将 C# WinForms 应用程序转换为程序集?
我有一个运行良好的 C# WinForms 应用程序。现在我想将其转换为程序集并在 ASP.NET Web 应用程序中使用它。
如何选择要引用的 DLL?
I have a C# WinForms application which is running fine. Now I want to convert it to an assembly and use it in an ASP.NET Web application.
How do I choose which DLLs to reference?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这取决于您要使用哪些类和方法。如果它们在 exe 中,您只需将 a.exe 重命名为 a.dll 即可。然后可以添加a.dll作为引用,并且您可以使用公共类。
值得注意的是,WinForms 应用程序中使用的许多内容对于 ASP.NET 应用程序来说是不可行或不适用的,并且可能导致严重的性能问题。这是因为 WinForms 和 ASP.NET 具有不同的流程模型。在它咬你之前要注意这一点。
It depends on which classes and methods you want to use. If they are in the exe, you can simply rename a.exe to a.dll. Then a.dll can be added as reference, and you can consume the public classes.
Noticeably that many things used in WinForms applications are not feasible or applicable to ASP.NET applications and can lead to serious performance issues. This is because WinForms and ASP.NET have different process models. Pay attention to that before it bites you.
您知道 ASP.NET 允许您使用 C# 代码吗?听起来您只需要重新考虑应用程序的 GUI 部分以供 Web 使用,然后就应该设置好了。
这可能很容易,也可能不容易。但是,如果您编写的代码充分分离了用户界面和实际执行(或业务)逻辑,那么它应该很容易。
You know ASP.NET allows you to use C# code right? Sounds like you just need to reconsider the GUI portion of the app for web usage and then you should be set.
This may or may not be easy. But if you wrote your code with an adequate separation of user interface and actual doing (or business) logic, then it should be easy enough.
将 yourapp.EXE 重命名为 yourapp.DLL,并将其作为对任何 .Net 应用程序(无论是 asp.net Web 还是 Windows)的引用。 .Net 中编译形式的任何内容都包含 MSIL,它是从任何 .net 应用程序引用的公平候选者。只需确保应用程序还引用 EXE 使用的依赖程序集和库即可。例如,System.Windows.Forms 等。
Rename the yourapp.EXE to yourapp.DLL and it as reference to any .Net application be it asp.net web or windows. Anything in compiled form in .Net contains MSIL which is a fair candidated for being referenced from any .net application. Just make sure the application also references dependant assemblies and libraries used by the EXE. Like, System.Windows.Forms, etc..