static reference to a web hosted assembly in VS

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
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top