Hey,
This is a pretty specific question, but I need to load a Silverlight application library into my ASP.NET MVC Web Application to reflect over the types and build a list for the user to select from. The purpose of the application is to let users upload their custom-built libraries and test it in a "sandboxed" environment.
Anyway, after some struggling, I've achieved file uploads in ASP.NET MVC. Now, when I attempt to load the uploaded assembly for reflection, I get the following error:
{"Cannot resolve dependency to assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.":"System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"}
I've added the specified assembly as a reference in the project to no avail.
The code to reflect the assembly looks like this:
Assembly a = Assembly.ReflectionOnlyLoad(_toolBytecode);
foreach (Type t in a.GetTypes())
{
if (typeof(BoardTool).IsAssignableFrom(t))
{
if (t.IsSubclassOf(typeof(NetworkTool)))
{
// Loop through each attribute of the class
foreach (object attr in t.GetCustomAttributes(false))
// Check if the attribute is the one we want
if (attr is NetworkToolIDAttribute)
{
ReflectedTool rt = new ReflectedTool();
rt.ToolID = ((NetworkToolIDAttribute)attr).ToolID;
rt.ToolName = t.Name;
_tools.Add(rt);
}
}
else
{
ReflectedTool rt = new ReflectedTool();
rt.ToolID = Guid.Empty;
rt.ToolName = t.Name;
_tools.Add(rt);
}
}
}
Any help would be apprecited, or if you know of another way to do this, that would be great too. If all else fails, I'll probably end up writing the sandbox launcher/container as a quick Silverlight application.
Thanks in advance.