interop.vixcom.constants cannot be embedded

Dec 8, 2010 at 6:15 PM

  I've been using VMWareTasks successfully with VMWare Workstation 6.5.4 for awhile.   While troubleshooting a time-out problem that I can't seem to resolve, I decided to try the same project against VMWare Workstation 7.1.   This involves moving from VixCOM 1.6.3.xxx to 1.9.3.xxx.   I'm using VS 2010.

  I can't get my project to compile in the new environment.  I cleaned the solution and deleted the three dlls from References in the Project and re-added them (Vestris.VMWareLib, Vestris.VMWareTools and Interop.VixCOM).  Now I get a rash of errors mostly like:

Interop type 'Interop.VixCOM.Constants' cannot be embedded.  Use the applicable interface instead.

Type 'Vestris.VMWareLib.VMWareVirtualMachine' from assembly '......\...\....\Vestris.VMWareLib.dll' cannot be used across assembly boundaries because a type in its inheritance hierarchy has a generic type parameter that is an embedded interop type.

  Evidently there's some other adjustment that I need to make?

Coordinator
Dec 8, 2010 at 6:52 PM

I think this is because you're trying to do a .NET 4.0 thing. A quick workaround should be to try to target .NET 4.0 client profile or .NET 2.0. Now, there might be something that can be changed in the code, if you find out, please share.

Dec 8, 2010 at 7:02 PM

Is targeting a specific generation of .NET something that I can configure VS 2010 to do?  I'm not yet familiar with that, if it is.

 

Coordinator
Dec 8, 2010 at 8:09 PM

http://msdn.microsoft.com/en-us/library/bb398202.aspx

Dec 10, 2010 at 4:33 PM
Edited Dec 10, 2010 at 5:23 PM

That's exactly right!  Thanks for the tip.  The .NET 4.0 client profile didn't help, but installing and using the 3.5 .NET client profile DID fix things!

 

Developer
Oct 11, 2011 at 12:11 AM

I found out that you can also set "Embed Interop Types" to false on the "Interop.VixCOM.dll" reference in your Visual Studio 2010 project to work-around this issue.

See this link for more detailed information:

http://blogs.msdn.com/b/vbteam/archive/2010/06/11/troubleshooting-errors-when-embedding-type-information-doug-rothaus.aspx

Mar 20, 2014 at 2:05 PM
The above does not work for version 1.17 of the VmTasks tools.

If you target a .NET framework prior to 4.0 you get this error
 'Vestris.VMWareLib.dll', or one of its dependencies, requires a later version of the .NET Framework than the one specified in the project.
when you try to add the reference is VS2010.

If the Embed Interop Types flag for Interop.Vix.COM is set to true (default), then this line in my code
private VMWareVirtualHost mHost;
gives you this complilation error
Type 'Vestris.VMWareLib.VMWareVirtualHost' from assembly '~\Vestris.VMWareLib.dll' cannot be used across assembly boundaries because a type in its inheritance hierarchy has a generic type parameter that is an embedded interop type.
If the Embed Interop Types flag for Interop.Vix.COM is set to false, then the above compilation error disappears to be replaced with the error on this line of code:
mVm.PowerOn(VixCOM.Constants.VIX_VMPOWEROP_NORMAL);
which reads:
Interop type 'VixCOM.Constants' cannot be embedded. Use the applicable interface instead.
Any suggestions on how to upgrade this code from using VixCCOMWrapper DLL to using VmTasks v1.17?
Or how to use "the applicable interface"?
Or which is the applicable interface for VixCOM.Constants.VIX_VMPOWEROP_NORMAL?
Mar 20, 2014 at 9:09 PM
Edited Mar 20, 2014 at 9:15 PM
If you try to set the Embed Interop Types flag on Vestris.VMWareLib.dll to true, then you get the compilation error:
Cannot embed interop types from assembly '~\Vestris.VMWareLib.dll' because it is missing either the 'ImportedFromTypeLibAttribute' attribute or the 'PrimaryInteropAssemblyAttribute' attribute