Running code in a different appdomain
-
Is there any way i can run a code snippet inside a different appdomain? (So i can load the same assembly twice for some reason)
public class MyFooBarAssembly
{
public myFooBarAssembly(string loadFrom)
{
assembly = AssemblyName.GetAssemblyName(loadFrom);} AssemblyName assembly; // This is the method i want to run in a different appdomain) public AssemblyName\[\] GetReferencedAssemblies() { return Assembly.ReflectionOnlyLoadFrom(assembly.CodeBase).GetReferencedAssemblies(); }
}
betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);Morgonen är tröttmans mecka
-
Is there any way i can run a code snippet inside a different appdomain? (So i can load the same assembly twice for some reason)
public class MyFooBarAssembly
{
public myFooBarAssembly(string loadFrom)
{
assembly = AssemblyName.GetAssemblyName(loadFrom);} AssemblyName assembly; // This is the method i want to run in a different appdomain) public AssemblyName\[\] GetReferencedAssemblies() { return Assembly.ReflectionOnlyLoadFrom(assembly.CodeBase).GetReferencedAssemblies(); }
}
betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);Morgonen är tröttmans mecka
First create the new domain:
AppDomain myNewAppDomain = AppDomain.CreateDomain("MyNewAppDomain");
Then create the class you want to run code on in the new app domain.Object myObjectInADifferentDomain = myNewAppDomain.CreateInstanceAndUnwrap(myAssemblyName, myTypeName);
Then just call the methods on it as you would normally with reflection.Simon
-
First create the new domain:
AppDomain myNewAppDomain = AppDomain.CreateDomain("MyNewAppDomain");
Then create the class you want to run code on in the new app domain.Object myObjectInADifferentDomain = myNewAppDomain.CreateInstanceAndUnwrap(myAssemblyName, myTypeName);
Then just call the methods on it as you would normally with reflection.Simon
Oh, sorry, I didn't read your question properly. You can use
newAppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate);
and just pass in a CrossAppDomainDelegate for the method you want to run. That will allow you to execute your method in a different domain. (You might have to change your method slightly to match the CrossAppDomainDelegate)Simon
-
Oh, sorry, I didn't read your question properly. You can use
newAppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate);
and just pass in a CrossAppDomainDelegate for the method you want to run. That will allow you to execute your method in a different domain. (You might have to change your method slightly to match the CrossAppDomainDelegate)Simon
Thanks! exactly what i needed ;)
betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);Morgonen är tröttmans mecka
-
Thanks! exactly what i needed ;)
betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);Morgonen är tröttmans mecka
My pleasure :) (If only everyone was polite like you)
Simon