我正在尝试将配置文件放在我的IOS / Android应用程序的PCL部分中。
以下文件:https://github.com/mrbrl/PCLAppConfig 表明:
Assembly assembly = typeof(App).GetTypeInfo().Assembly;
ConfigurationManager.AppSettings = new ConfigurationManager(assembly.GetManifestResourceStream("DemoApp.App.config")).GetAppSettings;
我希望DemoApp是他们的示例应用程序的程序集名称,所以我有:
使用PCLAppConfig;
namespace LYG
{
public class App : Application
{
public App ()
{
Assembly assembly = typeof(App).GetTypeInfo().Assembly;
ConfigurationManager.AppSettings = new ConfigurationManager(assembly.GetManifestResourceStream("LYG.App.config")).AppSettings;
}
...
}
}
我收到以下编译错误:
/Users/greg/Projects/LYG/LYG/LYG.cs(122,122):错误CS1061:输入PCLAppConfig.ConfigurationManager' does not contain a definition for
GetAppSettings'并且没有扩展方法GetAppSettings' of type
PCLAppConfig.ConfigurationManager'可以找到。你错过了装配参考吗? (CS1061)(LYG)
这是我的packages.config文件:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="PCLAppConfig" version="0.3.1" targetFramework="portable45-net45+win8+wp8" />
<package id="PCLStorage" version="1.0.2" targetFramework="portable45-net45+win8+wp8" />
<package id="Xamarin.Forms" version="2.3.2.127" targetFramework="portable45-net45+win8+wp8" />
</packages>
我也试过括号:
ConfigurationManager.AppSettings = new ConfigurationManager(assembly.GetManifestResourceStream("LYG.App.config")).AppSettings();
为什么找不到GetAppSettings?