Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1249
  • Last Modified:

creating a RPC (errors) / RPC tutorial needed

Hi!

I'm trying to create a remote procedure call in C++. I followed the steps described in the MSDN-RPC-tutorial at

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rpc/rpc/the_standalone_application.asp

I'm using Visual Studio .NET. After generating the rpc-files by midl.exe and adding them to the project, i get many linker-errors:
error LNK2001: unresolved external symbol _hello_IfHandle

extern handle_t hello_IfHandle; (variable-name without underscore) is a variable in the file hello.h, but the linker can't resolve _hello_IfHandle

error 2019: unresolved external symbol __imp_RpcBindingFree@4 refered in _main
(additional underscore)


Please help me, and tell me, what i've done wrong.
It would also be great if anyone could give me a sample of how to create a RPC.
0
jo_ugb
Asked:
jo_ugb
  • 3
  • 3
1 Solution
 
DexstarCommented:
@jo_ugb:

> extern handle_t hello_IfHandle; (variable-name without underscore) is a variable
> in the file hello.h, but the linker can't resolve _hello_IfHandle

In addition the entry in the .h file, add this line to one of your .cpp files:
     handle_t hello_IfHandle;

> error 2019: unresolved external symbol __imp_RpcBindingFree@4 refered in _main

Add "Rpcrt4.lib" to your linker settings.

Hope That Helps,
Dex*
0
 
jo_ugbAuthor Commented:
Thanks a lot, Dex! Adding Rpcrt4.lib resolved some of the linker errors, but i had to add RpcNdr.lib too to resolve all errors.

I'll give you half of the points for that.

The rest of the points is for giving me a simple and working tutorial for creating a remote procedure call in C. - I wouldn't mind getting a link to a tutorial.
0
 
DexstarCommented:
I take it you've already seen this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/html/vcsmphello.asp

What problems are you having with that sample?

Dex*
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jo_ugbAuthor Commented:
I've now found a very good and simple tutorial. It's similar to the MSDN-tutorial but easier to understand in my opinion.
You'll find the tutorial at http://www.codeproject.com/internet/rpcintro1.asp

I'm using exactly the same code which is provided by that tutorial.
// File Example1Server.cpp ... for my rpc-server and
// File Example1Client.cpp ... for my rpc-client.

The server seems to be listening correctly but when the client calls the remote function an rpc-exception occures. I've extended the client-code of the tutorial to get the RpcExceptionCode

   RpcTryExcept
   {
      puts( "now calling the server...\n\n" );
      Output((unsigned char*)"Hello RPC World!");
   }
   RpcExcept(1)
   {
      unsigned long ulCode = RpcExceptionCode();
      printf( "Runtime reported exception 0x%lx = %ld\n", ulCode, ulCode );
   }
   RpcEndExcept

and I get the following error-code:
Runtime reported exception 0x6a6 = 1702

That's my little problem.


I've got an additional question to the sample-program:
Why isn't the UUID needed to call the server??
The first attribute of RpcStringBindingCompose(), which represents the UUID is NULL (as well in the CodeProject-tutorial as well as in the MSDN-tutorial).


Thanks a lot for helping me!!
0
 
DexstarCommented:
Yeah, that tutorial is pretty good.  Have you seen the 2nd part to it?
http://www.codeproject.com/internet/rpcintro2.asp

As for why the UUID is not needed... On this page (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rpc/rpc/the_client_application.asp), I found this quote:

"In the call to RpcStringBindingCompose, the parameters do not specify the UUID because this tutorial assumes there is just one implementation of the interface 'hello.'"

But I think it is also because when you call RpcServerRegisterIf, you also specify a NULL UUID value.

Dex*

0
 
jo_ugbAuthor Commented:
Ok, the runtime exception was my fault. I added both the MIDL-generated file for the server (Example1_s.c) AND the file for the client (Example1_c.c) to my project. Apparently the wrong implementation for the remote procedure (Output) must have been executed.

Thanks anyways for helping me.

Now that i've successfully solved my problem you'll get the points.
Have a nice evening! - or what ever your time of day is :)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now