時,我有一個託管WCF服務的控制檯應用程序VS2008崩潰添加WCF服務
更新此代碼運行脫app.config文件,而不是初始化它編程
Uri baseAddress = new Uri("http://localhost:8000/ChatServer/Service");
ServiceHost myHost = new ServiceHost(typeof(ClientServerChat.ChatServer), baseAddress);
myHost.AddServiceEndpoint(typeof(IChat), new WSHttpBinding(), "ChatService");
ServiceMetadataBehavior mb = new ServiceMetadataBehavior();
ServiceBehaviorAttribute attrib = (ServiceBehaviorAttribute)myHost.Description.Behaviors[0];
attrib.IncludeExceptionDetailInFaults = true;
mb.HttpGetEnabled = true;
myHost.Description.Behaviors.Add(mb);
myHost.Open();
的控制檯應用程序編譯並運行。 svcutil完美運行。
SvcUtil工具違背了新的服務代碼完美,生成客戶端代碼和輸出中的文件
我打電話通過Visual Studio命令提示符SvcUtil工具,像這樣:svcutil.exe的http://localhost:8000/ChatServer/Service
它生成這個output.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IChat" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8000/ChatServer/Service/ChatService"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IChat"
contract="IChat" name="WSHttpBinding_IChat">
<identity>
<userPrincipalName value="Bedroom-PC\Roberto" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
隨着捆綁的客戶端代碼(這是在與t他輸出文件,我要補充),我應該能夠與此調用服務:
ChatClient client = new ChatClient();
從SvcUtil工具(代碼和配置新的輸出)仍然拋出該異常。
但它拋出一個異常說:
「找不到,在ServiceModel客戶端配置單元參考合同‘的iChat’默認終結點元素這可能是因爲沒有配置文件找到您的應用程序,或者因爲在客戶端元素中找不到匹配此合同的端點元素。「
有趣的是,在將相同的服務引用添加到客戶端項目時,Visual Studio 2008會崩潰。
VS2008仍然與更新的代碼崩潰。
它會找到服務,得到所有的操作,不能。當我點擊添加時,它崩潰。
任何人都有線索怎麼回事?
在此先感謝
羅伯託
據我所知客戶端代碼使用配置文件。它出於某種原因不能使用它(我認爲這是例外的意思)。你的配置文件設置是什麼意思?我是WCF新手,所以我不確定。 – 2009-01-06 22:49:45