views:

39

answers:

2

Hi Stackoverflowers! :)

We have a .NET application for Windows which is installed locally by Microsoft Installer. Now we have the need to use additional assemblies which are located online at our Web Servers. We'd like to refer to a remote uri like https://www.ourserver.com/OurProductName/ExternalLib.dll and reveal additional functionality, which is described roughly by a known common ("AddIn/Plugin") Interface. These are not 3rd Party Plugins, we just want be able to exchange parts of the application frequently, without the need to have frequent software updates.

Our first idea was to add some kind of "remote refence" in Visual Studio by setting the path to the remote assembly uri. But Visual Studio downloaded the assembly immediately to a temporary directory, adding a reference to it.

Our second attempt then, is simply using a WebRequest (or WebClient) to retrieve a binary stream of the Assembly, loading it "from image" by using Assembly.Load(...). This actually works, but is not very elegant and requires more additional programming for verification etc.

We hoped Clickonce would provide useful techniques but apparently it's suitable for standalone applications only. (Correct me?)

Is there a way (.net native or by framework/api) to reference remotely located assemblies?

Thanks in advance and have a happy easter!

+1  A: 

You can add the reference in Visual Studio, then call Assembly.Load to load it from the URL in your code.

As long as you set Copy Local and Specific Version to false on the reference, it will not be tied to that particular version.

SLaks
Hi, actually, I was NOT able to use Assembly.Load(...) to load an Assembly from the Url as you describe - passing the Url as location parameter is not working, so you'll need to download first, then load the byte array, validate (errors might have occured) etc. all manually, thus, I think that it's not a very "elegant" solution.Setting the Reference options as you described would just help having known classes but this is not the point when using class interfaces, unfortunately it doesn't help referencing the Assembly from web. Thank you for your support!
moonground.de
@Moonground: You need to add a reference in VS, then call `Assembly.Load` from a byte array using `WebClient`. You'll need to do that before calling any methods that use the types in the assmebly. (The JITter will fail if the assembly wasn't loaded)
SLaks
@SLaks: Yes. Hope you understand that it still doesn't make me happy since everything I wrote in my previous comment still applies.
moonground.de
A: 

Upvoting SLaks (no accept since it didnt get me any further) and "closing" the question as it seems that there is no better way (at the moment) then doing it the manual way.

moonground.de