Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在外部程序集中调用方法时加载外部web.config变量_C#_Wcf_Reflection_Configuration_.net Assembly - Fatal编程技术网

C# 在外部程序集中调用方法时加载外部web.config变量

C# 在外部程序集中调用方法时加载外部web.config变量,c#,wcf,reflection,configuration,.net-assembly,C#,Wcf,Reflection,Configuration,.net Assembly,我正在使用反射调用外部程序集中的方法。外部类/方法位于WCF数据服务中 WCF数据服务使用从web.config中的自定义配置部分加载的信息 <configSections> <section name="myCustomSection" type="MyWcfService.MyCustomSection, MyWcfService" /> </configSections> 这是产生错误的外部程序集(wcf服务)的代码 MyCustomSe

我正在使用反射调用外部程序集中的方法。外部类/方法位于WCF数据服务中

WCF数据服务使用从web.config中的自定义配置部分加载的信息

 <configSections>
  <section name="myCustomSection" type="MyWcfService.MyCustomSection, MyWcfService" />
 </configSections>
这是产生错误的外部程序集(wcf服务)的代码

   MyCustomSection configSection = ConfigurationManager.GetSection("myCustomSection")
          as MyCustomSection ;
configSection出现空值-“对象引用未设置为对象的实例”

我认为,如果在本地应用程序app.config而不是web.config中查找,那么在本地添加相同的配置信息应该可以


谢谢

您可能需要注册AppDomain.CurrentDomain.TypeResolve事件。这个链接有一个如何使用它的例子。

   MyCustomSection configSection = ConfigurationManager.GetSection("myCustomSection")
          as MyCustomSection ;