将Windows应用程序转换为类库(dll) [英] Convert Windows application to Class Library(dll)

查看:176
本文介绍了将Windows应用程序转换为类库(dll)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个Windows应用程序,其中有6种形式.

我想将项目转换为仅包含一个exe文件,其余为dll文件,这样以后如果我有任何进一步的更改,我将仅更改dll文件.

我尝试将应用程序类型更改为类库,但是它不起作用,它显示错误

为了调试此项目,请在解决方案中添加一个引用库项目的可执行项目".

感谢详细的逐步说明,我是.net

Hi,

I have a windows application with 6 forms in it.

I want to convert the project such that it should have only one exe file and the remaining are dll files so that if at all I have any further changes in future I will only change the dll file.

I tried changing the application type to class library but it is not working, it is showing error

"In order to debug this project add an executable project to the solution which references to the library project"

Detail step by step explanation is appreciated I am new to .net

推荐答案

Hi,
的新手.
您的解决方案将无法运行库项目,它可以编译并为其生成链接库(dll).您可以将获胜表格与业务逻辑隔离,然后将业务逻辑放入类库中,并在Windows应用程序中引用受尊敬的功能.我相信您会实现您的目标.

问候,
Hi,

Your solution would not be able to run the library project, it can compile and generate linked library (dll) for it. You can segregate your win forms from business logic and put the business logic in the class library and refer the respected functions in Windows Application. I believe that you solve your purpose.

Regards,
Sushant.


首先,确定业务逻辑,数据层和应用程序中的表示/应用程序层逻辑.以后,仅将Presentation层逻辑保留在Windows窗体中.在下一步中,将项目的类库"类型添加到您的解决方案中.将所有业务层逻辑移至业务层项目.我建议如果您也可以隔离数据层,那将是一件好事,并且代码将更易于维护.稍后,除非您的应用程序具有多个启动项目,否则您将必须将应用程序层项目"(即Windows Form Project)设置为启动项目.然后,构建类库,并将引用添加到Windows Form Project.现在,在编写业务级别逻辑的地方,您将不得不用对业务层的函数调用(即类库函数)来代替它.这样可以减少代码冗余,并且可以通过共享DLL轻松重用相同的代码.

我希望这种解释对您有所帮助.
First, identify the Business Logic, Data Layer & Presentation/Application Layer logic in your application. Later, keep only the Presentation layer logic in your Windows Forms. In the next step, add a Class Library type of Project to your Solution. Move all the Business Layer logic to the Business Layer project. I would suggest if you could segregate the Data Layer as well, it would be good and code would be more maintainable. Later on, you would have to set the Application Layer Project i.e. Windows Form Project as start-up Project, unless your application has multiple start-up projects. Then, build the Class Library and add the refrence to Windows Form Project. Now, in the place where you had written your business level logic, you would have to replace it with the function calls to the Business Layer i.e. the Class Library functions. This would reduce the code redundancy and the same peice can be easily reused by sharing the DLL.

I hope this explanation is of some use to you.


要在Visual Studio中执行类库逻辑,您需要:

1.将Windows应用程序项目添加到解决方案.
2.创建一个从新项目到现有类库项目的引用.
3.将代码添加到调用现有类库项目的新Windows应用程序项目中.例如.在表单上按一个按钮,然后将所需的代码放在其后.

如果这些步骤中的任何一个需要更多说明,那么我可以更详细地介绍.

-Rd
To execute your Class Library Logic in Visual Studio, you need to:

1. Add a Windows Application project to the solution.
2. Create a Reference from the new project to the existing Class Library Project.
3. Add Code to the new Windows Application Project that invokes the existing class library project. E.g. Stick a button on a form and put the code you need behind that.

If any of these steps need more explaination then I can go into more detail.

-Rd


这篇关于将Windows应用程序转换为类库(dll)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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