Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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 
Posted
Updated 3-Jun-17 8:29am

1 solution

Try replacing the endpoint address="https://abc/v2/webservices.asmx" with a fixed ip address if possible, e.g.
C#
endpoint address="https://127.0.0.1/v2/webservices.asmx"
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>
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900