Solved

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

Posted on 2010-11-11
6
821 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:hongning2009
Comment Utility
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
Comment Utility
If you've installed the Windows SDK & tools, you should find it in your Start menu.
0
 

Author Closing Comment

by:hongning2009
Comment Utility
Not very informative
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
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.

772 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

11 Experts available now in Live!

Get 1:1 Help Now