|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
app.config and assembly config in My.ConfigHi,
What is the best approach to deal with My.config and assemblies. When I compile an application the app.config is generated but not the assembly.config. I tried to add those setting in the application.config but this is not working. How can this be done? Thanks Bart Hello Bart,
B> What is the best approach to deal with My.config and assemblies. use System.Configuration to read data from config What do u mean by "deap with assemblies" B> When I compile an application the app.config is generated but not the B> assembly.config. in generated into <projectName>.exe.config B> I tried to add those setting in the application.config but this is B> not B> working. B> How can this be done? Could u desribe it wide? --- WBR, Michael Nemtsev :: blog: http://spaces.msn.com/laflour "At times one remains faithful to a cause only because its opponents do not cease to be insipid." (c) Friedrich Nietzsche Hi Michael,
I have an assembly called datalayer.dll. When I compile this dll separate datalayer.config is generated. When I compile my project called MyApp for example, only MyApp.config is generated. I tried to copy the datalayer.config file to my app folder but it seems that my settings are not picked up by datalayer.dll. Thanks Bart Show quote "Michael Nemtsev" wrote: > Hello Bart, > > B> What is the best approach to deal with My.config and assemblies. > > use System.Configuration to read data from config > > What do u mean by "deap with assemblies" > > B> When I compile an application the app.config is generated but not the > B> assembly.config. > > in generated into <projectName>.exe.config > > B> I tried to add those setting in the application.config but this is > B> not > B> working. > B> How can this be done? > > Could u desribe it wide? > > --- > WBR, > Michael Nemtsev :: blog: http://spaces.msn.com/laflour > > "At times one remains faithful to a cause only because its opponents do not > cease to be insipid." (c) Friedrich Nietzsche > > > Hello Bart,
Right. Class library can't have it's own config, only dll's host application can have it What kind of app is datalayer.dll? just class library or mb COM+? BTW u can keep datalayer.config and use content manually via System.Xml namespace B> Hi Michael, B> B> I have an assembly called datalayer.dll. When I compile this dll B> separate B> datalayer.config is generated. B> When I compile my project called MyApp for example, only MyApp.config B> is B> generated. B> I tried to copy the datalayer.config file to my app folder but it B> seems that B> my settings are not picked up by datalayer.dll. B> Thanks B> Bart Show quote B> "Michael Nemtsev" wrote: Michael Nemtsev :: blog: http://spaces.msn.com/laflourB> >> Hello Bart, >> >> B> What is the best approach to deal with My.config and assemblies. >> >> use System.Configuration to read data from config >> >> What do u mean by "deap with assemblies" >> >> B> When I compile an application the app.config is generated but not >> the B> assembly.config. >> >> in generated into <projectName>.exe.config >> >> B> I tried to add those setting in the application.config but this is >> B> not >> B> working. >> B> How can this be done? >> Could u desribe it wide? >> >> --- >> WBR, >> Michael Nemtsev :: blog: http://spaces.msn.com/laflour >> "At times one remains faithful to a cause only because its opponents >> do not cease to be insipid." (c) Friedrich Nietzsche >> --- WBR, "At times one remains faithful to a cause only because its opponents do not cease to be insipid." (c) Friedrich Nietzsche Hi Michael,
It is just a class library (my datalayer of a winforms app) A setting for example is the connectionstring. I cannot change it on deployment. Thanks art Show quote "Michael Nemtsev" wrote: > Hello Bart, > > Right. Class library can't have it's own config, only dll's host application > can have it > What kind of app is datalayer.dll? just class library or mb COM+? > > BTW u can keep datalayer.config and use content manually via System.Xml namespace > > B> Hi Michael, > B> > B> I have an assembly called datalayer.dll. When I compile this dll > B> separate > B> datalayer.config is generated. > B> When I compile my project called MyApp for example, only MyApp.config > B> is > B> generated. > B> I tried to copy the datalayer.config file to my app folder but it > B> seems that > B> my settings are not picked up by datalayer.dll. > B> Thanks > B> Bart > B> "Michael Nemtsev" wrote: > B> > >> Hello Bart, > >> > >> B> What is the best approach to deal with My.config and assemblies. > >> > >> use System.Configuration to read data from config > >> > >> What do u mean by "deap with assemblies" > >> > >> B> When I compile an application the app.config is generated but not > >> the B> assembly.config. > >> > >> in generated into <projectName>.exe.config > >> > >> B> I tried to add those setting in the application.config but this is > >> B> not > >> B> working. > >> B> How can this be done? > >> Could u desribe it wide? > >> > >> --- > >> WBR, > >> Michael Nemtsev :: blog: http://spaces.msn.com/laflour > >> "At times one remains faithful to a cause only because its opponents > >> do not cease to be insipid." (c) Friedrich Nietzsche > >> > --- > WBR, > Michael Nemtsev :: blog: http://spaces.msn.com/laflour > > "At times one remains faithful to a cause only because its opponents do not > cease to be insipid." (c) Friedrich Nietzsche > > > Hi Bart,
When you set up a Windows Application project, VS IDE automatically add a Settings.settings file under the MyProject folder if you're using VB.NET or the Properties folder if you're using C# in the project directory. VS IDE has generated a class in the Settings.settings file to access the application settings. If you double click the Settings.Designer.vb or Settings.Designer.cs file under the node of Settings.settings in the Solution Explorer, you will see the class. You could make use of the class to access the application settings conveniently. For example, suppose that we have added a setting named setting1 in the application and the setting is of type string. If you're using VB.NET, use the following line of code. Dim val As String = My.Settings.Setting1 If you're using C#, use the line of code as follows. string val = Properties.Settings.Default.Setting1; Generally speaking, the app.config file needn't be copied to the output directory, because when we build the project, a config file named yourappname.exe.config or yourappname.dll.config depending on the application type of your project is generated in the output directory. Finally, to add settings in a project, you have two options to do that. 1. Right-click the project node in the Solution Explorer and choose Properties. In the Project Designer, switch to Settings tab. Then you could add settings in the list box on the right panel. 2. Double-click the Settings.settings node under the My Project or Properties folder in the Solution Explorer. The setting file is opened in the designer with an UI, where you could add settings. Hope this helps. If you have anything unclear, please feel free to let me know. Sincerely, Linda Liu Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Hi Linda, I all know about this.
But I have a sollution with different projects. On project is a winform app and this is ok, [applicationame].config is generated and setting can be found and changes at deployment. But this sollution also have a datalayer.dll that holds the connectionstring setting. At compile time ofcourse the datalayer.dll is added to the bin directory of the winforms project, but not the datalayer.config So at deployment I cannot change the connection string. It is clear? Thanks Bart Show quote "Linda Liu [MSFT]" wrote: > Hi Bart, > > When you set up a Windows Application project, VS IDE automatically add a > Settings.settings file under the MyProject folder if you're using VB.NET or > the Properties folder if you're using C# in the project directory. > > VS IDE has generated a class in the Settings.settings file to access the > application settings. If you double click the Settings.Designer.vb or > Settings.Designer.cs file under the node of Settings.settings in the > Solution Explorer, you will see the class. > > You could make use of the class to access the application settings > conveniently. For example, suppose that we have added a setting named > setting1 in the application and the setting is of type string. If you're > using VB.NET, use the following line of code. > > Dim val As String = My.Settings.Setting1 > > If you're using C#, use the line of code as follows. > > string val = Properties.Settings.Default.Setting1; > > Generally speaking, the app.config file needn't be copied to the output > directory, because when we build the project, a config file named > yourappname.exe.config or yourappname.dll.config depending on the > application type of your project is generated in the output directory. > > Finally, to add settings in a project, you have two options to do that. > 1. Right-click the project node in the Solution Explorer and choose > Properties. In the Project Designer, switch to Settings tab. Then you could > add settings in the list box on the right panel. > > 2. Double-click the Settings.settings node under the My Project or > Properties folder in the Solution Explorer. The setting file is opened in > the designer with an UI, where you could add settings. > > Hope this helps. > If you have anything unclear, please feel free to let me know. > > > Sincerely, > Linda Liu > Microsoft Online Community Support > > ================================================== > Get notification to my posts through email? Please refer to > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications. > > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues > where an initial response from the community or a Microsoft Support > Engineer within 1 business day is acceptable. Please note that each follow > up response may take approximately 2 business days as the support > professional working with you may need further investigation to reach the > most efficient resolution. The offering is not appropriate for situations > that require urgent, real-time or phone-based interactions or complex > project analysis and dump analysis issues. Issues of this nature are best > handled working with a dedicated Microsoft Support Engineer by contacting > Microsoft Customer Support Services (CSS) at > http://msdn.microsoft.com/subscriptions/support/default.aspx. > ================================================== > > This posting is provided "AS IS" with no warranties, and confers no rights. > > Hi Bart,
Thank you for your reply. I understand your question now. Yes, you're right. If a WinForms project has a reference to an assembly and the assembly has a config file, when the WinForms project is built, the assembly is added to the output directory of the WinForms project, but not the assembly's config file. The assembly won't access its config file and only takes the default values of the settings. In fact, it's not a common use for an assembly to access a config file. The application config only makes sense for WinForms application. In your scenario, why not store the database connection string in the WinForms application's config file? You could read the database connection string in the WinForms application and pass it to the assembly. Hope this helps. If you have anything unclear, please feel free to let me know. Sincerely, Linda Liu Microsoft Online Community Support Hi Linda,
I understand. So it is by design. My idea was to split all business logic into a separate project (dll) including the connectionstring. I is like a webservice, the frontend app don't know anything about the underlaying database. Thanks for clearing out Bart Show quote "Linda Liu [MSFT]" wrote: > Hi Bart, > > Thank you for your reply. I understand your question now. > > Yes, you're right. If a WinForms project has a reference to an assembly and > the assembly has a config file, when the WinForms project is built, the > assembly is added to the output directory of the WinForms project, but not > the assembly's config file. The assembly won't access its config file and > only takes the default values of the settings. > > In fact, it's not a common use for an assembly to access a config file. The > application config only makes sense for WinForms application. > > In your scenario, why not store the database connection string in the > WinForms application's config file? You could read the database connection > string in the WinForms application and pass it to the assembly. > > Hope this helps. > If you have anything unclear, please feel free to let me know. > > > Sincerely, > Linda Liu > Microsoft Online Community Support > > > > |
|||||||||||||||||||||||