How to use the AppDomainSetup.SetConfigurationBytes

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.
 
G

Guest

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.
 

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

Top