Problems Creating a VMRC ActiveX Instance at RunTime

9. April 2007 06:40 by Csaborio in General  //  Tags: ,   //   Comments (0)

During the Virtualization labs, which are freely available to anyone interested in Virtualization, the Artinsoft trainers have had a chance to teach the Virtual Server COM API and its uses.  One of the attendees showcases the application that they build on his blog. I think the application in its finished state is a great start to create something functional, but it is in no way something that can be used for management right out of the box.  The reason for this is simple: we wanted simple in order to reduce the learning curve of the COM API. 

I have started to work on my spare time on a new version of the Virtual Machine Configuration Assistant (VMCA) which will be version 2.0 due to major UI overhaul it has had.   One of the cool things I wanted to do, was the ability to open VMRC connections within the app in tabs (gotta love tabs in everything!).  So here is the interface I have so far (click on the image for larger view, as it has info on what I am trying to accomplish):

ZZ5B4D2238

Sounds easy, huh?  Well, that is what I thought.  I have in my application the reference to the VMRC ActiveX control, the image that you see above depicts a VMRC instance placed on the form in Design Time.

When the user selects the VMRC option, I have the following code:

vmrcControl = new AxVMRCClientControl();
vmrcControl.ServerAddress = "vs02";
vmrcControl.Size = new System.Drawing.Size(985, 675);
//Add a New Tab
this.tabPage1 = new TabPage();
tabPage1.Text = VMCA.VirtualInstances.getVMInstance().Name;
//Add the VMRC Control
tabPage1.Controls.Add(vmrcControl);
vmrcControl.Location = new System.Drawing.Point(0, 0);
this.tbcVMRC.TabPages.Add(tabPage1);
vmrcControl.UserName = "Administrator"

The line in red below is where all hell breaks loose:

ZZ735D6EE2

The problems seems to be that at design time, the VS Designer creates and configures a resource that is used to keep track of the ActiveX instance's state.  At runtime, this resource does not exists and that is the reason why the ActiveX is an invalid state.  Not being the ActiveX hacker that I would like to be, I am baffled on this problem.

Have you ever suffered with a problem such as the one above?  I have looked for help at various locations without any luck.  Although not critical, this feature is something that would definitely rock.  Help me solve this problem and I will send you a couple of pure quality Costa Rican coffee wherever you may be (if you are in Costa Rica, I'll send you beer instead ;)

I have posted a project which repros the problem:

http://amd.streamload.com/artinsoft/Links/5B75335893

In order to repro, just debug the app, and from the menus select Remote Control...if you can somehow make it through without the invalid OCX state exception, you are right on the money.

UPDATE: In order to run the project above, you *need* to have the VMRC ActiveX control installed on your machine.  The following page will guide you with the necessary steps to complete this process: https://www.microsoft.com/resources/virtuallabs/installactivex-technet.aspx

For all things related to software migration, be sure to visit Artinsoft's website.  For training in Visual Basic to C# migrations, Visual Basic to VB.Net,  Virtualization, and 64-bit training check our training web page.