如何将C#.NET与VB.NET合并 [英] How to merge C#.NET with VB.NET

查看:94
本文介绍了如何将C#.NET与VB.NET合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编码员,

在我的Windows应用程序中,我有一个VB.NET项目。在那,我需要包括从某些设备捕获的图像。我有该设备的源代码,它位于C#.Net ...



如何在一个项目中添加两者?



我可以同时运行两个应用程序(C#和VB)。但问题是,我需要以VB.NET项目中生成的ID的名义保存该图像。我只想在我的C#项目中单独使用该ID。

有没有想法切换我的问题?

建议欢迎...

hi coders,
In my windows application, i have a VB.NET project. In that, i need to include an image capturing from some device. I have source code for that device which is in C#.Net...

How can i add both in a single project??

I can run both applications(C# and VB) side by side. But the problem is, i need to save that image in the name of an "ID" generated in VB.NET project. I just want that ID alone inside my C# project.
Is there any idea to toggle my problem??
Suggestions welcomes...

推荐答案

可能需要一个包含两个项目的解决方案 - 一个是C#,另一个是VB。例如,如果VB项目是您的主应用程序并且C#项目编译为类库,您应该能够将C#项目的引用添加到VB项目中,然后非常容易地从VB代码调用C#代码(所以方法在C#中,ID作为其参数之一,以便您可以从VB传递参数 - 或者获取C#以捕获图像并将其返回并让VB进行排序以适当地保存它)。正确定义每个项目中的命名空间,并将相关的Imports语句添加到VB代码中以引用C#项目命名空间。



AFAIK你不能混合VB和C#在同一个项目中。
Probably need one solution with two projects in it - one C#, the other VB. If, say, VB project is your main app and C# project compiles to a class library, you should be able to add a reference to the C# project to your VB project and then make calls from VB code to C# code very easily (so method in C# that has ID as one of its arguments so that you can pass the parameter from VB - or get C# to capture image and return it and let VB sort out saving it appropriately). Define the namespaces in each project properly and, add the relevant Imports statements to your VB code to reference the C# project namespace.

AFAIK you can''t mix VB and C# in the same project.


将VB代码解压缩到一个新的DLL项目中,使VB用户界面保持不变。

然后你可以调用这些函数来自VB程序和C#的DLL。



要做到这一点:

1)在解决方案资源管理器窗格中右键单击您的解决方案。

2)选择Add..New Project

3)从VB列表中选择项目类型为类库。

4)正确设置名称。

5)按OK。



导入代码,然后关闭 - 你必须添加一个参考到VB和C#项目中的DLL项目命名空间等。
Extract the VB code into a new DLL project, leaving the VB user interface the same.
You can then call the functions in the DLL from both the VB program and the C#.

To do this:
1) Right click your solution in the Solution Explorer pane.
2) Select Add..New Project
3) Select Project type as "Class library" from the VB list.
4) Set the name appropriately.
5) Press OK.

Import the code, and off you go - you will have to add a reference to the DLL project namespace in both your VB and C# projects and so forth.


我刚刚回答了类似的问题,请参阅:

如何将c#应用程序合并到vb.net应用程序 [ ^ ]。



-SA
I just answered a similar question, please see:
how to merge c# application to a vb.net application[^].

—SA


这篇关于如何将C#.NET与VB.NET合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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