2009-01-06 85 views
0

时,我有一个托管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仍然与更新的代码崩溃。

它会找到服务,得到所有的操作,不能。当我点击添加时,它崩溃。

任何人都有线索怎么回事?

在此先感谢

罗伯托

回答

0

我固定它。

在userSettings部分之后,我将output.config中的system.serviceModel节复制并粘贴到app.config中,并将整个output.config注释掉。

我还在初始化ChatClient(“名称”)时指定了端点的名称。

它似乎在工作。

0

您是否尝试过使用配置文件的设置,而不是编程方式这样做呢?那么至少你会知道这是一个常规设置问题还是与你的代码有关。然后您可以逐个推出代码位; mex,然后终点并查看哪个杀死了它。

+0

据我所知客户端代码使用配置文件。它出于某种原因不能使用它(我认为这是例外的意思)。你的配置文件设置是什么意思?我是WCF新手,所以我不确定。 – 2009-01-06 22:49:45

0

是否VS2008死亡没有任何反馈?如果是这样,请检查Windows事件日志(应用程序日志)中的错误消息。

一个可能的原因:VS2008 + System.Core.dll 3.5 +坏NGen图像可能会导致崩溃,当VS2008试图加载任何System.Core或任何引用/依赖于它。

您可能还想将一个VS实例附加到另一个(作为调试器)以查看任何其他崩溃详细信息。但我会首先探索System.Core/NGen的轨迹。

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=341658 https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=337149 https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=330302 https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=330903