简体   繁体   中英

Combine C# and VB.NET in a solution

I have a solution, Winforms, mainly composed from VB.NET projects (Wiforms, Constrols and business classes).

How, I added to it a WPF project, but wrote it in C#.

Actually, every time I make a modification in the WPF C# project, I need to (re)build the C#WPF project.

Is there a option to make it work like other (VB.NET) projects (accept and "see" the changes without rebuilding the C# project)?

An example:

When I reference project "R.VB" in project "M.VB", I add a method "DoTest" in the "R.VB" and use that method in "M.VB" without compile errors.

If I add "DoTest" in the C# WPF Control and try to use it in "M.VB" project, I recieve a compile error "DoTest" is not a member od "RC#Class".

C# options in my VS

在此处输入图片说明

不,C#确实支持后台编译。

If project A references project B, A can't see changes in B until project B is rebuilt.

However, if you want autocompletion and a few other tricks before recompiling referenced projects, you could use an extension that looks at your source code instead of your compiled output, such as ReSharper .

不,如果您更改了代码,则需要重新编译,至少我认为这是您要的。

if you need dynamic build you can take a look at project Roslyn

more info here

"Developers could also use the output of such software to do tasks like refactor, or reorganize, their code more easily, to add C# and Visual Basic functionality to programs written in other languages. It also adds dynamic typing to the statically typed C# and Visual Basic, allowing developers to add objects and new variables to a program on the fly."

Do you have both the VB.NET projects and your C#/WPF stuff in the same solution? They should automatically rebuild if you do. If you use an assembly reference, you need to do it by hand. As far as I know, changing the code without rebuilding in VB6-style is not supported in .NET anyway...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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