ArtinSoft's Blogs

Software Migration Experts
Welcome to ArtinSoft's Blogs Sign in | Join | Help
in Search

Jose Aguilar's Blog

All things migrations, software and technology

.NET and the Virtual Server 2005 COM API

Accessing Virtual Server’s COM objects from .NET is not as direct as just including the references to the COM classes. In order to instantiate to the Virtual Server object, you need to have the proper COM permissions. For Virtual Server, the required impersonation level must be Impersonation or higher.

There are two ways to achieve this:

  1. The first one is to use Component Services to change the Default Impersonation Level to Impersonate. To do this in the Component Service console, go to Computers->My Computer->Properties, and the setting is in the Default Properties tab. This has obvious security implications, though.
  2. The second method is to do it programatically. This can be a bit painful if you’re not familiar with COM and COM Security. You have basically two options:
    • Use the method described in the Virtual Server Programming Guide, that you can find here: .
    • You can also use an alternative method, described by Virtual PC Guy in his blog as a solution to connect to Virtual Server from Powershell. You can check the link to review the code, which consists in using the CoSetProxyBlanket function, that according to the documentation “Sets the authentication information that will be used to make calls on the specified proxy.” Implementing a class similar to the one described on the linked page should work and is much simpler than the recommended approach descrbied in the Programming Guide.
Published Aug 03 2006, 10:00 PM by Jaguilar
Filed under:

Comments

 

smurillo said:

This will fix the COM security settings for you, but if you are running your application from Visual Studio 2005 on debug mode, you might still experience security errors.
You will need to go to the Debug tab on the Project Properties and uncheck the "Enable Visual Studio hosting process" option.
August 9, 2006 9:47 AM
 

Jaguilar said:

Thanks Stephen. :o)
August 11, 2006 2:41 PM

Leave a Comment

(required) 
(optional)
(required) 
Submit

About Jaguilar

Jose A. Aguilar has been working at ArtinSoft for more than 6 years, starting out with Informix to Java migrations and moving on to VB6 to .NET conversions using the Visual Basic Upgrade Companion. He currently works as both Senior Software Migration Consultant and Program Manager for the Visual Basic Upgrade Companion, helping clients to leverage their existing investments in VB6 by moving them to .NET Framework.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems