Solved

creating a RPC (errors) / RPC tutorial needed

Posted on 2003-11-29
6
1,218 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to convert MFC APP to Win32 APP. 19 69
computer science syllabus 3 70
I could not build boost code, 10 79
C++ mouse_event mouse look 7 70
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

867 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

20 Experts available now in Live!

Get 1:1 Help Now