471,107 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Accessing VC++ interface methods from C#

Hello

I have a windows service developed in VC++. It exposes some
interface methods. I need to access them from C# client.
I cant add the reference since it might be running on some other
system. So I used activators to access the methods with the help of
InvokeMember function. But now the problem is I am not able to get the S_OK
or S_FALSE result values from Interface method. How to get this value. Or is
there any other way to solve the problem I have.

Regards
Shrihari Devji
RBEI Bangalore
Mar 6 '08 #1
3 2017
On Mar 6, 11:36 am, "Shrihari Devji" <srihari.de...@in.bosch.com>
wrote:
Hello

I have a windows service developed in VC++. It exposes some
interface methods. I need to access them from C# client.
I cant add the reference since it might be running on some other
system. So I used activators to access the methods with the help of
InvokeMember function. But now the problem is I am not able to get the S_OK
or S_FALSE result values from Interface method. How to get this value. Or is
there any other way to solve the problem I have.

Regards
Shrihari Devji
RBEI Bangalore
Hi there,
Generally, the return values S_OK, E_FAIL and other S_FALSE
will be consumed by the .Net's Runtime Callable Wrapper(RCW). If the VC
++ service is returning E_FAIL, the RCW will convert that as an
Exception and throws it to the C# client. so it is better to provide
try...catch blocks to know the return types.

goB
Mar 7 '08 #2
<gr***********@gmail.comwrote in message
news:a4**********************************@u69g2000 hse.googlegroups.com...
On Mar 6, 11:36 am, "Shrihari Devji" <srihari.de...@in.bosch.com>
wrote:
>Hello

I have a windows service developed in VC++. It exposes some
interface methods. I need to access them from C# client.
I cant add the reference since it might be running on some other
system. So I used activators to access the methods with the help of
InvokeMember function. But now the problem is I am not able to get the
S_OK
or S_FALSE result values from Interface method. How to get this value. Or
is
there any other way to solve the problem I have.

Regards
Shrihari Devji
RBEI Bangalore

Hi there,
Generally, the return values S_OK, E_FAIL and other S_FALSE
will be consumed by the .Net's Runtime Callable Wrapper(RCW). If the VC
++ service is returning E_FAIL, the RCW will convert that as an
Exception and throws it to the C# client. so it is better to provide
try...catch blocks to know the return types.

goB
Hi

But we are not getting an excetption when it returns S_FALSE. So is
there any way to get it??

Regards
Shrihari Devji
Mar 10 '08 #3
On Mar 10, 1:53*pm, "Shrihari Devji" <srihari.de...@in.bosch.com>
wrote:
<grps.gobin...@gmail.comwrote in message

news:a4**********************************@u69g2000 hse.googlegroups.com...
On Mar 6, 11:36 am, "Shrihari Devji" <srihari.de...@in.bosch.com>
wrote:
Hello
* * * * I have a windows service developed in VC++. It exposes some
interface methods. I need to access them from C# client.
* * * * I cant add the reference since it might be running on some other
system. So I used activators to access the methods with the help of
InvokeMember function. But now the problem is I am not able to get the
S_OK
or S_FALSE result values from Interface method. How to get this value. Or
is
there any other way to solve the problem I have.
Regards
Shrihari Devji
RBEI Bangalore
Hi there,
* * * * *Generally, the return values S_OK, E_FAIL and other S_FALSE
will be consumed by the .Net's Runtime Callable Wrapper(RCW). If the VC
++ service is returning E_FAIL, the RCW will convert that as an
Exception and throws it to the C# client. so it is better to provide
try...catch blocks to know the return types.
goB

Hi

* * But we are not getting an excetption when it returns *S_FALSE. So is
there any way to get it??

Regards
Shrihari Devji
Hi,
Sorry for this late reply. S_FALSE is not exactly a failure.
Exceptions will be raised only when the severity bits are set in the
HRESULT. If you want to get exceptions, you may have to use anyone of
the following

E_UNEXPECTED - 8000FFFF Catastrophic failure
E_NOTIMPL - 80004001 Not implemented
E_OUTOFMEMORY 8007000E Out of memory
E_INVALIDARG 80070057 One or more arguments are not valid
E_NOINTERFACE 80004002 Interface not supported
E_POINTER 80004003 Pointer not valid
E_HANDLE 80070006 Handle not valid
E_ABORT 80004004 Operation aborted
E_FAIL 80004005 Unspecified error
E_ACCESSDENIED 80070005 General access denied

regards,
goB
Apr 9 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Rookie | last post: by
2 posts views Thread by vemulakiran | last post: by
1 post views Thread by Steve | last post: by
6 posts views Thread by Earl Teigrob | last post: by
1 post views Thread by Rob C | last post: by
53 posts views Thread by Edward Diener | last post: by

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.