views:

17

answers:

1

I'm trying to use Assembly.Load(Byte[]) in a Silverlight 4 app and i'm getting MethodAccessException. As far as I understand that's because my app code is Transparent and this method is Critical. Is there any SafeCritical API to load assembly from byte array?

Then I want to create an instance of type (SL app doesn't have a compile time reference to it) that is inside dynamically loaded assembly and make that instance a current item for a DataFrom control.

+1  A: 

Try this:-

  AssemblyPart assemblyPart = new AssemblyPart();
  assemblyPart.Load(new MemoryStream(yourByteArray));
AnthonyWJones
How to create a type instance from this assemblyPart thing?
fspirit
@fspirit: use `Type.GetType(string)` to get a reference to the `Type` then `Activator.CreateInstance(Type)` to create an instance of that `Type`.
AnthonyWJones