Com Excpetion Bad variable

Hi,

I am working in vs2005 using vb.net. I am using the Com interop objects in my present windows application. I am storing the variables like settings of my usercontrol using the Cominterop object. At present i don't have the definitions of com objects. I just have the Interops. When i am able to store the values, but at the the time retrieving the values from the com interop object it's throwing Com Exception Bad variable. Can any body explain, which issues needs to be take care when retrieving the values from the com interop objects?

Thanks,

Venu

[585 byte] By [zoomer] at [2007-12-27]
# 1
You need to show us the COM interface declaration you are using and the .NET code that uses it. If you are not sure, what the COM interface looks like, use the OleView.exe tool, File + View Type library. You'll find it in the Common7\Tools\Bin subfolder of the VS2005 installation folder.

nobugz at 2007-9-4 > top of Msdn Tech,.NET Development,Common Language Runtime...
# 2

Thanks for your reply. Can you tell me what you would like to do when you get Com Exception Bad variable. Because i am storing some variables such a,b,c in my cominterop object as object. I am retrieving the values into the object only, and then i am storing that object into an integer variable. I tried to typecast into that. Still it's throwing exception as Com Exception bad variable.

Another thing i would like to know how to deal with the intPtr and uIntPtr structures in the .Net environment ?

Thanks.

Venu .

zoomer at 2007-9-4 > top of Msdn Tech,.NET Development,Common Language Runtime...
# 3
The typical way you'd get an error like that is when the COM interface takes a VARIANT (the ActiveX version of Object) and you pass it an object that has a type the component doesn't like. There'll be code in the COM component that looks at the type of the VARIANT. It might handle BSTR (string) or I2 (short) and will say "bad type" on anything else. You'd have to take a look at the source code for the COM component or the documentation to know what it will accept.

nobugz at 2007-9-4 > top of Msdn Tech,.NET Development,Common Language Runtime...
# 4

Hi,

Thank you for your reply. Your assumption is exactly correct. Now it's not throwing exception. I am passing the variable in my get method as var.Tostring().

Thanks,

Venu

zoomer at 2007-9-4 > top of Msdn Tech,.NET Development,Common Language Runtime...

.NET Development

Site Classified