static reference to a web hosted assembly in VS

  • Thread starter Thread starter Wiktor Zychla
  • Start date Start date
W

Wiktor Zychla

Hello,

I hope this is a simple issue.

Suppose I place an assembly under the IIS virtual directory. The
assembly is easily accessible via:

Assembly a = Assembly.LoadFrom(
http://hostname/virtualdirectory/myassembly.dll );

However, when I try to bring a Add Reference dialog in VS [to add a static
reference] and write "http://hostname/virtualdirectory" in the file name
field then I can see the assembly but after I select it (or write the full
assembly address http://hostname/virtualdirectory/myassembly.dll in a "file
name" field) I only get a messagebox saying:

"The file or files at "http://hostname/virtualdirectory/myassembly.dll"
could not be retrieved. Ensure that the directory is accessible."

I do not get the error message since Assembly.LoadFrom works on that
assembly prooving it IS accessible. Is there any chance that I can add a
reference to such assembly in VS? Is it possible at all? I could not find
any web references to this issue.

Thanks in advance for any help.

Wiktor Zychla
 
Wiktor,

The reference dialog is for local references only.

What you will have to do is download the dll, and set a reference
locally so you can get the strong typing and allow your class to compile.
However, you can not load the assembly using LoadFrom anymore. Rather, you
will have to create a binding in the config file for your app so that it
will look at that URL for the assembly first.

Hope this helps.
 
Back
Top