Is there a C# wrapper for the VMware VIX API?
Asked Answered
F

4

7

I am using VMware Workstation 6.5 on Windows Vista x64. I would like to automate some of the VM management tasks. I know that there is a COM API (http://www.vmware.com/support/developer/vix-api/) available which I could use directly.

Is there a C# wrapper for this COM API?

Thanks,

Arnie

Flatfoot answered 17/12, 2008 at 23:50 Comment(0)
N
3

ArnieZ.

Any COM DLL can be used from .NET. Adding it as reference in visual studio will generate a DLL called

"YourDll.Interop.dll"

This is a .NET -> COM marshaling library, and will do what you need.

You can also generate this from the command line using tlbimp.exe

Of course, you'll have to keep in mind that you are invoking COM components, and remember to use the .NET Marshaling API to decrease reference counts when you are done using them, otherwise you will cause memory leaks.

I've wrapped the interop implementation in another library that implements IDisposable on its objects so that cleanup is handled automatically before, but if it is a large library, this might not be worth the effort.

Northerly answered 18/12, 2008 at 0:8 Comment(0)
T
7

There's now a nice library that wraps this up: http://www.codeproject.com/KB/library/VMWareTasks.aspx

Torpor answered 23/12, 2008 at 23:30 Comment(3)
Thank you. Good work! Sadly, I've discovered that VMware Workstation doesn't expose certain management operations that I need (such as creation of VMs and VM teams). I won't be able to reach the level of automation that I want until I upgrade to ESX, :-(Flatfoot
It is very nice indeed. And dblock is the author of said wrapper, and a very helpful person!Guff
Fyi, VMWareTasks has moved to github.com/dblock/vmwaretasks/blob/master/README.mdConcentric
C
5

VMWareTasks is a complete wrapper for VixCOM: http://vmwaretasks.codeplex.com

Concentric answered 15/6, 2009 at 12:45 Comment(2)
does this require some redist components to be copied ? i couldn't find any .NET wrapper library that works without installing VIX on the target box.Papotto
It requires VIX, yes. Still makes it a lot easier to use than VIX directly.Concentric
N
3

ArnieZ.

Any COM DLL can be used from .NET. Adding it as reference in visual studio will generate a DLL called

"YourDll.Interop.dll"

This is a .NET -> COM marshaling library, and will do what you need.

You can also generate this from the command line using tlbimp.exe

Of course, you'll have to keep in mind that you are invoking COM components, and remember to use the .NET Marshaling API to decrease reference counts when you are done using them, otherwise you will cause memory leaks.

I've wrapped the interop implementation in another library that implements IDisposable on its objects so that cleanup is handled automatically before, but if it is a large library, this might not be worth the effort.

Northerly answered 18/12, 2008 at 0:8 Comment(0)
S
1

How 'bout adding a reference to this API in your VS.Net and let VS.Net create a managed wrapper for you? I'm not aware of any "managed" API for this. Let me know if you find it :)

Subservient answered 17/12, 2008 at 23:52 Comment(1)
If I don't find one, I might consider writing one. That would be an interesting project... :)Flatfoot

© 2022 - 2024 — McMap. All rights reserved.