Solved

TypeInitializationException was unhandled on Windows 7 64 bit OS and VStudio 2008

Posted on 2010-11-11
6
823 Views
Last Modified: 2012-05-10
I have a new Windows 7 64 bit OS laptop with Visual Studio 2008 .

Program is coded in C#

Everytime I debug the program it give me this error

TypeInitializationException was unhandled
The type initializer for 'ADOHelper' threw an exception.

ADOHelper is a class that I created

It errors on this line
ADOHelper dHelper = new ADOHelper();

This works on a Windows 7 32 bit OS with Visual Studio 2008, but gives out an error in the 64 bit environment.

Do I need to specify a 32 bit option and how do you do it, any suggestions will be appreciated

Thanks
First part of ADO Helper Code

using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System;
using System.Collections;
using System.Windows.Forms;
using Microsoft.Win32;
using iqcnet;
using itevtlogwrap;
using formdbwrap;


public enum CONFTYPE {CENTRAL, DEMO};
public enum RETURNVAL
{
	ERROR_ONLINEHELP_MISSING=-28,
	ERROR_INVALID_REPT_FIELD_ORDER=-27,
	ERROR_GUIFILE_SAVE=-26,
	ERROR_GUIFILE_FROMFORM=-25,
	ERROR_GUIFILE_CORRUPTED=-24,
	ERROR_GUIFILE_LOAD=-23,
	ERROR_CHARSECTION_SAVE=-22,
	ERROR_SAVE_ADDITIONAL_DATA=-21,
	ERROR_FIELDSECTION_SAVE=-20,
	ERROR_INVALID_FORMIDX=-19,
	ERROR_FORMSECTION_SAVE=-18,
	ERROR_DOCSECTION_SAVE=-17,
	ERROR_FILE_SAVE=-16,
	ERROR_FILENOTOPEN=-15,
	ERROR_FILE_CREATE_ERROR=-14,
	ERROR_FILENOTFOUND=-13,
	ERROR_IQCDISCONN=-12,
	ERROR_REGOPENCONF=-11,
	ERROR_REGNOFORMDB=-10,
	ERROR_REGNOGENAPPKEY=-9,
	ERROR_REGNOCHECKPOINT=-8,
	ERROR_IQCNOLICMANAGER=-7,
	ERROR_IQLICMGRDOWN=-6,
	ERROR_IQCLICEXCEEDS=-5,
	ERROR_IQCLICMANAGER=-4,
	ERROR_IQCSTARTUP=-3,
	ERROR_ACCESSDENIED=-2,
	ERROR_GENERAL=-1,
	SUCCESS=1
}
	public class ADOHelper
	{
		//copied
		private static string m_strEnvName = "DEFAULT";
		public const string APPNAME = "iConfigForm";
		private static string m_strLicManager;
		public static string VERSION;
		private static CONFTYPE m_enConfType = CONFTYPE.CENTRAL;
		private static CIqcNet m_iqc = null;
        private static EventLogWrap m_log;
        private static string m_strFormDBDir;

Open in new window

0
Comment
Question by:hongning2009
  • 3
  • 2
6 Comments
 
LVL 13

Expert Comment

by:AngryBinary
ID: 34116894
I would suspect that one of these packages:

using iqcnet;
using itevtlogwrap;
using formdbwrap;

... may depend on 32-bit only stuff (oddly enough, I think the Microsoft.Win32 namespace is kosher in a 64-bit environment). If you had more info on what those were, it might help bear out what the problem is. You could probably work around it by changing your build configuration to target x86 specifically, instead of "Any CPU", if that's currently the case.

You access this option via the Standard toolbar (make sure it's enabled in View > Toolbars). There's a dropdown that says "Any CPU" by default. If you don't see the x86 option in there, select the "Configuration Manager..." option. You will get a dialog with the "Active solution platform" dropdown set to "Any CPU". Select the "<New...>" option, and you will get another dialog where you just need to select "x86".
0
 

Author Comment

by:hongning2009
ID: 34122125
I already changed to x86 and it still have the same problem.  Anyway I know this libraries work because it worked on a Windows 2008 x64 server.

Anyway when I look at the details I found out that the one cause the error is iqcnet

It has this error

Could not load file or assembly 'iqcnet, Version=5.0.0.2000, Culture=neutral, PublicKeyToken=236c11700a57dbaf' or one of its dependencies. The system cannot find the file specified.":"iqcnet, Version=5.0.0.2000, Culture=neutral, PublicKeyToken=236c11700a57dbaf

I have this in the reference  and I even used gacutil tp register, but problem still occurs.

Do you have any suggestions?

Thanks
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34122488
Could be you're missing an assembly that iqcnet depends on.  You can check with the documentation for that assembly, or if you have the Windows SDK you can use the IL disassembler to view the manifest of the iqcnet assembly (which will tell you the names of the assemblies it depends on).
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:hongning2009
ID: 34220584
What is the exe file of this IL disassembler?  Any help is appreciated
0
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 500 total points
ID: 34226211
If you've installed the Windows SDK & tools, you should find it in your Start menu.
0
 

Author Closing Comment

by:hongning2009
ID: 34259488
Not very informative
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now