VS2013 C#.net4.5,在新解决方案中将现有服务引用添加到新项目中 [英] VS2013 C# .net4.5 , add existing service reference to a new project in a new solution

查看:291
本文介绍了VS2013 C#.net4.5,在新解决方案中将现有服务引用添加到新项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VS2013 C#.net 4.0解决方案,并且其中一个C#项目(控制台应用程序)有一个名为";服务参考".

I have a VS2013 C# .net 4.0 solution and one of the C# projects (console application ) has a folder called "Service References".

文件夹中有两个子文件夹

In the folder, there are two subfolders

   一个是:MyReference1,它具有以下文件

    One is : MyReference1, it has files of

                          configuration.svcinfo

                configuration.svcinfo

             configuration91.svcinfo

                configuration91.svcinfo

                          MyApplication1.disco(Web服务发现文件)

                MyApplication1.disco (web service Discovery File)

                          MyApplication2.wsdl(Web服务描述语言)

                MyApplication2.wsdl (web service description language)

                          Reference.cs(Visual C#源文件)

                Reference.cs (Visual C# source file)

                          Reference.svcmap

                Reference.svcmap

     另一个 是:MyReference2,它的文件是

      Another one  is: MyReference2, it has files of

                          configuration.svcinfo

                configuration.svcinfo

                          configuration91.svcinfo

                configuration91.svcinfo

                          MyApplication3.wsdl

                MyApplication3.wsdl

                          MyApplication4.disco

                MyApplication4.disco

                          MyApplication4_1.xsd

                MyApplication4_1.xsd

                          MyApplication4_2.xsd

                MyApplication4_2.xsd

                          MyApplication4_3.xsd

                MyApplication4_3.xsd

             MyProject.MyReference.JobStatus.datasource(Visual Studio数据源文件)

                MyProject.MyReference.JobStatus.datasource (visual studio data source file)

                          Reference.cs

                Reference.cs

                          Reference.svcmap

                Reference.svcmap

 

现在,由于某些原因,我必须创建一个新项目. (具有VS2013 C#.net 4.0的新解决方案)中的服务引用与上述完全相同.

Now, for some reasons, I have to create a new project  in a new solution (of VS2013 C# .net 4.0) with exactly same services references as the above one.

 

创建了新的解决方案和新项目(与上述项目具有相同的属性)后,我尝试添加上述现有项目上述子文件夹中的文件放入我的新项目.

After creating a new solution and a new project (which has same property as the above one), I tried to add the above existing files in the above subfolders into my new project.

我创建了一个名为"Service References"的新文件夹,以及与上述同名的子文件夹.

I created a new folder called "Service References" and the subfolders with the same name as above.

但是,当我构建项目时,出现了错误,例如,

But, when I build the project, I got the errors, for example,

在Reference.svcmap中,

In Reference.svcmap,

 

           错误                  自定义工具错误:无法生成文件:The 系统找不到指定的文件. (来自HRESULT的异常:0x80070002)       C:\ MyPATH \ MyProject \ serviceReference \ MyReference2 \ Reference.svcmap

            Error        1        Custom tool error: Failed to generate file: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)        C:\MyPATH\MyProject\serviceReference\MyReference2\Reference.svcmap

 

在Reference.cs中

In Reference.cs

        错误                     名称空间系统"(您是否缺少程序集引用?)        C:\ MyPATH \ MyProject \ serviceReference \ MyReference1 \ Reference.cs(该文件是自动由工具生成)

          Error        5        The type or namespace name 'ServiceModel' does not exist in the namespace 'System' (are you missing an assembly reference?)        C:\MyPATH\MyProject\serviceReference\MyReference1\Reference.cs (the file was auto-generated by a tool )

 

文件夹"Service References"与"Service References"之间的区别在我的项目和旧项目中,在服务引用"下,您只是两个子文件夹名称.在旧项目中 文件夹中没有文件显示在项目中.但是,在我的项目中, 显示所有文件,因为我将它们添加为现有项.

The difference between the folder "Service References" in my project and in the old project is that thee are only two subfolder names under "Service References" in the old project and no files inside the folder are shown in the project. But, in my project,  all files are shown because I added them as existing items.

 

当我右键单击该项目并通过将路径(服务引用"位于其中)粘贴服务引用时, 地址"部分,我得到了错误:

When I right clicked the project and add service reference by pasting the path (where the "Service References" is located) in the "Address" part, I got error:

 

       下载"C:\ MyPath \ Service References"时出错.

         There was an error downloading 'C:\MyPath\Service References'.

 

       

         Access to the path 'C:\djx_2014_6_3\MyPath\Service References' is denied.

 

       如果服务是在当前解决方案中定义的,请尝试构建解决方案并再次添加服务引用.

         If the service is defined in the current solution, try building the solution and adding the service reference again.

 

我以管理员身份运行VS2013.

I run the VS2013 as administrator.

 

如何正确添加服务引用?

How to add service references correctly ?

 

有什么想法吗?

 

谢谢!

推荐答案

服务引用及其子文件夹由IDE自动生成.您不会直接创建它们.删除该文件夹及其中手动创建的任何内容.

Service References and its subfolders are auto-generated by the IDE. You will not create them directly. Delete that folder and anything inside there that you manually created.

要生成服务参考条目,请右键单击该项目,然后选择添加\服务参考".然后将提示您输入服务的URI.然后,IDE将自动生成连接所需的所有代码.为了确保您连接到正确的 您可以从旧项目中打开.svcmap文件之前拥有的URI.其中包含用于生成文件的URI和配置选项.如果您设置了相同的选项,那么它应该生成大约相同的代码.

To generate a service reference entry right-click the project and select Add\Service Reference. You will then be prompted for the URI to the service. The IDE will then auto-generate all the code needed to connect. To ensure you connect to the correct URI that you had before you can open the .svcmap file from the old project. Within there is the URI and configuration options that were selected to generate the files. Provided you set the same options then it should generate about the same code.

迈克尔·泰勒
http://www.michaeltaylorp3.net

Michael Taylor
http://www.michaeltaylorp3.net


这篇关于VS2013 C#.net4.5,在新解决方案中将现有服务引用添加到新项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