Could not load file or assembly 'Interop.VixCOM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1a2e7e25925ba452'

Sep 30, 2009 at 1:19 PM
Edited Sep 30, 2009 at 1:23 PM

Hi dblock, all


I wonder if you or anyone else can help with what is a really basic thing, I think.

I'm getting the following error when I try to do anything, including just this line: "VMWareVirtualHost virtualHost = new VMWareVirtualHost();"

Could not load file or assembly 'Interop.VixCOM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1a2e7e25925ba452'

Is this because I don't have any VMWare stuff installed on my machine (other than the SDK which I downloaded and installed)?

 

I have included a reference to the dll as mentioned in the help file, and then tried including various references to other dlls both from that folder and the VMWare-supplied Com object. So I'm wondering if I actually needed. I have looked at installing them but as much as anything else I'm not sure what I could install (for free) - to a newbie to the VMWare product set VMWare seems to do their best to confuse with similar sounding marketing names and some renaming that isn't done throughout their website!

 

Cheers

 

R

 

Edit:

Just thought some more detail may be useful. I'm writing a WCF service. It (the project) builds fine, and I get that error when I try to run it by clicking Invoke on the WCF Test Client. .Net 3.5, VS 2008, Vista. The host is connected to via a VPN, but I'm not getting that far at the moment, I've commented out all lines but the one I copied in above.

Coordinator
Sep 30, 2009 at 1:28 PM

Start with a simple command line test program. If that works, you'll know that the machine is okay and everything is installed. If not, copy-paste the entire stack of the exception here.

Next is the WCF service story, that might get much more complicated because of isolation and permissions.

You might need to include a reference to the COM object DLL as well if you use any of the constants. Otherwise it's not necessary.

Sep 30, 2009 at 1:59 PM
Edited Oct 21, 2010 at 9:49 AM

Hi, and thanks for the incredibly quick response.

I ran up a simple test program, and I'll include the source below.

I can get to and past the "VMWareVirtualHost virtualHost = new VMWareVirtualHost();" line now with no problems, but I get an error on the next line (The type initializer for 'Vestris.VMWareLib.VMWareInterop' threw an exception.)

I have tried adding a reference to either "Interop.VixCom" (included in the download) or "VixCom" (from the VMWare SDK) or none of those.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Vestris.VMWareLib;

namespace ConsoleApplicationTest {
    class Program {
        private static String vimHost = "https://ip:port/sdk";
        private static String userName = "username";
        private static String password = "password";

        static void Main(string[] args) {
            string cpu = "";

            VMWareVirtualHost virtualHost = new VMWareVirtualHost();
//            virtualHost.ConnectToVMWareVIServer(vimHost, userName, password); // If I uncomment this I get an error :(

            //foreach (VMWareVirtualMachine vm in virtualHost.RegisteredVirtualMachines) {
            //    cpu = " " + vm.CPUCount.ToString();
            //};
            Console.WriteLine(cpu);
            Console.ReadKey();
        }
    }
}

I don't know if it has any bearing (I had assumed not) but I'm running 64Bit Vista, btw.

Cheers

R

 

For completeness, in case this is an error someone gets, I

System.TypeInitializationException was unhandled
  Message="The type initializer for 'Vestris.VMWareLib.VMWareInterop' threw an exception."
  Source="Vestris.VMWareLib"
  TypeName="Vestris.VMWareLib.VMWareInterop"
  StackTrace:
       at Vestris.VMWareLib.VMWareVirtualHost.ConnectToVMWareVIServer(String hostName, String username, String password)
       at ConsoleApplicationTest.Program.Main(String[] args) in C:\Files\Code\V\ConsoleApplicationTest\ConsoleApplicationTest\Program.cs:line 17
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Runtime.InteropServices.COMException
       Message="Retrieving the COM class factory for component with CLSID {6874E949-7186-4308-A1B9-D55A91F60728} failed due to the following error: 80040154."
       Source="Vestris.VMWareLib"
       ErrorCode=-2147221164
       StackTrace:
            at Vestris.VMWareLib.VMWareInterop..cctor()
       InnerException:

 

