Reputation: 1087
I Have created a WCF service that hosted in IIS 7
My .NET version is 4.0
My Operating System is Windows 7 Ultimate
My Service Address:
When i added service reference i get two warning:
First:
Warning 2 Custom tool warning: Endpoint 'NetTcpBinding_IChat' at address 'net.tcp://localhost:4504/WPFHost/tcp' is not compatible with Silverlight 4. Skipping... D:\Projects\C#\WCF\SilverlightApplication1\SilverlightApplication1\Service References\SV\Reference.svcmap 1 1 SilverlightApplication1
Second:
Warning 3 Custom tool warning: No endpoints compatible with Silverlight 4 were found. The generated client class will not be usable unless endpoint information is provided via the constructor. D:\Projects\C#\WCF\SilverlightApplication1\SilverlightApplication1\Service References\SV\Reference.svcmap 1 1 SilverlightApplication1
My service Appconfig file is like below:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<system.serviceModel>
<services>
<service name="WCFService.Service"
behaviorConfiguration="behaviorConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:4504/WPFHost/"/>
<add baseAddress="http://localhost:4505/WPFHost/"/>
</baseAddresses>
</host>
<endpoint address="tcp"
binding="netTcpBinding"
bindingConfiguration="tcpBinding"
contract="WCFChatLibrary.IChat"/>
<endpoint address="net.tcp://localhost:4503/WPFHost/mex"
binding="mexTcpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="behaviorConfig">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="tcpBinding"
maxBufferSize="67108864"
maxReceivedMessageSize="67108864"
maxBufferPoolSize="67108864"
transferMode="Buffered"
closeTimeout="00:00:10"
openTimeout="00:00:10"
receiveTimeout="00:20:00"
sendTimeout="00:01:00"
maxConnections="100">
<security mode="None">
</security>
<readerQuotas maxArrayLength="67108864"
maxBytesPerRead="67108864"
maxStringContentLength="67108864"/>
<reliableSession enabled="true" inactivityTimeout="00:20:00"/>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>
When i call the service it throw exception. Here is my code:
if (this.proxy == null)
{
try
{
this.StatusTxtBlock.Text = "Ready";
this.localClient = new Client();
this.localClient.Username = "User-" + Guid.NewGuid();
this.proxy = new ChatClient(new InstanceContext(this));
this.proxy.OpenAsync();
this.proxy.ConnectAsync(this.localClient);
this.proxy.ConnectCompleted += new EventHandler<ConnectCompletedEventArgs>(proxy_ConnectCompleted);
}
catch (Exception ex)
{
this.StatusTxtBlock.Text = "Exception: "+ ex.Message;
}
}
and the exception is:
Exception: The given key was not present in the dictionary
I follow this tutorial but no luck
I don't know what to do, my mind and vision is going to blank, maybe i'm going crazy. Please somebody save me (i mean help me).
Upvotes: 0
Views: 2237
Reputation: 87308
Silverlight 4 supports a subset of NetTcpBinding
on the server. It doesn't support security, for example (which is fine for your case, since you have <security mode="None">
in your binding), and it also doesn't support reliable messaging (which is likely the problem in your case, since you have it enabled in your binding). This is one binding configuration for netTcpBinding
which is compatible with SL:
<bindings>
<netTcpBinding>
<binding name="SLCompatible">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
Upvotes: 1
Reputation: 8687
This MSDN article states that NetTcpBinding
cannot be used with Silverlight 4.
I'm not sure whether to believe Tomasz Janczuk or MSDN, but Tomasz's article is 2 years old, so my guess is: NetTcpBinding
was planned for Silverlight 4 but not included in the end.
You can consider switching to BasicHttpBinding
or 'roll your own' custom binding as described in the following article.
Upvotes: 0