How to use the AppDomainSetup.SetConfigurationBytes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I wrote a unit test for load an App.Config file from a string:
public const string Config =
"<configurationx>" +
" <appSettings>" +
" <add key=\"Pi\" value=\"3.15\" />" +
" </appSettings>" +
"</configurationx>";

AppDomainSetup setup = new AppDomainSetup();
setup.SetConfigurationBytes(ASCIIEncoding.UTF8.GetBytes(Config));

then I create a new appdomain with the AppDomainSetup above.

AppDomain appDomain = AppDomain.CreateDomain(
"New AppDomain",
AppDomain.CurrentDomain.Evidence,
setup);

The problem is that the Config string is ignored.
Someone know how to set the App.Config configuration from a string?
Thanks.
Antonio.
 
Antonio said:
I wrote a unit test for load an App.Config file from a string:
public const string Config =
"<configurationx>" +
" <appSettings>" +
" <add key=\"Pi\" value=\"3.15\" />" +
" </appSettings>" +
"</configurationx>";

AppDomainSetup setup = new AppDomainSetup();
setup.SetConfigurationBytes(ASCIIEncoding.UTF8.GetBytes(Config));

then I create a new appdomain with the AppDomainSetup above.

AppDomain appDomain = AppDomain.CreateDomain(
"New AppDomain",
AppDomain.CurrentDomain.Evidence,
setup);

The problem is that the Config string is ignored.
Someone know how to set the App.Config configuration from a string?
Thanks.
Antonio.
 
Back
Top