And here's the stack from my WCF, again for completeness (and Google!)

Could not load file or assembly 'Interop.VixCOM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1a2e7e25925ba452' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Server stack trace:
   at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at IService1.GetData(Int32 value)
   at Service1Client.GetData(Int32 value)

Sep 30, 2009 at 2:52 PM
Edited Sep 30, 2009 at 3:07 PM

Update:

I had an idea, and tried changing the target platform for my app to x86 (right click on project, Build tab, Platform target if you've not encountered this).

It worked. Well, sort of. I then got the message "Unable to Connect to Host".

I then realised that perhaps I needed to change my ConnectTo call so it reads

virtualHost.ConnectToVMWareVIServer(new Uri(vimHost), userName, password, 100);

and that seems to do the trick.

The for each loop (as above, uncommented) takes an age though. Is there a way to speed this up? (not a complaint, which it may sound like, just a question!)

As an aside I tried using Vestris.VMWareLib as I'm two weeks into a job and the folks really needed this before I started. That connects and returns registered servers, so my connection strings, it would seem are correct (used the same strings to connect while still trying to use the VixCom a few days ago).

I'm now looking at going and grabbing stuff from the database for the sake of speed, but that's risky, I reckon - can't find much documentation (immediate problem) and it may change (may be worth the risk).

R

Coordinator
Sep 30, 2009 at 7:42 PM

This explains it! I bet VixCOM isn't doing something right at registration that makes a 64-bit managed application fail to load it. This was discussed here. I'll add a note in the VMWareTasks documentation.

Coordinator
Sep 30, 2009 at 7:47 PM
Retne wrote:

I then realised that perhaps I needed to change my ConnectTo call so it reads

virtualHost.ConnectToVMWareVIServer(new Uri(vimHost), userName, password, 100);

and that seems to do the trick.

 

The ConnectToVMWareVIServer implementation that takes a string looks like this:

public void ConnectToVMWareVIServer(string hostName, string username, string password, int timeoutInSeconds)
{
            ConnectToVMWareVIServer(new Uri(string.Format("https://{0}/sdk", hostName)),
                username, password, timeoutInSeconds);
}

So if you want to pass the full URL, you have to make an Uri out of it (as you did), but you can strip the whole https:// and /sdk part and call the string method.

Coordinator
Sep 30, 2009 at 7:51 PM
Retne wrote:

The for each loop (as above, uncommented) takes an age though. Is there a way to speed this up? (not a complaint, which it may sound like, just a question!)

I'm now looking at going and grabbing stuff from the database for the sake of speed, but that's risky, I reckon - can't find much documentation (immediate problem) and it may change (may be worth the risk).

The RegisteredVirtualMachines call is actually opening each vitual machine as you go through them (otherwise all you get is a handle and there's not much you can do with that). So it takes time, all spent on the VMWare Server. VMWareTasks is using yield, so it opens them one-at-a-time rather than all-at-once, so that's at least scaling up to hundreds of virtual machines.

VMWareJobCallback callback = new VMWareJobCallback();
using (VMWareJob job = new VMWareJob(_handle.FindItems(
 Constants.VIX_FIND_REGISTERED_VMS, null, -1, callback),
 callback))
{
 object[] properties = { Constants.VIX_PROPERTY_FOUND_ITEM_LOCATION };
 foreach (object[] runningVirtualMachine in job.YieldWait(properties, VMWareInterop.Timeouts.FindItemsTimeout))
 {
  yield return this.Open((string)runningVirtualMachine[0]);
 }
}

You can always try the VixCOM forum to see if anyone has a suggestion of how to improve performance here. I'd offload the collection process to something that runs all the time (or every 24 hours) else and would query a cached copy if this needs to be fast.

 

Jul 8, 2011 at 10:29 PM

 

I am getting the same runtime error "Could not load file or assembly 'Interop.VixCOM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1a2e7e25925ba452' or one of its dependencies."

using VMWareTasks 1.5  with Vix 1.10 in a one line command line program that only tries to create a virtual host like so "VMWareVirtualHost virtualHost = new VMWareVirtualHost();".

 

I am running WIndows Enterprise 7 64bit and compiling with the x86 build option in Visual Studio 2010. In my Visual Studio project I  have references to the following .dlls

- Interop.Vixcom              (VMWareTasks 1.5)

- Vestris.VMWareComLib (VMWareTasks 1.5)

- VixCom (Vix 1.10)

 

Here are the exception details:

 

System.IO.FileLoadException was unhandled  Message=Could not load file or assembly 'Interop.VixCOM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1a2e7e25925ba452' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)  Source=VMwareAutomationExample  FileName=Interop.VixCOM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1a2e7e25925ba452  FusionLog==== Pre-bind state information ===LOG: User = AGILENT\rfeldmanLOG: DisplayName = Interop.VixCOM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1a2e7e25925ba452 (Fully-specified)LOG: Appbase = file:///C:/Users/rfeldman/Documents/VMwareAutomationExample/VMwareAutomationExample/bin/Debug/LOG: Initial PrivatePath = NULLCalling assembly : Vestris.VMWareLib, Version=1.5.24311.0, Culture=neutral, PublicKeyToken=null.===LOG: This bind starts in default load context.LOG: No application configuration file found.LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.LOG: Post-policy reference: Interop.VixCOM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1a2e7e25925ba452LOG: Attempting download of new URL file:///C:/Users/rfeldman/Documents/VMwareAutomationExample/VMwareAutomationExample/bin/Debug/Interop.VixCOM.DLL.WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKENERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
  StackTrace:       at VMwareAutomationExample.Program.Main(String[] args)       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)       at System.Threading.ThreadHelper.ThreadStart()  InnerException: 

 

