簡體   English   中英

WCF客戶端應用程序在訪問服務時崩潰

[英]WCF client application crashes when accessing service

我創建了可以訪問ADO.net實體框架的wcf Web服務。 IIS上的主機,並具有控制台客戶端。 一切正常..在我的計算機上。 當我將.exe文件發送到另一個文件時,它崩潰了,我無法弄清原因。 控制台應用程序代碼:

MyServiceClient client = new MyServiceClient();
Console.WriteLine(client.GetOrders().First().Date_Accepted.ToString());
client.Close();
Console.ReadLine();

我的web.config文件是默認文件,除了連接字符串外沒有任何更改。 客戶端app.config

<configuration>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IMyService" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://93.77.254.167:9595/MyService.svc" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IMyService" contract="MyServiceReference.IMyService"
            name="BasicHttpBinding_IMyService" />
    </client>
</system.serviceModel>

任何想法為什么?

將代碼包裝在try catch塊中,您會發現出了什么問題。

try
{
 MyServiceClient client = new MyServiceClient();
 Console.WriteLine(client.GetOrders().First().Date_Accepted.ToString());
 client.Close();
 Console.ReadLine();
}
catch (Exception ex)
{
 Console.WriteLine(ex);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM