我创建了一个简单的服务,只是为了在Cent OS中尝试WCF。 我在Windows中用MonoDevelop创建了服务客户端,它工作正常。当我尝试在CentOs上运行它(使用相同的配置文件)时,它会抛出构造客户端的错误,我在这里跟踪它:
ExtensionElementCollection extensions = ((ExtensionsSection) EvaluationContext.GetSection ("system.serviceModel/extensions")).BindingExtensions;
for (int i = 0; i < extensions.Count; i++) {
ExtensionElement extension = extensions [i];
_properties.Add (new ConfigurationProperty (extension.Name, Type.GetType (extension.Type), null, null, null, ConfigurationPropertyOptions.None));
}
在System.ServiceModel.Configuration.BindingsSection
中错误是ConfigurationProperty构造函数中的argumentNullException,type为null。因此,来自EvaluationContext.GetSection(“system.serviceModel / extensions”)的Type.GetType失败。 我没有在配置文件中的扩展部分,这个相同的客户端在Windows中完美运行。 任何提示。
这是我的配置文件:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IPairArithmeticService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://theIp/AlertService/Services/PairArithmeticService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPairArithmeticService"
contract="ServiceReference1.IPairArithmeticService" name="BasicHttpBinding_IPairArithmeticService" />
</client>
</system.serviceModel>