简体   繁体   English

Visual Studio中的多语言项目

[英]Multiple Language Projects in Visual Studio

I've recently learned of the joys of compiling projects into dlls to use them in other projects! 我最近了解到将项目编译为dll以便在其他项目中使用它们的乐趣! However, now I'm trying to streamline a process where I have two projects, one written in C# and the other in VB, where the C# project has dependencies on a dll compiled from the VB process. 但是,现在我正在尝试简化一个过程,其中有两个项目,一个用C#编写,另一个用VB编写,其中C#项目依赖于从VB进程编译的dll。

What I'm hoping I can achieve: - Have both of these projects viewable within the same VS project 我希望可以实现以下目标:-在同一个VS项目中可以同时看到这两个项目

  • Pull updates on the VB code from SVN and compile them into a dll located in a folder within the project 从SVN提取VB代码上的更新,并将其编译到项目内文件夹中的dll中

  • Not have to update my references in the C# project as I am updating the same dll in the project. 不必更新C#项目中的引用,因为我正在更新项目中的相同dll。

  • Build the C# project whenever needed, without rebuilding the VB project 在需要时构建C#项目,而无需重建VB项目

Can this be done? 能做到吗?

Thanks! 谢谢!

Is this a VB.NET project? 这是VB.NET项目吗? If so, you're in luck. 如果是这样,那么您很幸运。

1) You cannot have a Visual Studio project that uses multiple languages (unless you count ASM in C/C++). 1)您不能拥有使用多种语言的Visual Studio项目(除非您将C / C ++中的ASM计算在内)。 However, a single Visual Studio solution can have multiple projects where each project uses a different language. 但是,单个Visual Studio解决方案可以具有多个项目,其中每个项目使用不同的语言。

2) If the projects are C# and VB.NET (or F# or Managed C++ or any other language that produces a .NET assembly), there is little difference in the output assemblies of one versus the other. 2)如果项目是C#和VB.NET(或F#或Managed C ++或生成.NET程序集的任何其他语言),则一个程序集的输出程序集与另一个程序集的输出程序集几乎没有区别。 AC# project can reference an assembly built with VB.NET and vice-versa. AC#项目可以引用使用VB.NET构建的程序集,反之亦然。

3) If the projects are in the same Visual Studio solution, you can use Project References instead of Assembly References. 3)如果项目在同一Visual Studio解决方案中,则可以使用“项目引用”代替“程序集引用”。 Project References make it so that one project depends on the output of another project in the same solution. 使用项目引用可以使一个项目依赖同一解决方案中另一个项目的输出。 You establish the project reference once (in VS2015: Right-click Project => Add => Reference... => Projects => select the project to reference). 一次建立项目引用(在VS2015中:右键单击Project => Add => Reference ... => Projects =>选择要引用的项目)。 And then Visual Studio/msbuild automatically knows the correct order to build them (and whether or not to build them at all). 然后,Visual Studio / msbuild会自动知道正确的顺序来构建它们(以及是否完全构建它们)。 It's even smart enough that if you change the output location of the referenced project, you don't need to do anything to the referencing project. 甚至足够聪明,如果您更改引用项目的输出位置,则无需对引用项目做任何事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM