Using VB6 ActiveX components in .NET

Codeless

Well-known member
Joined
Jan 24, 2003
Messages
59
Location
Great NW
I have an ActiveX control that I have used in VB6 several times, but I cant seem to get it to work in .NET. What are the general steps to getting it to work in the .NET environment? I can add the component into my ToolBox and place it on my aspx, but then the code behind page doesnt seem to recognize it as a control.

I have tried to run the TblImp.exe on the original dll, but after I do, I cant add it to the ToolBox successfully. Am I way off base?
 
In addition to adding it your toolbox, you also need to add a
reference to the control in your projects references.

Go to the Project menu, then Add Reference. Select the COM tab,
and look for the control on the list or click Browse to find the DLL.
 
Thanks, I had forgotten to do that. Another one of my problems was that I didnt know I could give the control a name in the (id) property to expose the events on the code behind page.
Well now I know... and knowings half the battle. --GI Joe
 
Didnt work after all

I guess I spoke too soon. That actually wasnt the fix I was looking for. If I place the control on a Windows Form and run the app, it seems to work just fine as it did in VB6. However when I place it on a Web Form, I cant seem to interact with it. The control loads graphics (2D and 3D) Here are the clues:

The control appears on the web form, and when I run the app without interacting with it I get no errors and I can see that the control is working fine, although empty.

When placed on the web form it gets declared as a generic object instead of with the class that is normally used in the windows form even though I have a reference to the class library in the solution explorer.

When I try and reference it from the code-behind with its (id) name to load something to it, it is not recognized and tells me that the name has not been declared.

I can define a new control programmatically without errors, but cant add it to the web page because it is not a system.web.ui.control.

Any suggestions are greatly appreciated. I hope this all makes sense.
 
For the same reason that you cant add web controls to a windows form you cant add windows controls to web forms. They exist on two entirely different mediums, and should remain as such. Simply put, youre going to have to separate the ActiveX control, which I wouldnt recommend using in the first place, from your .NET logic. Dont expect to be able to interact with it like you would any of the controls found under System.Web.UI, since the most control youre going to have over it is passing it parameters via Response.Write().
 
I was expecting to be able to interact with it because when I add it to my toolbox it always shows up in the web forms tab. I guess thats just because of the way it was created.

Any other suggestions of how to expose it through the web would be very helpful. I do have a java applet that was sent with it. Can I expose the applet to people from the server side using .NET and jscript or something? (I legally cant distribute it in a client app). If so could someone point me in the right direction.

Thanks.
 
No, you cannot. Neither Java applets nor ActiveX controls (COM) are .NET components. The framework would have no idea how to render these objects.
 
Back
Top