views:

209

answers:

1

I am using Assembly.LoadFrom within a web service to load assemblies from a web site. but the problem is it is in the virutal directory and the server.mappath parses the url like \share\mydll.dll and loadform method failed. Is there anyway to reference dll from the remote location?

I've tried passing the url (http://localhost/downloadable/mydll.dll) and again it got "Could not load file or assembly 'http://localhost/downloadable/mydll.dll' or one of its dependencies. HTTP download of assemblies has been disabled for this appdomain. (Exception from HRESULT: 0x80131048)"

A: 

You can use the WebClient class to download an assembly over the internet:

using(var wc = new WebClient()) {
    Assembly.Load(wc.DownloadData(url));
SLaks
as long as you verify that your web server allows downloading of .dll files, by default IIS blocks this (which is why there is the .deploy option in ClickOnce).
Tom Anderson
I did manage to get the dll with webclient.downloaddata but the problem again is when i cast that object, it said "Unable to cast object of type 'SiteExtractor' to type 'IExtractor'." but SiteExtractor implements the interface Iextractor and it was working perfectly before.
Myat Htut
You probably have a conflict between different versions of the same assembly.
SLaks
that's what i thought so i replaced the dll with the version from the url.but still doesn't work.. it's been a week and i m really frustrated at this point.
Myat Htut