469,356 Members | 2,220 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

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

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
mscorlib.dll.

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 :
http://support.microsoft.com/default...b;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
0 1421

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Ayesha Ahsan | last post: by
reply views Thread by trayguy | last post: by
reply views Thread by dpp | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.