开发者

several project in a solution and I can't use properties class inside none of them

开发者 https://www.devze.com 2023-03-08 01:34 出处:网络
I\'ve created a solution with 3 different class project (DLL library) inside it. Now when I create a Setting and I want to access any of my Settings inside code using Properties.Settings I\'m not abl

I've created a solution with 3 different class project (DLL library) inside it.

Now when I create a Setting and I want to access any of my Settings inside code using Properties.Settings I'm not able to do that since compiler shows some error like :

Only assignment, call, increment, decrement, and new object expressions can be used as a statement

actually the intelisene doesn't give me any hint about prope开发者_如何学运维rties namespace seems it is missing.

what should I do?


Refer to the following:

Using Settings in C#

Compiler Error CS0201


Actually libraries (.dll assemblies) are not meant to have their own settings. Rather, all settings should be injected by the host application (.exe) for those libraries. Have a settings class in the host application and inject all the settings to the libraries as needed via their constructor (of course after you retrieve them via Properties.Settings.Default.xxx properties of the host application settings).


To access your property settings do the following:

var mySetting = Properties.Default.aSetting;

where aSetting the the name of your setting.

From the error message I'm guessing you are not assigning the setting to anything e.g. just doing

 Properties.Default.aSetting;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号