How to use reflection to create a class in app_code?

I have a Customer client in the app_code folder on asp.net, how can I create an instance using reflection, for example using Activator.CreateInstance (assemblyName, typeName)? Since app_code is dynamically compiled, I don’t know the build at design time?

Thanks fred

The question is how to get the full type name at design time, I want to put it in web.config. I have type ConfigSection, it is in the app_code folder, I need to declare it in configSection. Thanks

+4
source share
4 answers

You should be able to use "App_Code" or "__Code" as the assembly name in the web.config file

+3
source

I think you can use Assembly.GetExecutingAssembly () to get a link to the current assembly.

+2
source

I solved a similar problem this way:

Type[] appCodeTypes = System.Reflection.Assembly.Load("App_Code").GetTypes(); 
+1
source

You can also use GetType (). An assembly, if you know that it will be the same assembly as your executable code.

0
source

All Articles