时,我有一个托管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