appdomain configuration file error

H

hB

Hi.


Error = "The configuration system can only be set once. Configuration
system is already set"


Exception Details: System.InvalidOperationExcepti­on: The
configuration
system can only be set once. Configuration system is already set


....
System.Web.Configuration.HttpC­onfigurationSystemBase.EnsureI­nit()
System.Web.HttpRuntime.InitCon­figuration(HttpContext context)
System.Web.HttpRuntime.FirstRe­questInit(HttpContext context)
....


I am not on IIS. I am hosting ASP dotnet, in a dotnet console
applicaiton.


The console app has its own default app domain.
When i create as
ApplicationHost.CreateApplicat­ionHost(Type.GetType("url.ASPN­etHost"),

"/",Directory.GetCurrentDirect­ory());
it worx fine.


but when i create myself an appdomain //due to some reason regarding
[web]application base directory


....loDomain = AppDomain.CreateDomain(domainI­d, null, setup);...
as mentioned in here (reference)
http://radio.weblogs.com/0105476/stories/2002/07/12/executingAspxPage...



in my code:
msh =
ASPNetHost.CreateApplicationHo­st(Type.GetType("url.ASPNetHos­t"),
"/",Directory.GetCurrentDirect­ory()+"\\web",Directory.GetCur­rentDirectory());



and when i do
msh.ProcessRequest(file_name, query,tw);
Then this error comes when i use my own appdomain creation.


I think this is some one console exe with its domian create another
appdomain with its (need to be separately own) configuraiton file
(which is there or not there does gives problem) (i do AppDomainSetup
setup = new AppDomainSetup(); | setup.ConfigurationFile = "web.config";

BUT IT gives same problem)


I hope you guys understand.
Thanks in advance


Awaiting replies.


regards,
 
J

Juan T. Llibre

Hi, hB.

Maybe it would help to review these links :

Application Domain FAQ :
http://www.gotdotnet.com/team/clr/AppdomainFAQ.aspx

There's also good info here :
http://www.andymcm.com/dotnetfaq.htm

Finally, there's example code at :
http://msdn.microsoft.com/library/d...appdomainsetupclassconfigurationfiletopic.asp






Hi.


Error = "The configuration system can only be set once. Configuration
system is already set"


Exception Details: System.InvalidOperationExcepti­on: The
configuration
system can only be set once. Configuration system is already set


....
System.Web.Configuration.HttpC­onfigurationSystemBase.EnsureI­nit()
System.Web.HttpRuntime.InitCon­figuration(HttpContext context)
System.Web.HttpRuntime.FirstRe­questInit(HttpContext context)
....


I am not on IIS. I am hosting ASP dotnet, in a dotnet console
applicaiton.


The console app has its own default app domain.
When i create as
ApplicationHost.CreateApplicat­ionHost(Type.GetType("url.ASPN­etHost"),

"/",Directory.GetCurrentDirect­ory());
it worx fine.


but when i create myself an appdomain //due to some reason regarding
[web]application base directory


....loDomain = AppDomain.CreateDomain(domainI­d, null, setup);...
as mentioned in here (reference)
http://radio.weblogs.com/0105476/stories/2002/07/12/executingAspxPage...



in my code:
msh =
ASPNetHost.CreateApplicationHo­st(Type.GetType("url.ASPNetHos­t"),
"/",Directory.GetCurrentDirect­ory()+"\\web",Directory.GetCur­rentDirectory());



and when i do
msh.ProcessRequest(file_name, query,tw);
Then this error comes when i use my own appdomain creation.


I think this is some one console exe with its domian create another
appdomain with its (need to be separately own) configuraiton file
(which is there or not there does gives problem) (i do AppDomainSetup
setup = new AppDomainSetup(); | setup.ConfigurationFile = "web.config";

BUT IT gives same problem)


I hope you guys understand.
Thanks in advance


Awaiting replies.


regards,
 
H

hB

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.FullName,
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.SetConfigurationSystem(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.HttpConfigurationSystemBase.EnsureInit()
System.Web.HttpRuntime.InitConfiguration(HttpContext context)
System.Web.HttpRuntime.FirstRequestInit(HttpContext context)

[HttpException (0x80004005): ASP.NET Initialization Error]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context)
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top