Solved

creating a RPC (errors) / RPC tutorial needed

Posted on 2003-11-29
6
1,222 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

770 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