views:

195

answers:

1

Help, here is the idea:

External.dll IMyClass NewCreated = (IMyClass)Activator.CreateInstance(Namespace.MyClass).UnWrap();


Asp.Net WebSite App_Code Namespace.MyClass.cs Bin External.dll

Is that even posible?

I have tried, a lot of posible combinations, like:

Assembly.GetCallingAssembly().CreateInstance("Namespace.MyClass") Activator.CreateInstance(AppDomain.CurrentDomain,"Namespace","Namespace.MyClass") Assembly.GetExecutingAssembly().CreateInstance("Namespace.MyClass")

+1  A: 

You can use the BuildManager.CodeAssemblies property to list all the assembly names that have been compiled in the App_Code directory. You may be able to accomplish what you need that way.

The problem with App_Code is that everything gets dynamically compiled into an assembly that is by nature, temporary. This comes along with a temporary assembly name. This makes it impossible to hardcode an assembly name or path.

womp
Thanks a lot, here is the complete code for initializing any class in app_code from a dll.Activator.CreateInstance(((Assembly)BuildManager.CodeAssemblies[0]).GetType("Namespace.Class"), ConstructorParams1,ConstructorParams2);
Fraga