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

dotnet remoting : Refrencing dll which is not copied locally


Sunny
10/31/2003 9:09:29 AM
Hi Ken,
this is not a remoting problem, but ...
As far as I understand, CopyLocal property only instructs the compiler,
that when it builds the project, it shoud make a copy of the referenced
dll in the directory, where it places youe executable. If you turn it to
false, it will not copy the dll, and your app will can not find it.
Possible solutions:
1. manualy copy the dll in the directory of your exe
2. register the dll in the GAC
3. I'd recomend you to leave CopyLocal to true. Thus if you make a
changes in the dll and recompile it (it'll be compiled with a new vesion
nr), when you recompile your app, it'll have the right dll.

Hope that helps
Sunny

In article <#BLA2H6nDHA.2500@TK2MSFTNGP10.phx.gbl>,
_k.a.cooper@shu.ac.uk_ says...
[quoted text, click to view]
Ken Cooper
10/31/2003 11:27:23 AM
Hi All,

I am trying to create a gateway to a database as a dll which will be
installed on a remote server (on our intranet) but have run into a whole lot
of problems, but my immediate problem is very simple.

How can I reference a dll which is not copied locally?

I create a solution consisting of 2 projects. The first project is a class
library which consists of a single class with a single method which returns
the string "Hello World".

Public Class foo
Public Function bar() As String

Return "Hello World"

End Function

End Class

The second project is a windows forms application which references the first
project and has a single form with 2 buttons, one to exit and one to call
the method in the class of the first project and pop up a message box.
Public Class Form1

Inherits System.Windows.Forms.Form

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

End

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim foo As New RemoteLibrary.foo

MsgBox(foo.bar)

End Sub

End Class

Hunky Dory cool, I click on the button and I see "Hello World". Marvellous!

So, then I remove the reference to the first project and add a reference to
the compiled dll and run the project. "Hello World" - no surprises there.

However, my aim is to reference a remote dll and I want to simulate this
situation. So I look at the properties of the reference to the dll and
change "Copy Local" from true to false. I run and click on Button1 and I get
an error - System.IO.FileNotFoundException - File or assembly name
RemoteLibrary, or one of its dependencies, was not found.

If I run the compiled Windows Forms exe, I get the option to view more
detailed error information. (See end of post).

From the searches I have done so far, I think the key to solving this
relates to publisher policy. Am I right and do you have any good info on
this?

Also when creating the reference, I browse to the DLL on my local machine,
so why in the error details is there an attempt to "download" an EXE?

Any help greatly appreciated.

Cheers,

Ken


The error details:


************** Exception Text **************
System.IO.FileNotFoundException: File or assembly name RemoteLibrary, or one
of its dependencies, was not found.
File name: "RemoteLibrary"
at WinForm.Form1.Button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

=== Pre-bind state information ===
LOG: DisplayName = RemoteLibrary, Version=1.0.1399.18879, Culture=neutral,
PublicKeyToken=null
(Fully-specified)
LOG: Appbase = C:\SHU\WinForm\bin\
LOG: Initial PrivatePath = NULL
Calling assembly : WinForm, Version=1.0.1399.18833, Culture=neutral,
PublicKeyToken=null.
===

LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Post-policy reference: RemoteLibrary, Version=1.0.1399.18879,
Culture=neutral, PublicKeyToken=null
LOG: Attempting download of new URL
file:///C:/SHU/WinForm/bin/RemoteLibrary.DLL.
LOG: Attempting download of new URL
file:///C:/SHU/WinForm/bin/RemoteLibrary/RemoteLibrary.DLL.
LOG: Attempting download of new URL
file:///C:/SHU/WinForm/bin/RemoteLibrary.EXE.
LOG: Attempting download of new URL
file:///C:/SHU/WinForm/bin/RemoteLibrary/RemoteLibrary.EXE.










Ken Cooper
11/3/2003 3:16:35 PM
Thanks for clearing this point up for me. I've read a lot since making this
post and think I'm back on track with my original remoting problem.

Cheers,

Ken

AddThis Social Bookmark Button