简体   繁体   English

添加引用vs添加服务引用

[英]Add reference vs Add service reference

I'm little bit confused about "Add reference" and "Add service reference" in case of WCF service. 在WCF服务的情况下,我对“添加引用”和“添加服务引用”有点困惑。 I checked it on internet and MSDN but did not find any suitable answer.The actual problem I'm facing due to lack of understanding this, is questioned here ( Add service reference gives Exception: Unable to connect to remote server ). 我在互联网和MSDN上检查过但没有找到任何合适的答案。由于对此缺乏了解,我面临的实际问题在这里受到质疑( 添加服务参考给出例外:无法连接到远程服务器 )。

I tried to find that, add service reference is invoking svcutil.exe and add reference is just adding dll. 我试图发现,添加服务引用是调用svcutil.exe而添加引用只是添加dll。 However, this did not give me clear idea.What actually internally happens in both the case? 但是,这并没有让我明白。在这两种情况下,究竟是内部发生了什么? If Add reference is working fine with basic HTTP connection, why add service reference would not work? 如果添加引用与基本HTTP连接正常工作,为什么添加服务引用不起作用?

Please help me understand without down grading this question.I'm tiring to find out the solution to my problem. 请不要对这个问题进行评分,请帮助我理解。我很难找到解决问题的方法。

Use add service reference when you are adding a web service reference to the solution and needs a proxy to call the service functions. 在向解决方案添加Web服务引用时需要使用添加服务引用,并且需要代理来调用服务功能。 You add reference in case when you have another project and you want to add it as a library or add any external library. 如果您有另一个项目并且想要将其添加为库或添加任何外部库,则可以添加引用。

From MSDN: "A service reference enables a project to access one or more Windows Communication Foundation (WCF) services" 来自MSDN:“服务引用使项目能够访问一个或多个Windows Communication Foundation(WCF)服务”

"The Add Reference dialog box can be used either to add or to delete project references" “添加引用对话框可用于添加或删除项目引用”

When you use "Add Reference", you are adding a reference to a dynamic-link library so you can reuse code. 使用“添加引用”时,您将添加对动态链接库的引用,以便您可以重用代码。

When you add a Service Reference, you are asking Visual Studio to generate stubs in order to call some service running on a possibly separate machine. 添加服务引用时,您要求Visual Studio生成存根,以便调用在可能独立的计算机上运行的某些服务。

For example, if example.com exposes a soap service for credit card processing, you would click on Add Service Reference and enter "example.com" in the address bar. 例如,如果exam​​ple.com公开了用于信用卡处理的soap服务,则可以单击“添加服务引用”并在地址栏中输入“example.com”。 If example.com sends you a credit card processing library in the form of a dll, you would use "Add Refererence". 如果exam​​ple.com以dll的形式向您发送信用卡处理库,您将使用“Add Refererence”。

Add Service Reference - exposed as a WCF / SOAP etc 添加服务引用 - 作为WCF / SOAP等公开

Add Reference - exposed as a file ending in .dll 添加引用 - 公开为以.dll结尾的文件

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

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