Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Boxing COM objects... how does VB.NET resolve it?

Status
Not open for further replies.

urielk

Programmer
Jun 13, 2001
15
CA
I added to my project refernces an AciveX control, the enviroment created the wrapper as expected.

But when I try to use it, the compiler requires to cast the objects, example:

MyActiveXObj myObj = (MyActiveXObj)TheControl.MyObj;

but it fails at run time with invalid casting exception.

To test it I switched to Visual Basic.Net and it works without problem, the following line compiles and executes just fine:

Dim myObj as MyActiveXObj
myObj = TheControl.MyObj

What I am doing wrong in C# ?
 
There was an article in Visual Studio magazine this month about .NET and COM interoperability.

Sorry I couldn't be of more help.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top