Wednesday 16 September 2009

Silverlight: Passing constructor parameters when creating objects from dynamically loaded assemblies.

In my current project I faced the problem that when using the Assembly.CreateInstance in Silverlight , constructor parameters cannot be directly passed.

The workaround I found is very simple and uses the Activator.Create instance in the following manner:

System.Object new_object = Activator.CreateInstance(asm.GetType("SomeNamespace.SomeType"), new Object[]{"param1","param2"});


I hope this helps somebody.



Tzanimir