Solved

creating a RPC (errors) / RPC tutorial needed

Posted on 2003-11-29
6
1,213 Views
Last Modified: 2012-05-04
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
Comment
Question by:jo_ugb
  • 3
  • 3
6 Comments
 
LVL 19

Accepted Solution

by:
Dexstar earned 250 total points
ID: 9843862
@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
 

Author Comment

by:jo_ugb
ID: 9845590
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
 
LVL 19

Expert Comment

by:Dexstar
ID: 9845606
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:jo_ugb
ID: 9850807
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
 
LVL 19

Expert Comment

by:Dexstar
ID: 9851711
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
 

Author Comment

by:jo_ugb
ID: 9852386
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now