Its not just a simple appdomain configuration problem.
I am doing it this way, may some errors in it.
Code fragment:
--------------------------------------------------------------------------
string aspDir = HttpRuntime.AspInstallDirectory;
string domainId = "ASPHOST_" +
DateTime.Now.ToString().GetHashCode().ToString("x" );
string appName = (virtualDir +
physicalDir).GetHashCode().ToString("x");
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationName = appName;
setup.ConfigurationFile = "app.config";
if (ApplicationBase != null && ApplicationBase != "")
setup.ApplicationBase = ApplicationBase;
AppDomain loDomain = AppDomain.CreateDomain(domainId, null, setup);
loDomain.SetData(".appDomain", "*");
loDomain.SetData(".appPath", physicalDir);
loDomain.SetData(".appVPath", virtualDir);
loDomain.SetData(".domainId", domainId);
loDomain.SetData(".hostingVirtualPath", virtualDir);
loDomain.SetData(".hostingInstallDir", aspDir);
System.Runtime.Remoting.ObjectHandle oh =
loDomain.CreateInstance(hostType.Module.Assembly.F ullName,
hostType.FullName);
ASPNetHost loHost = (ASPNetHost) oh.Unwrap();
loHost.cVirtualPath = virtualDir;
loHost.cPhysicalDirectory = physicalDir;
loHost.oAppDomain = loDomain;
return loHost;
--------------------------------------------------------------------------
when quering from my internet client (browser) as
http://localhost/
i get this error
Server Error in '/' Application.
--------------------------------------------------------------------------------
The configuration system can only be set once. Configuration system is
already set.
Exception Details: System.InvalidOperationException: The configuration
system can only be set once. Configuration system is already set.
Stack Trace:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
[InvalidOperationException: The configuration system can only be set
once. Configuration system is already set]
System.Configuration.ConfigurationSettings.SetConf igurationSystem(IConfigurationSystem
configSystem)
[TargetInvocationException: Exception has been thrown by the target of
an invocation.]
System.Reflection.RuntimeMethodInfo.InternalInvoke (Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean
verifyAccess) +0
System.Reflection.RuntimeMethodInfo.InternalInvoke (Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean verifyAccess)
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
System.Web.Configuration.HttpConfigurationSystemBa se.EnsureInit()
System.Web.HttpRuntime.InitConfiguration(HttpConte xt context)
System.Web.HttpRuntime.FirstRequestInit(HttpContex t context)
[HttpException (0x80004005): ASP.NET Initialization Error]
System.Web.HttpRuntime.FirstRequestInit(HttpContex t context)
System.Web.HttpRuntime.ProcessRequestInternal(Http WorkerRequest wr)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Main Application Thread (MT in a console based app with TcpListener)
MT -> creates appdomain. (for asp.net)
The class in appdomain.doSoProcessRequest() //proxy call. and then this
error comes upon first call to it by proxy call cross appdomain.
Thanks.