0
votes

I've got a silverlight application that loads a dll file located within the ClientBin folder at run time via a relative Uri. It works great on my local machine, but when deployed on a server here, it seems to constantly fail while trying to load the file:

private void OnAssemblyOpened(object sender, OpenReadCompletedEventArgs e)
{  
    AssemblyPart asmbPart = new AssemblyPart();

    MessageBox.Show(e.ToString());
    Assembly asmb = asmbPart.Load(e.Result) // this line causes the exception
    ...
}

Of course silverlight doesn't give me a useful error - just the usual NotFound nonsense. Is there a step I've missed in deploying this? Permissions or something? The dll file is definitely in the ClientBin folder btw - I've checked that! :)

4

4 Answers

1
votes

Another option would be to compress the dll into a zip file, then download the zip file. That way you need not play with the server config.

How to download and unpack a file from a Zip file is given in this answer.

Code in essence would look like this:-

AssemblyPart asmbPart = new AssemblyPart();

var zipRes = new StreamResourceInfo(args.Result, null)
var assemRes = Application.GetResourceStream(zipRes, new Uri("YourAssembly.dll", UriKind.Relative));

Assembly asmb = asmbPart.Load(assemRes.Stream)
0
votes

Try to use absolute path for deployed application and give your url + path-to-clietbin as path.
You may got error because of invalid path on server machine(if you didn't change it and it's still path of your local machine).

0
votes

Problem was that I'm running IIS6 and dll's cannot be served out without switching execute permissions on the site to None (which obviously stops the Silverlight app from running) so I was legitimately getting a 404 - who'd have thought!!

I created a virtual directory for my scripts at the top level of my site and stuck the dll in there, switched the execute permissions for the virtual to None, updated the uri to ../scripts/ControlLibraries.dll and job's a goodun!

0
votes

Actually, just change the execute permissions on your application to Scripts only, instead of Scripts and Executables, should work fine.