reference_add service reference_add web reference_add connected reference_add analyze distinguishing

Add Connected Service is the new tool for generating .NET Core proxies
The difference between "Add Service Reference" and "Add Connected Service" is whether the generated proxy can run on .NET Core (Connected Service) or on the full .NET Framework (Service Reference). WCF on .NET Core does not support all the same features as WCF on the full framework, so the proxy has to be generated differently.

The reason you're seeing an error when calling the service is because WS Security is not supported by WCF on .NET Core.

Creating a plain C# Console App in Visual Studio 2015 Preview, we get a pseudo reference named "Analyzers":

What does the "Analyzers" reference just above mean?

The project file has nothing inside and the properties window shows nothing (completely blank) about this entry (though, in contrast to "reference properties" it says "folder properties" in the header, but that does not say much).

I would expect this to be related to Roslyn, but I have no idea. I have ReSharper installed, but I don't assume it has anything to do with it.

Edit 6.8.2016

The accepted answer explains the tooling provided by analyzers, but leaves open why a development tool becomes a (runtime?) reference. Actually it is not a runtime reference, unlike the other references. So the answer to this miracle is Hans Passants comment below:

They picked a clumsy place to add the code analyzers feature, they just couldn't find a better place without drastically overhauling the solution explorer and nuget. – Hans Passant May 26 '15 at 8:59

先谈谈他们的区别:

区别一:

  • WebReference是由wsdl.exe生成客户端代理的。生成webservice代理类的方法,即从System.Web.Services.Protocols.SoapHttpClientProtocol派生而来,代理类代码可以指定要访问的Url属性。
  • ServiceReference是由svcutil.exe生成客户端代理的。按照新的webservice客户访问机制WCF(不是直接从System.Web.Services.Protocols.SoapHttpClientProtocol派生而来)。代理类代码没有Url属性可指定,而是在客户端的配置文件app.config中指定endpoint来访问指定的url。

区别二:

  • WebReference生成的代理可以被.net1.1或.net2.0的客户端调用。
  • ServiceReference生成的代理只能被.net3.0+的客户端调用,而且ServiceReference后不仅生成代理类,在web.config中还会生成相应的Tag。(注:这里Tag显著表现为)

区别三:

  • WebReference的方式不能使用Wcf。(wcf需.net3.0的支持)
  • ServiceReference可以使用wcf。(需.net3.0+的客户端)

再谈谈使用时注意事项:

  • 静态添加WebReference: 右击项目–》添加服务引用–》高级–》添加Web引用–》URL输入地址–》前往–》确定
  • 静态添加ServiceReference: 右击项目–》添加服务引用–》地址–》转到–》确定

注意:上面的方法是在非启动项项目(比如某个类库)中添加的,在该项目下会自动生成一个app.config文件,而在主配置文件.config中并没有自动添加上该webservice的标记,这样运行会出现错误,说找不到配置信息等等……所有还需要把app.config中的<system.serviceModel>……</system.serviceModel>这段配置添加到主配置文件的.config的<configuration>……</configuration>标记中,这样运行就不会出问题了。如果以后服务地址发生了变化,也只需要修改主配置文件config中的地址就行了。
 

发布了721 篇原创文章 · 获赞 71 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/sinolover/article/details/104558405
Add