App.config on windows phone 7?

Darling, I'm building an application on a Windows 7 phone. My application needs some configurations, such as web service URLs, database name ... These configurations can be changed as needed during deployment (but I don't want to rebuild the expression ) In a WPF application, I often save these configurations in the App.config file, but in a WP7 application I cannot.

If you encounter this problem before you have any solution, tell me.

Many thanks.

Bin Nguyen.

+6
windows-phone-7 configuration app-config
source share
2 answers

I do not understand your question, but:

If you need settings that you can change at runtime (after deployment), save this information in IsolatedStorage . You can use IsolStorageFile or IsolatedStorageSettings, whichever suits your data best.
I made this lot by setting the default settings in the code that I write to IsolStorageFile when I first run the application. They can then be read and updated as needed.

If you just need to change the values ​​at build time, include the options in the / resources (.resx) file.

+7
source share

WP7 does not support the same concept of the app.config file as .NET desktop applications.

Instead, if you need to provide basic configuration information for an application, you can often store the constants and getters properties in the App.xaml.cs file.

Then you can go to these properties by inserting the Application.Current application into the application from anywhere in your application.

 var property = ((App) Application.Current).MyWebServiceUri; 

Other options include

  • Saving an XML, JSON or INI data file as a Content type, then opening this file and analyzing it at runtime
  • Saving a resource file, parsing at runtime.
+8
source share

All Articles