Accessing VC++ interface methods from C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shrihari Devji

    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


  • grps.gobinath@gmail.com

    #2
    Re: Accessing VC++ interface methods from C#

    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

    Comment

    • Shrihari Devji

      #3
      Re: Accessing VC++ interface methods from C#

      <grps.gobinath@ gmail.comwrote in message
      news:a4074084-00b6-49d5-8e28-01fe09db5ee2@u6 9g2000hse.googl egroups.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


      Comment

      • grps.gobinath@gmail.com

        #4
        Re: Accessing VC++ interface methods from C#

        On Mar 10, 1:53 pm, "Shrihari Devji" <srihari.de...@ in.bosch.com>
        wrote:
        <grps.gobin...@ gmail.comwrote in message
        >
        news:a4074084-00b6-49d5-8e28-01fe09db5ee2@u6 9g2000hse.googl egroups.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

        Comment

        Working...