[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

C# and COM interoperability

Posted on 2006-05-02
1
Medium Priority
?
616 Views
Last Modified: 2013-11-25
Hi,

I'm doing this service for my job and I need to code a module that forwards call from a C++ program to a DLL. Normaly, the C++ program instanciate the DLL with his GUID and then calls some functions. I changed the GUID of the DLL and took the original GUID and applied it to my service so now when the C++ program needs a instance of the DLL, it calls me. I then instanciate the good DLL and forward the calls. This works fine until I need the return value of the forwarded call to the DLL. The .NET documentation states that when a call to a COM object fails (HRESULT != S_OK or S_FAIL) the CLR converts this failure by returning an Exception to the callee (my service). The problem is that i know the return value is different from S_OK and S_FAIL but i don't catch the exception ! (with try/catch block)

This problem comes from the fact that the interface I used to communicate with the DLL returns a HRESULT result but has no [out,retval] param so when i use midl to create the tlb and tlbimp to then create the DLL, the resulting interface i can use in my C# project has a VOID signature. And I must read the HRESULT return value for other processing.

How can I get the HRESULT value from my C# code ?
0
Comment
Question by:LeibNiZ
1 Comment
 
LVL 14

Accepted Solution

by:
nayernaguib earned 600 total points
ID: 16590301
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Progress
Suggested Courses
Course of the Month20 days, 6 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question