简体   繁体   English

为什么 WCF 服务在应用程序中添加为连接服务而不是服务参考?

[英]why WCF service Added As Connected Service not Service reference in application?

I am trying to add a service reference to my MVC application project.我正在尝试向我的 MVC 应用程序项目添加服务引用。 The project is targeting 4.5.1 .NET framework.该项目针对 4.5.1 .NET 框架。 When I add the service reference the service is added under connected service folder, I expected this to be under a folder named "Service References".当我添加服务引用时,该服务被添加到连接的服务文件夹下,我希望它位于名为“服务引用”的文件夹下。 how can I do that?我怎样才能做到这一点? if that is impossible what is the different between connected services and reference services?如果这是不可能的,那么连接服务和参考服务有什么区别? if i make it under connected service there is any problem?如果我在连接服务下进行,有什么问题吗?

Generally, when adding a service reference, it will be in the Service Reference folder.通常,添加服务引用时,它会在服务引用文件夹中。 If the references are not under Service References, you can put them under Service Reference and tell the program that they are Service references.如果引用不在服务引用下,您可以将它们放在服务引用下,并告诉程序它们是服务引用。 Or the Service References that specify a location.或指定位置的服务引用。 Here's what you can do:以下是您可以执行的操作:

First edit the XML file and add the following code:首先编辑 XML 文件并添加以下代码:

<ItemGroup>
 <WCFMetadataStorage Include="Service References\NameOfYourReference\" />
 <WCFMetadataStorage Include="Service References\NameOfYourOtherReference\" />
</ItemGroup>

Then because VS automatically generates a reference1.cs, you need to remove it and change the code in the reference.cs file:然后因为VS自动生成了一个reference1.cs,所以需要去掉它,改一下reference.cs文件中的代码:

<Compile Include="Service References\NameOfYourReference\Reference.cs">
  <AutoGen>True</AutoGen>
  <DesignTime>True</DesignTime>
  <DependentUpon>Reference.svcmap</DependentUpon>
</Compile>

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

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