CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 3 FirstFirst 123
Results 31 to 36 of 36
  1. #31
    Join Date
    Mar 2012
    Posts
    99

    Re: getting RpcExceptionCode 5 with RPC code

    just before the line What is this RPC anyway? there is a link to download the code near the top of the page.
    this is an old example and nobody has written to it since 2008 and there is no way to contact the author
    this was the easiest example of RPC i could find. there isn't many tutorials

  2. #32
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: getting RpcExceptionCode 5 with RPC code

    Well, I tested it and got the same error on my XP SP3. But it was not the NdrSendReceive that caused this error but NdrFreeBuffer

    Perhaps, you will try some MSDN samples instead? like this one:
    http://msdn.microsoft.com/en-us/libr...(v=VS.60).aspx
    Victor Nijegorodov

  3. #33
    Join Date
    Mar 2012
    Posts
    99

    Re: getting RpcExceptionCode 5 with RPC code

    i saw that example before but i don't understand it. it talks about the files being used but there is no link to these files...

  4. #34
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: getting RpcExceptionCode 5 with RPC code

    Victor Nijegorodov

  5. #35
    Join Date
    Mar 2012
    Posts
    99

    Re: getting RpcExceptionCode 5 with RPC code

    ok i followed that tutorial and i got this error in the server program:
    error C2664: 'RpcServerUseProtseqEpW' : cannot convert parameter 1 from 'unsigned char *' to 'RPC_WSTR'

    so i changed this code:
    Code:
     status = RpcServerUseProtseqEp(
          reinterpret_cast<unsigned char*>("ncacn_ip_tcp"),
          RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
          reinterpret_cast<unsigned char*>("4747"),
          NULL);
    to this:
    Code:
    status = RpcServerUseProtseqEp(
          L"ncacn_ip_tcp",
          RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
          L"4747",
          NULL);
    but now i am getting this error:
    error C2664: 'RpcServerUseProtseqEpW' : cannot convert parameter 1 from 'const wchar_t [13]' to 'RPC_WSTR'

  6. #36
    Join Date
    Apr 1999
    Posts
    27,449

    Re: getting RpcExceptionCode 5 with RPC code

    Quote Originally Posted by beginner91 View Post
    ok i followed that tutorial and i got this error in the server program:
    error C2664: 'RpcServerUseProtseqEpW' : cannot convert parameter 1 from 'unsigned char *' to 'RPC_WSTR'
    That is because you are building your program as Unicode, not MBCS. You should be using the _T() macro or _TEXT() macro when creating string literals.
    so i changed this code:
    [code] status = RpcServerUseProtseqEp(
    reinterpret_cast<unsigned char*>("ncacn_ip_tcp"),
    No. Do not do this. The function is expecting 16-bit char strings, and casting one string type to another doesn't do any conversion.
    Code:
    RpcServerUseProtseqEp(_T("ncacn_ip_tcp"), RPC_C_PROTSEQ_MAX_REQS_DEFAULT,  _T("4747"),  NULL);
    The above code now will compile, regardless if your code is compiled as Unicode or ANSI/MBCS.

    Regards,

    Paul McKenzie

Page 3 of 3 FirstFirst 123

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured