TypeInitializationException exception thrown in VS2010 web project

Jul 13, 2009 at 8:48 PM

I'm trying to run the example code in a web application but I always get a TypeInitializationException during ConnectToVMWareWorkstation call.
I've installed the latest VMWare VIX library (VMware-vix-1.6.2-127388.exe) and have the Vetris.VMWareLib referenced in the Visual Studio 2010 Beta1 project.

Am I missing something obvious?

Exception data:

System.TypeInitializationException
{"The type initializer for 'Vestris.VMWareLib.VMWareInterop' threw an exception."}

InnerException
{"Retrieving the COM class factory for component with CLSID {6874E949-7186-4308-A1B9-D55A91F60728} failed due to the following error: 80040154."}<font face="Consolas" size="2"><font face="Consolas" size="2">

Code:

</font></font><font face="Consolas" size="2">

 

</font>


VMWareVirtualHost
virtualHost = new VMWareVirtualHost(); // this runs fine
virtualHost.ConnectToVMWareWorkstation();                // exception thrown

Coordinator
Jul 14, 2009 at 10:42 AM

The error 0x80040154 is "class not registered" and the GUID is the one of VixCOM.VixLib.1, looks to me like VMWare VIX is not (properly) installed. I would manually try to register regsvr32 C:\Program Files\VMware\VMware VIX\VixCOM.dll, and if that doesn't work around the problem, examine the VixLib Class in oleview. You should have HKEY_CLASSES_ROOT\CLSID\{6874E949-7186-4308-A1B9-D55A91F60728} in registry and that should point to the right DLL.

Jul 15, 2009 at 10:10 AM

Thanks for the info, I'll try that once I get to my development machine.

One thing that I forgot to mention: I'm using "Clasic ASP.NET" appication pool for which also implies using .NET Framework 2.0. Could this be of relevance here?

Coordinator
Jul 15, 2009 at 12:00 PM

The library is .NET 2.0. It could be relevant that you are running under ASP.NET, but you would get a different exception in case of a security problem. If re-registration doesn't work, write a simple console application first that does the same thing and runs on the same machine. If that works, but the ASP.NET application doesn't, that will point to a different problem.

Jan 24, 2010 at 12:45 PM

I also wanted to let others know that if you are running on x64 and getting the "The type initializer for 'Vestris.VMWareLib.VMWareInterop' threw an exception"  you will need to change the build from Any CPU to x86 so that the com interop will work.

 

 

Coordinator
Jan 24, 2010 at 1:08 PM
beckhamk wrote:

I also wanted to let others know that if you are running on x64 and getting the "The type initializer for 'Vestris.VMWareLib.VMWareInterop' threw an exception"  you will need to change the build from Any CPU to x86 so that the com interop will work.

 

 

 Can you please create an issue/upload a patch so I can commit it for this? Thx.