如何将c#应用程序合并到vb.net应用程序 [英] how to merge c# application to a vb.net application

查看:76
本文介绍了如何将c#应用程序合并到vb.net应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我有一个用c#(windows)制作的条形码应用程序。现在我想在我的vb.net应用程序中添加它。



请告诉我该怎么做



谢谢

Hi all

i have a barcode application made in c#(windows). now i want to add that in my vb.net application.

Please tell me how to do that

Thank you

推荐答案

而不是神秘的合并(曾试图正式定义那是什么?),你应该更好地运用文明的方式,它的方式应该在.NET中使用。



使用C#应用程序,您希望在其他应用程序中重用的应用程序,作为类库程序集。你可能需要重新使用它才能使用:抽象出一些过于具体的东西,使你需要在外部程序集公共中使用的方法,属性和事件,并摆脱入口点(你静态主要方法)和其他裁员。但是,如果你不做最后一步,那么解决方案无论如何都会起作用,但它会被你的遗留物污染。你甚至不需要将程序集从.EXE重命名为.DLL - 对于.NET来说,这是完全无关紧要的。但是,从操作系统用户的角度来看,最好重命名,以避免意外尝试将此程序集运行为应用程序。但是,这种危险也不是很显着。



然后,在你的VB.NET应用程序中引用这个程序集并使用它。如果C#代码将在同一个程序集中编写,则使用代码将与代码完全相同。



甚至不要考虑单组装解决方案。它完全没有意义。



另外,请理解Visual Studio仅支持用不同语言编写的程序集,因此必须使用多个程序集。 br $> b $ b

严格来说,还有另一种方法:使用没有清单的可执行模块。您可以用不同的语言编写它们并放入一个程序集中。例如,您将拥有两个可执行文件(每个文件代表一个模块),其中只有一个代表程序集。问题是Visual Studio不支持单个程序集中的多个模块,因此您需要自定义项目文件和其他麻烦。为什么,如果可以使用不同的程序集?
-SA
Instead of mysterious "merging" (ever tried to define formally what is that?), you should better use the civilized way, the way it is supposed to be used in .NET.

Use you C# application, the one you want to reuse in your other application, as a class library assembly. You may need to re-work it to be usable: abstract out some too concrete stuff, make the methods, properties and events you need to use from outside assembly public, and get rid of the entry point (you static Main method) and other redundancies. However, if you don''t do this last step, the solution will work anyway, but it will appear contaminated with your legacy stuff. You don''t even need to rename you assembly from .EXE to .DLL — for .NET, this is totally insignificant. From the standpoint of the OS user, however, it''s better to rename, to avoid accidental attempts to "run" this assembly as application. However, this danger is also not very significant.

And then, reference this assembly in your VB.NET application and use. The using code would be absolutely identical to the code if the C# code would be written in the same assembly.

Don''t even think about a single-assembly solution. It makes no sense at all.

Also, please understand that Visual Studio supports only the assemblies written in different languages, so using more than one assemblies is a must.

Strictly speaking, there is another approach: using executable modules without manifests. You could write them in different language and put in one assembly. You would have, say, two executable files (each representing a module), only one of them representing the assembly. The problem is that Visual Studio does not support multiple modules in a single assembly, so you would need a custom project files and other hassles. Why, if you can use different assemblies?
—SA


这篇关于如何将c#应用程序合并到vb.net应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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