Groups | Blog | Home
all groups > dotnet remoting > october 2003 >

dotnet remoting : Can you help me prove .NET Remoting works?


Andrew
10/29/2003 11:18:52 AM
There are some known issues with what you are trying to do. The first one
is getting the config file. You can find information about that here:
http://blogs.gotdotnet.com/alanshi/commentview.aspx/fafd34ae-e72d-44ca-bb2d-7614ecfa2070

If you want your no-touch deployed client to do remoting, you will run into
a security exception. To get around that, you will need to set some
security permissions on the client. See this example:
http://www.sellsbrothers.com/wahoo/ and
http://www.devx.com/codemag/Article/16686/0/page/5

As for your RemoteLibrary assembly, you need to make sure that that .dll
resides in the same directory as the executable that you are trying to no
touch deploy unless you are explicitly trying to do a Assembly.LoadFrom().
The IEExec execution environment will take care of downloading the .dll's
into the GAC.

Hope that gives you some leads,
Andrew

[quoted text, click to view]
Ken Cooper
10/29/2003 5:10:53 PM
Hi All

Over the last few days I have been trying to build a sample app to call a
remote component.

I am trying to prove that Windows Forms using Zero Touch Deployment and .NET
Remoting is the best way to proceed on a new fairly substantial project.

However, I keep hitting a brick wall when making a call to the remote
component.

I get the following error:

"An unhandled exception of type 'System.IO.FileNotFoundException' occurred
in system.windows.forms.dll

Additional information: File or assembly name RemoteLibrary, or one of its
dependencies, was not found."



I feel like I am so close but some key setting or missing step is preventing
me from accessing the remote object.



Some questions:

Should the remote config file be named remoting.config or remoting.cfg?

Should the first xml line be removed from the config file?

Should the config file be installed in the bin directory or the directory
above?

Does the error imply the communication channel has been opened and the
remote server is denying access to the assembly or that the communication
channel may not be open?

If tcp port 1234 is not actually available to me to use how could I tell?

Are there any other steps I should be making to register the assembly in the
GAC?



Step by Step this is what I have done:



Create a VB.Net Class Library
a.. Create a new VS.NET project of type ClassLibrary called RemoteLibrary
b.. Rename the default class to DateTimeFunctions
c.. Derive this class from MarshalByRefObject and create a new method eg
CurrentTime which returns the present time.
<Serializable()> Public Class DateTimeFunctions

Inherits MarshalByRefObject



Public Function CurrentTime() As String

Return Format(Now, "HH:mm")

End Function



End Class



This is the simple class which will be installed on a remote server and
referenced locally. I have included the serializable attribute but I am not
sure if this is necessary as the object will be referenced remotely, but not
itself passed as a parameter in a method call.



a.. Edit the Assembly Information File (In Solution Explorer, click on the
project and then Show All Files)
Select the AssemblyInfo.vb file
Enter an Assembly Version and other optional information. The key file can
be created using the Strong Name Tool.
<Assembly: AssemblyVersion("1.0.0.0")>

<Assembly: AssemblyCulture("neutral")>

<Assembly: AssemblyKeyFile("K:\Certificates\SCBKC.snk")>



Add an Application Configuration File named remoting.config
Remove the first line <?xml version="1.0" encoding="utf-8" ?>
Add the following information
<configuration>

<system.runtime.remoting>

<application>

<service>

<wellknown

mode="SingleCall"
type="RemoteLibrary.DateTimeFunctions,

RemoteLibrary"
objectUri="DateTimeFunctions"/>

</service>

<channels>

<channel ref="tcp" port="1234"/>

</channels>

</application>

</system.runtime.remoting>

</configuration>

(http://www.15seconds.com/issue/030225.htm)
Rename the file to remoting.cfg (Colour disappears)
This file will need to be installed on the remote server.

a.. Build the solution
b.. From the command line run the sn tool to create a strong name for the
assembly
C:\SHU\RemoteLibrary\bin>
sn -R RemoteLibrary.dll K:\Certificates\SCBKC.snk (Previously created
KeyFile)
c.. Create a directory on the remote server named RemoteLibrary and a
subdirectory named bin
Copy remoting.cfg to RemoteLibrary
Copy RemoteLibrary.dll to bin
Grant Full Control rights to everyone (to ensure permissions is not
causing the error)
d.. On the remote server, drag RemoteLibrary.dll into WINNT\Assembly
This will register the assembly in the Global Assembly Cache (GAC)
e.. Double check that the assembly is registered using .NET Framework
Configuration in Administrative Tools


Create a VB.NET WinForms Application
a.. In VS.Net create a new Windows Forms Application name WinForm
b.. In the project References, add a .NET reference - browse to
RemoteLibrary.dll on the remote server
In the properties of the newly added reference, ensure that Copy Local is
set to False
c.. Add an Application Configuration file to the project and enter the
following information
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<system.runtime.remoting>

<application name="WinForm">

<client>

<wellknown

type="Remoting.DateTimeFunctions,Remoting"
url="tcp://ntchamaeleon:1234/DateTimeFunctions">

</wellknown>

</client>

<channels>

<channel ref="tcp"></channel>

</channels>

</application>

</system.runtime.remoting>

</configuration>



a.. Add 2 buttons to Form1 - Call and End
b.. In the click event handler for "End" type End to end the application
c.. In the click event handler for Call enter
Dim dtf As New RemoteLibrary.DateTimeFunctions
MsgBox(dtf.CurrentTime)


Run the application and click on the Call button



"An unhandled exception of type 'System.IO.FileNotFoundException' occurred
in system.windows.forms.dll

Additional information: File or assembly name RemoteLibrary, or one of its
dependencies, was not found."





Tantalisingly close but not there yet! (this proof of concept excercise is
beginning to feel like my substantail project!!)



Any help greatly appreciated.



Cheers,



Ken



AddThis Social Bookmark Button