虽然服务项目的投掷错误{''system.servicemodel.diagnostics.traceutility'的类型初始化程序引发了异常。“} [英] While service project its throwing error {"the type initializer for 'system.servicemodel.diagnostics.traceutility' threw an exception."}

查看:183
本文介绍了虽然服务项目的投掷错误{''system.servicemodel.diagnostics.traceutility'的类型初始化程序引发了异常。“}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am getting  this error 

"The type initializer for 'System.ServiceModel.Diagnostics.TraceUtility' threw an exception."  While calling soap client web service " . Code gets above error when it reached to code    

ServiceReference1.WebservicesSoapClient srv =new  ServiceReference1.WebservicesSoapClient();
-----------------------------------------------This is my app.config--------------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appsettings>
  </appsettings>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="WebservicesSoap">
                    <security mode="Transport" />
                </binding>
                <binding name="WebservicesSoap1" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://abc/v2/webservices.asmx"
                binding="basicHttpBinding" bindingConfiguration="WebservicesSoap"
                contract="ServiceReference1.WebservicesSoap" name="WebservicesSoap" />
        </client>
      
    </system.serviceModel>
</configuration>


Would some body guid on this ?





我尝试过:





What I have tried:

I tired editing app.config . there is no much result found on intenrnet 

推荐答案

尝试替换端点地址=https://abc/v2/webservices.asmx 如果可能,使用固定的IP地址,例如

Try replacing the endpoint address="https://abc/v2/webservices.asmx" with a fixed ip address if possible, e.g.
endpoint address="https://127.0.0.1/v2/webservices.asmx"

此外,您可能需要在IP地址中添加一个端口。

还要确保您的防火墙没有阻止通信。

还要确保您的项目中没有干扰app.config的设置,尝试删除这些行:

Also you might need to add a port to the ip address.
Also make sure your firewall is not blocking the communication.
Also make sure you don't have settings in your project that interfere with app.config, try to remove the lines:

<appsettings>
</appsettings>
<startup> 
   <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>


这篇关于虽然服务项目的投掷错误{''system.servicemodel.diagnostics.traceutility'的类型初始化程序引发了异常。“}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