Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

creating a RPC (errors) / RPC tutorial needed

Posted on 2003-11-29
6
Medium Priority
?
1,234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 19

Accepted Solution

by:
Dexstar earned 500 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
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!

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

715 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