-1

我有一個簡單的WCF服務,我會嘗試添加服務引用爲我的控制檯應用程序,它工作正常,並自動生成Web配置配置。WCF服務未生成web配置配置

<system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="BasicHttpBinding_IService1" /> 
      </basicHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://localhost:50765/Service1.svc" binding="basicHttpBinding" 
       bindingConfiguration="BasicHttpBinding_IService1" contract="MyFirstService.IService1" 
       name="BasicHttpBinding_IService1" /> 
     </client> 
    </system.serviceModel> 

在同樣的服務我嘗試添加我的MVC項目的服務引用。服務引用已成功添加,但未生成web-config配置。 我該如何解決這個問題?

+0

是它給人的錯誤,而將基準?是否描述了在MVC項目中調用服務時面臨的錯誤? –

+0

我沒有任何錯誤 – user2384352

+0

您是否能夠在您的MVC應用程序中創建代理客戶端? –

回答

2

可能是Visual Studio中的一些錯誤/故障。你總是可以在命令行上手動使用svcutil.exe工具,它會生成所有必要的東西:

svcutil.exe http://example.com/yourservicemetadata 
+1

你能解釋更多關於svcutil.exe的問題 – user2384352

+0

你需要進一步的解釋嗎?你打開一個Visual Studio命令提示符窗口並鍵入'svcutil.exe http:// address_of_your_wcf_service',它將生成一個'.cs'文件,其中包含客戶端代理類和一個'App.config'文件,幷包含所需的必要部分添加到您的配置文件。 –

+0

優秀的答案。你可以通過MSDN鏈接改進它如何使用生成的.cs文件嗎? –