简体   繁体   English

VS2012添加服务引用不更新配置文件

[英]VS2012 Add Service Reference not updating config file

I have created a new IIS hosts WCF service using the webHttpBinding which is currently running on on IIS Express on my development machine and when I try to "Add Service Reference" the service is correctly built and the Reference.cs file looks fine but the web.config or app.config files are not being updated. 我使用webHttpBinding创建了一个新的IIS主机WCF服务,该webHttpBinding当前在我的开发机器上的IIS Express上运行,当我尝试“添加服务引用”时,服务正确构建并且Reference.cs文件看起来很好但是web .config或app.config文件未更新。

No warnings or error messages are received. 没有收到警告或错误消息。

Both the service and the client are targeting .Net 4.5. 服务和客户端都以.Net 4.5为目标。

Service config 服务配置

  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="webInteropSecureBinding" allowCookies="false" maxBufferPoolSize="2097152" maxBufferSize="2097152" maxReceivedMessageSize="2097152">
          <security mode="Transport" />
        </binding>
      </webHttpBinding>
    </bindings>
    <services>
      <service name="PsmDataProvider.PsmProvider" behaviorConfiguration="SecureRest">
        <clear />
        <endpoint address="" binding="webHttpBinding" bindingConfiguration="webInteropSecureBinding" name="PsmProvider" contract="PsmDataProvider.IPsmProvider" listenUriMode="Explicit" behaviorConfiguration="webHttpBehavior" />
        <endpoint address="mex" binding="mexHttpsBinding" name="mex" contract="IMetadataExchange" listenUriMode="Explicit" />
        <host>
          <baseAddresses>
            <add baseAddress="https://localhost:44300/PsmProvider/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="SecureRest">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="webHttpBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

Client Config 客户端配置

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
</configuration>

Client Service Reference 客户服务参考

在此输入图像描述

Following some investigation I found these StackOverflow questions 经过一些调查后,我发现了这些StackOverflow问题

Question 1 问题1

Question 2 问题2

Question 3 问题3

And this post 这篇文章

Blog post 博客文章

Each of the above refer to the same problem of unticking the "Reuse types in references assemblies" flag which I have done. 上面的每一个都指的是解开我已经完成的“引用程序集中的重用类型”标记的相同问题。

在此输入图像描述

The problem is it did not fix the issue. 问题是它没有解决问题。 I have tried updating and deleting and recreating the service reference but it never updates the config file. 我已尝试更新和删除并重新创建服务引用,但它从不更新配置文件。

Question

Is this a problem with the server side configuration? 这是服务器端配置的问题吗? Or is this an issue with the client side? 或者这是客户端的问题? How to I change either so that the proxy generation works as expected? 如何更改以使代理生成按预期工作?

OK, looks like there are issues in adding a service reference to services that implement the WebHttpBinding WCF binding. 好的,看起来在向实现WebHttpBinding WCF绑定的服务添加服务引用时存在问题。

This is discussed in Carlos Figueira Blog Post 这在Carlos Figueira博客文章中讨论

Remove maxBufferPoolSize="2097152" maxBufferSize="2097152" from your web.config file. web.config文件中删除maxBufferPoolSize="2097152" maxBufferSize="2097152" Then try to update your service. 然后尝试更新您的服务。 Make sure your Bindings are correctly mentioned. 确保正确提到您的绑定。

I had the same problem again today with VS2012. 今天我和VS2012再次遇到了同样的问题。

I have a set of Test, PreProduction and Production web.config configurations, I could use "Preview transformation", and see that VS2012 was patching my "web.config" with the relevant settings.. 我有一套Test,PreProduction和Production web.config配置,我可以使用“预览转换”,并看到VS2012 正在使用相关设置修补我的“web.config”。

预习

...but... when I deployed, well, it just seemed to include the default "web.config" file without any changes. ...但是...当我部署时,它似乎只包含默认的“web.config”文件而没有任何更改。

The cause was that VS2012 seemed to have messed up its configurations, and in the Publish dialog, suddenly my PreProduction configuration was associated with Debug. 原因是VS2012似乎弄乱了它的配置,并且在Publish对话框中,突然我的PreProduction配置与Debug相关联。 Huh ? 嗯?

发布

Changing this from "Debug" to "PreProduction" fixed the issue for me. 将其从“Debug”更改为“PreProduction”为我解决了这个问题。

Or, at least, it nudged me a step forward, but I'm still having an issues with VS2012 messing up my configuration names when it tries to deploy. 或者,至少,它向我推了一步,但我仍然遇到VS2012在尝试部署时弄乱我的配置名称的问题。

部署

(Depressed sigh.) (郁闷叹息。)

Currently downloading VS2013. 目前正在下载VS2013。 Hopefully, this release will be less buggy. 希望这个版本不那么多了。

In my case, it was caused by I set a binding parameter wrong on the web service side. 在我的情况下,它是由我在Web服务端设置错误的绑定参数引起的。

binding.ReliableSession.InactivityTimeout = TimeSpan.Maximum; binding.ReliableSession.InactivityTimeout = TimeSpan.Maximum;

After set this to System.TimeSpan(0, 10, 0); 将此设置为System.TimeSpan(0,10,0); the binding configuration is generated in web.config file. 绑定配置在web.config文件中生成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM