473,378 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 1553

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ayesha Ahsan | last post by:
Hi, I use Runtime.getRuntime().exec(command) to make my system call. For Windows based Dos, i add "cmd /c" before I type in my system call. So for example make the system call "dir": String...
0
by: trayguy | last post by:
Accepting the fact that .NET 1.x is lacking support for named events, and windows security manipulation, we end up using interop and the platform SDK, and functions like CreateMutex and OpenMutex....
3
by: Chua Wen Ching | last post by:
Hi there, I had applied this security permissions in my class library based on fxcop standards. Before namespace: using System.Runtime.InteropServices; using System.Security.Permissions;
5
by: SStory | last post by:
Hi all, I really needed to get the icons associated with each file that I want to show in a listview. I used the follow modified code sniplets found on the internet. I have left in...
0
by: dpp | last post by:
Hi I am calling a method of a .NET component from both win forms and web service applications. Strangly, it is working fine from win forms application, but when i call the same method (same...
4
by: ffhansix | last post by:
Hi, I am trying to reference a COM component (.dll) from Visual Studio 2005 in my windows application in C# by adding a reference to a third party.dll file (tried .type library also), and i get...
1
by: chriskent | last post by:
Hi, I have an unusual situation whereby we create a Window during initialisation. We have used this code for many years and have found one unusual case with a customer when the RegiterClass fails...
2
by: rdilipk | last post by:
I am posting at the end of this post some code that P/Invoke's SetSystemTime to set the local system time. This call fails -- i.e the time is not set and the API returns false. However calling...
2
by: Gillard | last post by:
hello I get a dll with standard call in C ++ but I really do not know how to use it in VB anyone can help??? there is the declarations in cpp to use the functions #ifndef SFPDF_H #define...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.