[英]2 projects 1 solution- sharing classes?
I am new to windows mobile development and also Visual Studio. 我是Windows移动开发和Visual Studio的新手。
I am developing a web service as well as a mobile application. 我正在开发一个Web服务以及一个移动应用程序。 I have the 1 solution, but 2 different projects. 我有1个解决方案,但有2个不同的项目。
I have created a class in the web service (say project 1), but want to be able to use this class in the mobile application (say project 2). 我在Web服务中创建了一个类(比如项目1),但希望能够在移动应用程序中使用这个类(比如项目2)。
Do I have to basically create a copy of it and reference it in the other project? 我是否必须基本上创建它的副本并在其他项目中引用它?
No, you do not need to create copy. 不,您不需要创建副本。 Instead, add a reference to project1
in the project2
. 而是在project2
添加对project1
的project2
。
Right-click [References->Add Reference...] in project2
, pick the "Projects" tab, select project1
, and click [OK]. 右键单击project2
[References-> Add Reference ...],选择“Projects”选项卡,选择project1
,然后单击[OK]。
make your common class as a class library and save it in the form of .dll 将您的公共类作为类库并以.dll的形式保存
whenever you require that class just add its reference to your project and use it :) 每当你需要该类只是添加它对你的项目的引用并使用它:)
This is called re-use one of the best feature of OOPS 这被称为重用OOPS的最佳功能之一
it defeats the purpose of SOA... It becomes Tightly coupled project. 它挫败了SOA的目的......它变成了紧密耦合的项目。 One should not add.. Two different layers.. "add as a reference". 一个不应该添加..两个不同的层..“添加作为参考”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.