Any suggestions will be greatly appreciated.

 

Cheers,

Roy

Coordinator
Jul 9, 2011 at 1:57 PM

I've never seen the "failed to complete setup of assembly because of a public key token error". I would check the usual suspects first - make sure you've installed VixCOM (comes from VMWare), that you've used Interop.VixCom that came with the library and that you're not targeting Win64 target platform (VixCOM is 32-bit, so you can't do that). The .NET profile might also have something to do with this.

Jul 11, 2011 at 12:37 AM

Hi dblock,

Thank you  for your reply.  I do have have VixCom installed and referenced as part of my Visual Studio project. Also, I have my build setting set to 32bit (x86).

However, I think you are on to something regarding my .Net profile.  The project I am to trying to use VMWareTasks is based on .Net 3.5, not 4.0.

After getting the error I reported with released .dlls, I decided to get the latest VMwareTasks source from the repository and  I did a build all.  

During the build I got an error regarding Interop.Vixcom dll.  I can't give you the exact error message at this moment, but it was something to the effect that Interop.VixCom was built for .Net 4.0 and my environment is set for .Net 3.5.

Is is possible to use VMwareTasks with .Net 3.5?   In particular, is there a way to get a Interop.VixCom dll compatible with .Net 3.5.

When I am back at my main development machine, I will be able to give you the exact load error I go when I tried to build from source.

Coordinator
Jul 11, 2011 at 1:09 PM

Try a build from command line, build all. Does that fail? Try running it as admin too, I think something is being registered. 

Jul 11, 2011 at 5:21 PM

Hi dlock,

Thanks again for your reply.  I need to travel today, so I won't be able try your suggestion until late today.  I will report the results

as soon as I can.

 

Cheers,

 

Roy 

Jul 11, 2011 at 11:34 PM

Hi dblock,

Running the Visual Studio command prompt as Administrator, I just did a build all of the latest VMWareTasks source in the trunk directory . I get the following build errors:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Building "C:\Users\rfeldman\svnroot\vmwaretasks\trunk\VMWareTasks.sln" (2:2) onnode 0 (default targets).Project "C:\Users\rfeldman\svnroot\vmwaretasks\trunk\VMWareTasks.sln" (2:2) isbuilding "C:\Users\rfeldman\svnroot\vmwaretasks\trunk\Source\Version\Version.csproj" (3:2) on node 0 (default targets).  Creating directory "bin\Debug\".  Creating directory "obj\Debug\".CopyFilesToOutputDirectory:  Copying file from "obj\Debug\Version.dll" to "bin\Debug\Version.dll".  Version -> C:\Users\rfeldman\svnroot\vmwaretasks\trunk\Source\Version\bin\Deb  ug\Version.dll  Copying file from "obj\Debug\Version.pdb" to "bin\Debug\Version.pdb".Done Building Project "C:\Users\rfeldman\svnroot\vmwaretasks\trunk\Source\Version\Version.csproj" (default targets).
Project "C:\Users\rfeldman\svnroot\vmwaretasks\trunk\VMWareTasks.sln" (2:2) isbuilding "C:\Users\rfeldman\svnroot\vmwaretasks\trunk\Source\VMWareLib\VMWareLib.csproj" (4:2) on node 0 (default targets).  Creating directory "bin\Debug\".  Creating directory "obj\Debug\".ResolveAssemblyReferences:  Primary reference "Interop.VixCOM".C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible.Could not load file or assembly 'C:\Users\rfeldman\svnroot\vmwaretasks\trunk\Source\Interop.VixCOM\Interop.VixCOM.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot beloaded.      Resolved file path is "..\Interop.VixCOM\Interop.VixCOM.dll".      Reference found at search path location "{HintPathFromItem}".VMWareException.cs(4,7): error CS0246: The type or namespace name 'Interop' could not be found (are you missing a using directive or an assembly reference?)

 

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

The error "The type or namespace name 'Interop' could not be found" is repeated multiple times.  Not that I am using the  .Net 3.5 Framework.  Is the problem above being caused because Interop.VixCOM is built with .Net 4.0?  Unfortunately, I need to use .Net 3.5 for this particular application.  It appears that Interop.VixCOM is a third party library, being used by VMWareTasks.  In any case,  is there a workaround to this problem? For example, is it possible to acquire or generate a Interop.VixCOM dll that is compatible with both .Net 3.5 and VMWareTasks?

Also, I get additional build errors, but for all I know they may all be consequences of the problem with Interop.VixCOM.  Here are the additional build errors:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  VMWareJob.cs(12,46): error CS0246: The type or namespace name 'IJob' could not be found (are you missing a using directive or an assembly reference?)  VMWareVixHandle.cs(4,7): error CS0246: The type or namespace name 'Interop' could not be found (are you missing a using directive or an assembly reference?)  VMWareJobCallback.cs(5,7): error CS0246: The type or namespace name 'Interop' could not be found (are you missing a using directive or an assembly reference?)  VMWareJobCallback.cs(12,38): error CS0246: The type or namespace name 'ICallback' could not be found (are you missing a using directive or an assembly reference?)  VMWareVirtualMachine.cs(4,7): error CS0246: The type or namespace name 'Interop' could not be found (are you missing a using directive or an assembly reference?)  VMWareVirtualMachine.cs(30,57): error CS0246: The type or namespace name 'IVM2' could not be found (are you missing a using directive or an assembly reference?)  VMWareRootSnapshotCollection.cs(5,7): error CS0246: The type or namespace name 'Interop' could not be found (are you missing a using directive or an assembly reference?)  VMWareSnapshotCollection.cs(5,7): error CS0246: The type or namespace name 'Interop' could not be found (are you missing a using directive or an assembly reference?)  VMWareSharedFolder.cs(5,7): error CS0246: The type or namespace name 'Interop' could not be found (are you missing a using directive or an assembly reference?)  VMWareSharedFolderCollection.cs(5,7): error CS0246: The type or namespace name 'Interop' could not be found (are you missing a using directive or an assembly reference?)  VMWareSnapshot.cs(6,7): error CS0246: The type or namespace name 'Interop' could not be found (are you missing a using directive or an assembly reference?)  VMWareSnapshot.cs(13,51): error CS0246: The type or namespace name 'ISnapshot' could not be found (are you missing a using directive or an assembly reference?)  VMWareVirtualHost.cs(3,7): error CS0246: The type or namespace name 'Interop' could not be found (are you missing a using directive or an assembly reference?)  VMWareVirtualHost.cs(10,54): error CS0246: The type or namespace name 'IHost' could not be found (are you missing a using directive or an assembly reference?)  VMWareJob.cs(21,26): error CS0246: The type or namespace name 'IJob' could not be found (are you missing a using directive or an assembly reference?)  VMWareJobCallback.cs(24,32): error CS0246: The type or namespace name 'IJob'could not be found (are you missing a using directive or an assembly reference?)  VMWareJobCallback.cs(24,57): error CS0246: The type or namespace name 'IVixHandle' could not be found (are you missing a using directive or an assembly reference?)  VMWareJobCallback.cs(42,49): error CS0246: The type or namespace name 'IJob'could not be found (are you missing a using directive or an assembly reference?)  VMWareJobCallback.cs(42,75): error CS0246: The type or namespace name 'IVixHandle' could not be found (are you missing a using directive or an assembly reference?)  VMWareRootSnapshotCollection.cs(23,45): error CS0246: The type or namespace name 'IVM2' could not be found (are you missing a using directive or an assembly reference?)  VMWareSharedFolderCollection.cs(17,17): error CS0246: The type or namespace name 'IVM' could not be found (are you missing a using directive or an assemblyreference?)  VMWareSharedFolderCollection.cs(24,45): error CS0246: The type or namespace name 'IVM' could not be found (are you missing a using directive or an assemblyreference?)  VMWareSnapshot.cs(15,17): error CS0246: The type or namespace name 'IVM2' could not be found (are you missing a using directive or an assembly reference?)  VMWareSnapshot.cs(25,31): error CS0246: The type or namespace name 'IVM2' could not be found (are you missing a using directive or an assembly reference?)  VMWareSnapshot.cs(25,40): error CS0246: The type or namespace name 'ISnapshot' could not be found (are you missing a using directive or an assembly reference?)  VMWareSnapshotCollection.cs(18,19): error CS0246: The type or namespace name'IVM2' could not be found (are you missing a using directive or an assembly reference?)  VMWareSnapshotCollection.cs(30,41): error CS0246: The type or namespace name'IVM2' could not be found (are you missing a using directive or an assembly reference?)  VMWareVirtualHost.cs(44,19): error CS0246: The type or namespace name 'IHost2' could not be found (are you missing a using directive or an assembly reference?)  VMWareVirtualMachine.cs(100,21): error CS0246: The type or namespace name 'IVM2' could not be found (are you missing a using directive or an assembly reference?)  VMWareVirtualMachine.cs(114,36): error CS0246: The type or namespace name 'IVM2' could not be found (are you missing a using directive or an assembly reference?)  VMWareVirtualMachine.cs(203,21): error CS0246: The type or namespace name 'IVM2' could not be found (are you missing a using directive or an assembly reference?)  VMWareVirtualMachine.cs(209,28): error CS0246: The type or namespace name 'IVM2' could not be found (are you missing a using directive or an assembly reference?)  VMWareVirtualMachine.cs(257,37): error CS0246: The type or namespace name 'IVM2' could not be found (are you missing a using directive or an assembly reference?)  VMWareVixHandle.cs(25,19): error CS0246: The type or namespace name 'IVixHandle' could not be found (are you missing a using directive or an assembly reference?)  VMWareVixHandle.cs(39,19): error CS0246: The type or namespace name 'IVixHandle2' could not be found (are you missing a using directive or an assembly reference?)  VMWareVirtualHost.cs(24,22): error CS0103: The name 'Constants' does not exist in the current context  VMWareVirtualHost.cs(28,27): error CS0103: The name 'Constants' does not exist in the current context  VMWareVirtualHost.cs(32,43): error CS0103: The name 'Constants' does not exist in the current context  VMWareVirtualHost.cs(36,22): error CS0103: The name 'Constants' does not exist in the current context  VMWareVirtualMachine.cs(19,16): error CS0103: The name 'Constants' does not exist in the current context  VMWareVirtualMachine.cs(24,18): error CS0103: The name 'Constants' does not exist in the current context

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

Any help with this problem will be greatly appreciated.  If I can't get a solution to this problem, I will unfortunately have to forgo using VMWareTasks for now.  That would be unfortunate for me, since it appears that VMWareTasks takes a lot of the pain out of using the VMWare VixCOM api with C#.

Cheers,

 

Roy

Coordinator
Jul 12, 2011 at 2:53 AM

It's pretty puzzling, I am pretty sure this has nothing to do with version of .NET framework by now.  Try running regsvr32 "C:\Program Files (x86)\VMware\VMware VIX\VixCOM.dll" as admin. Does that succeed? Does that change anything?

Jul 12, 2011 at 5:42 PM

 

 Running regsvr32 "C:\Program Files (x86)\VMware\VMware VIX\VixCOM.dll" succeeds, but it doesn't change the results of the build.  Any other ideas?

 

Thanks,

 

Roy

Coordinator
Jul 12, 2011 at 6:16 PM

I am puzzled. You're using VS 2008 (ie. not converting the project to anything)? I think you'll have to isolate the problem further and spend some google time figuring out what's wrong. My advice is clearly not helping :(

Jul 12, 2011 at 11:25 PM

 

FWIW, I am using VS 2010.  After getting the source from the repository, I am not doing any project conversion.  I simply open up Visual Studio Command Prompt as Administrator and run build all in the trunk.

Thanks for your help, but I think I have already started to roll my own wrapper around VixCOM for now.  Looking at the VMWareTasks source code is helpful, but I can't really spend anymore time researching why I can't use VMWareTasks for now.

 

Cheers,

 

Roy

Coordinator
Jul 13, 2011 at 2:34 PM

I create a new console app in VS 2010, added references to Interop.VixCOM and Vestris.VMWareLib from the 1.5 release, added using Vestris.VMWareLib. Trying to create a virtual host resulted in this error.

Error 2 Type 'Vestris.VMWareLib.VMWareVirtualHost' from assembly 'c:\temp\ConsoleApplication1\Vestris.VMWareTasks\1.5\Bin\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. c:\temp\ConsoleApplication1\ConsoleApplication1\Program.cs 13 13 ConsoleApplication1

This is related to the .NET profile vs. COM, it's too long to explain. Changing to .NET 3.5 client profile works around this.

I could connect to a virtual machine just fine.

I think your problem is exactly the question you asked first (that I missed) - you've imported VixCOM.dll, which created an Interop.VixCOM which has a version 1.0. But VMWareTasks comes with its own which is strongly versioned. I suspect that if you get rid of all your instances of Interop.VixCOM.dll in your project and just reference the one from VMWareTasks things will work.

Of course, rolling out your own wrapper is a wonderful idea. You'll get to learn first hand how complicated it can get to use the VixCOM API in a stable and reliable way :)

Jul 13, 2011 at 5:51 PM

 

Hi dblock,

 

Thank you for your "dogged persistence" in resolving my issue and teaching me , a .Net newbie,  a few things about .Net profiles interacting with COM.

I assure you that I  am either too lazy or not masochistic enough, or both, to duplicate VMWareTasks.  Working directly with the VixCOM API in C# is clearly painful and ripe with opportunities to make

time-consuming errors. 

 

Cheers,

Roy

Developer
Oct 11, 2011 at 12:12 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 the "cannot be used across assembly boundaries because a type in its inheritance hierarchy has a generic type parameter that is an embedded interop type." 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