By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 1,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

Call to C++ COM DLL from VB.NET, fails with 'System.Runtime.Intero

P: n/a
I have a COM DLL written in C++ which worked fine when called from VB6. But
we have now moved to Visual Studio 2005 - .NET Framework v2 and Windows XP
Pro. In total there are 4 methods in this DLL which I can call, 3 of which
have no return paramters as arguments (ByRef), these work fine, its only the
method that uses 2 passed in paramters (Long - ByRef) to return the the
required data that causes an exception.

So from my VB.NET program:

Dim prnObj as New Prn.PrProxy ' This is instantiation of COM object
Dim retVal1 as integer
Dim retVal2 as integer

Dim retFunction as integer

retFunction = prnObj.GetStatus(retVal1, retVal2)

This fails on the line above with
'System.Runtime.InteropServices.COMException' occurred in microsoft

The original function definition was that the two passed in ByRef paramters
(LONG values) would return the required values. This works fine in VB6.

I am still a newbie in VB.NET, but have been looking around and have come to
two main sources of solution, one of which I have tried which is the article
in MSDN numbered :;en-us;815633
(BUG: "InteropServices.COMException" error message occurs when you pass
ByRef Parameters by using late binding)

But converting the value using
System.Runtime.InteropServices.DispatchWrapper(Not hing) simply causes a
conversion to integer error instead.

I am assuming then that as this is a 'Unmanaged object and variables', and
that I need to convert a managed integer into an unmnaged integer and then
pass it to the function?

Oct 30 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.