Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ Visual-Studio TCP/IP Remote , +
i followed this tutorial about creating a server and client program using RPC and downloaded the source code from it
but when i ran the code "Runtime exception occured: 5" displayed which i know means access denied.
i debugged the program and found that the problem was with the line
NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
here is the full show function:
  void Show( 
    /* [string][in] */ const unsigned char __RPC_FAR *szMsg)
    RPC_BINDING_HANDLE _Handle  =   0;
    RPC_MESSAGE _RpcMessage;
                          ( PRPC_MESSAGE  )&_RpcMessage,
                          ( PMIDL_STUB_MESSAGE  )&_StubMsg,
                          ( PMIDL_STUB_DESC  )&DoRPC_StubDesc,

        _Handle = hDoRPCBinding;

        _StubMsg.BufferLength = 12U;
        NdrConformantStringBufferSize( (PMIDL_STUB_MESSAGE) &_StubMsg,
                                       (unsigned char __RPC_FAR *)szMsg,
                                       (PFORMAT_STRING) &__MIDL_TypeFormatString.Format[4] );
        NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle );
        NdrConformantStringMarshall( (PMIDL_STUB_MESSAGE)& _StubMsg,
                                     (unsigned char __RPC_FAR *)szMsg,
                                     (PFORMAT_STRING) &__MIDL_TypeFormatString.Format[4] );
        NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
        NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
and here's some code from main:
        // Calls the RPC function. The hDoRPCBinding binding handle
        // is used implicitly.
        // Connection is done here.
        const unsigned char szMsg[] = "Client: I Can RPC Now!";
        printf("Runtime exception occured: %d\n",RpcExceptionCode());
so when debugging it jumped to the RpcExcept line when it reached NdrSendReceive
please help i have no idea how to fix this problem
Posted 10-Apr-13 23:20pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Peter Leow 390
1 Sergey Alexandrovich Kryukov 330
2 Zoltán Zörgő 258
3 CHill60 195
4 CPallini 155
0 Sergey Alexandrovich Kryukov 8,943
1 OriginalGriff 6,631
2 Peter Leow 4,102
3 Zoltán Zörgő 3,714
4 Kornfeld Eliyahu Peter 2,525

Advertise | Privacy | Mobile
Web02 | 2.8.150123.1 | Last Updated 11 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100