I have a Application where I need to create AppDomain and Load Assembly into it and execute the methods in the Assembly.
Here is my Code
public class CreateAppDomain
{
public void CreateAppDom()
{
AppDomain domain = AppDomain.CreateDomain("myDomain");
domain.ExecuteAssembly(@"C:\Visual Studio 2005\Projects\A1\A1\bin\Debug\A1.dll");
domain.CreateInstanceFrom(@"C:\Visual Studio 2005\Projects\A1\A1\bin\Debug\A1.dll","A1.Navigate");
}
}
I above code is written in a classfile called CreateAppDomain.cs
In my Default.aspx page I created the instance of the above class and called the create method.Here is the code
protected void Button1_Click(object sender, EventArgs e)
{
CreateAppDomain obj = new CreateAppDomain();
obj.CreateAppDom();
Response.Write("Application Domain Successfully created");
}
when I run the default.aspx page I get a error saying
Entry point not found in assembly ‘A1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’.
Can Anyone explain me the meaning of above error and solution to it.
Thanks,
AppDomain.ExecuteAssembly()method loads an assembly into specified domain and then executes it’s standard entry point i.e.static void Main(string[] args)method.Look here for details.
What do you want is probably one of the overloads of
CreateInstanceAndUnwrap()methodEDIT:
I created ConsoleApplication9, added besides ClassLibrary1. In the ClassLibrary1 I have
Class1:In the ConsoleApplication9 these’s:
When run, I have: