prabhu

prabhu

  • NA
  • 64
  • 11.4k

While creating WCF service i faced one error.

Mar 18 2019 12:37 AM
The type initializer for 'System.ServiceModel.DiagnosticUtility' threw an exception.
I am using console application for hosting
I am new to WCF just step into 
 
//code which iam getting error
 
 
using (System.ServiceModel.ServiceHost host = new
System.ServiceModel.ServiceHost(typeof(HelloService.HelloService)))
{
host.Open();
Console.WriteLine("Host started @ " + DateTime.Now.ToString());
Console.ReadLine();
}
App config of  console application
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviour">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="HelloService.HelloService" behaviorConfiguration="mexBehaviour">
<endpoint address="HelloService" binding="basicHttpBinding" contract="HelloService.IHelloService">
</endpoint>
<endpoint address="HelloService" binding="netTcpBinding" contract="HelloService.IHelloService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:65453/" />
<add baseAddress="net.tcp://localhost:65477"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MexBehavior">
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
 
App config  for service 
//
 
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="HelloService.HelloServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="HelloService.HelloServiceBehavior"
name="HelloService.HelloService">
<endpoint address="" binding="basicHttpBinding" contract="HelloService.IHelloService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/HelloService/HelloService/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
// 
Please help on this, 
Thanks in advance
 
 
 

Answers (1)