将VB.NET 2005项目转换为C#2008项目

时间:2021-10-08 01:40:22

Is there a tool to convert a VB.NET 2005 project to a C# 2008 project. I am trying to convert our project to VS 2008 and mostly port all the vb.NET code in some projects to C# 3.0/3.5.

是否有工具将VB.NET 2005项目转换为C#2008项目。我正在尝试将我们的项目转换为VS 2008,并且主要将某些项目中的所有vb.NET代码移植到C#3.0 / 3.5。

8 个解决方案

#1


You could check out SharpDevelop. It's an open source .NET development environment. SharpDevelop has some code conversion built in.

你可以查看SharpDevelop。它是一个开源的.NET开发环境。 SharpDevelop内置了一些代码转换功能。

#2


I had a similar decision to make with a VB.net project. Solution was a compromise, I decided to run with dual VB and C#.

我有一个类似的决定用VB.net项目。解决方案是妥协,我决定使用双VB和C#运行。

Upgrading VB.NET 2005 to 2008 is easy bit.

将VB.NET 2005升级到2008很容易。

Added CSharp and VB folders to App_Code and

将CSharp和VB文件夹添加到App_Code和

<codeSubDirectories>
<add directoryName="CSharp" />
<add directoryName="VB" />
</codeSubDirectories>

to compilation section of web.config

到web.config的编译部分

As Kev says, it's not as straight forward as you might expect, and you will likely run into unexpected issues , that make running with dual language support the best solution

正如Kev所说,它并不像你期望的那样直截了当,你可能遇到意想不到的问题,这使得使用双语支持运行成为最佳解决方案

I know this doesn't directly answer the question, but it's an alternative approach

我知道这并没有直接回答这个问题,但它是另一种方法

#3


Take a look at this.

看看这个。

http://www.developerfusion.com/tools/convert/vb-to-csharp/

Try to google term "convert vb.net project to c# project", you will find a couple of options there.

尝试谷歌术语“将vb.net项目转换为c#项目”,你会发现有几个选项。

#4


There's a tool on CodeProject called GBVB (Goodbye VB) that purports to 'flawlessly' convert VB.NET code to C# code. However the author does add a number of caveats such as the problems with ambiguous code, optional parameters etc.

CodeProject上有一个名为GBVB(Goodbye VB)的工具,它声称“完美地”将VB.NET代码转换为C#代码。然而,作者确实添加了一些警告,例如模糊代码,可选参数等问题。

Another approach could be to use Denis Bauer's Reflector.FileDisassembler .NET Reflector add-in and disassemble the compiled assemblies back to C#.

另一种方法可能是使用Denis Bauer的Reflector.FileDisassembler .NET Reflector加载项并将已编译的程序集反汇编回C#。

Handling .aspx/.asmx pages and their code-behind files would probably be a special case because you'd need to manually change the <%@ Page Codebehind="Default.aspx.cs" %> directives to point to the correct source files.

处理.aspx / .asmx页面及其代码隐藏文件可能是一种特殊情况,因为您需要手动更改<%@ Page Codebehind =“Default.aspx.cs”%>指令以指向正确的源文件。

Automatic VB.NET to C# conversion isn't really as straight forward as it initially appears to be. I've been here before and gave up on a fairly large project, there's a lot of fiddling about with specific edge cases where the translation either wouldn't compile or produced unexpected behaviour at runtime. I elected to go for a dual language solution where all new code was written in C# and older VB.NET code was ported gradually over time.

自动VB.NET到C#的转换并不像最初看起来那么简单。我以前来过这里并放弃了一个相当大的项目,有很多关于特定边缘情况的翻版,其中翻译要么在运行时不能编译或产生意外行为。我选择了双语解决方案,其中所有新代码都是用C#编写的,旧的VB.NET代码随着时间的推移逐渐被移植。

#5


hi this code answer not

嗨,这段代码答案不是

public student ()
        {}
        private string code;
            private string name;
        public string code()
        { 
        set (code=Value);
            Get return code;

        }

#6


Telerik has a converter you might want to take a look at.

Telerik有一个你可能想看的转换器。

#7


Since others have mentioned online conversion tools I've found www.carlosag.net to work the best for my code. Maybe b/c I work other 3rd party API's but it seems like a lot of the other online converter just error out if they hit a line they can't convert.

由于其他人提到了在线转换工具,我发现www.carlosag.net最适合我的代码。也许b / c我工作的其他第三方API,但似乎很多其他在线转换器只是错误输出,如果他们达到他们无法转换的线。

#8


SharpDevelop is quite good, but at my company we've found VBConversions to provide a much more complete conversion. It's a commerical app though, but for the time saved over SharpDevelop it was a no-brainer for us.

SharpDevelop非常好,但在我的公司,我们发现VBConversions提供了更完整的转换。这是一个商业应用程序,但是在SharpDevelop上保存的时间对我们来说是一个明智的选择。

As a specific example, one thing we found that SharpDevelop didn't convert correctly was VB indexes, which use curvy brackets. It seemed unable to distinguish between indexes and method calls so didn't convert the indexes to square brackets. VBConversions converted them fine. This one thing made it worth its purchase for us.

作为一个具体的例子,我们发现SharpDevelop没有正确转换的一件事是VB索引,它使用曲线括号。它似乎无法区分索引和方法调用,因此没有将索引转换为方括号。 VBConversions转换它们很好。这一件事让我们值得购买。

It looks like Tangible Software have a very similarly product to VBConversions, but I don't have any experience with it. Jon Skeet suggested it though, so it must be pretty good.

看起来有形软件与VBConversions的产品非常相似,但我对它没有任何经验。 Jon Skeet虽然提出了这个建议,但一定非常好。

#1


You could check out SharpDevelop. It's an open source .NET development environment. SharpDevelop has some code conversion built in.

你可以查看SharpDevelop。它是一个开源的.NET开发环境。 SharpDevelop内置了一些代码转换功能。

#2


I had a similar decision to make with a VB.net project. Solution was a compromise, I decided to run with dual VB and C#.

我有一个类似的决定用VB.net项目。解决方案是妥协,我决定使用双VB和C#运行。

Upgrading VB.NET 2005 to 2008 is easy bit.

将VB.NET 2005升级到2008很容易。

Added CSharp and VB folders to App_Code and

将CSharp和VB文件夹添加到App_Code和

<codeSubDirectories>
<add directoryName="CSharp" />
<add directoryName="VB" />
</codeSubDirectories>

to compilation section of web.config

到web.config的编译部分

As Kev says, it's not as straight forward as you might expect, and you will likely run into unexpected issues , that make running with dual language support the best solution

正如Kev所说,它并不像你期望的那样直截了当,你可能遇到意想不到的问题,这使得使用双语支持运行成为最佳解决方案

I know this doesn't directly answer the question, but it's an alternative approach

我知道这并没有直接回答这个问题,但它是另一种方法

#3


Take a look at this.

看看这个。

http://www.developerfusion.com/tools/convert/vb-to-csharp/

Try to google term "convert vb.net project to c# project", you will find a couple of options there.

尝试谷歌术语“将vb.net项目转换为c#项目”,你会发现有几个选项。

#4


There's a tool on CodeProject called GBVB (Goodbye VB) that purports to 'flawlessly' convert VB.NET code to C# code. However the author does add a number of caveats such as the problems with ambiguous code, optional parameters etc.

CodeProject上有一个名为GBVB(Goodbye VB)的工具,它声称“完美地”将VB.NET代码转换为C#代码。然而,作者确实添加了一些警告,例如模糊代码,可选参数等问题。

Another approach could be to use Denis Bauer's Reflector.FileDisassembler .NET Reflector add-in and disassemble the compiled assemblies back to C#.

另一种方法可能是使用Denis Bauer的Reflector.FileDisassembler .NET Reflector加载项并将已编译的程序集反汇编回C#。

Handling .aspx/.asmx pages and their code-behind files would probably be a special case because you'd need to manually change the <%@ Page Codebehind="Default.aspx.cs" %> directives to point to the correct source files.

处理.aspx / .asmx页面及其代码隐藏文件可能是一种特殊情况,因为您需要手动更改<%@ Page Codebehind =“Default.aspx.cs”%>指令以指向正确的源文件。

Automatic VB.NET to C# conversion isn't really as straight forward as it initially appears to be. I've been here before and gave up on a fairly large project, there's a lot of fiddling about with specific edge cases where the translation either wouldn't compile or produced unexpected behaviour at runtime. I elected to go for a dual language solution where all new code was written in C# and older VB.NET code was ported gradually over time.

自动VB.NET到C#的转换并不像最初看起来那么简单。我以前来过这里并放弃了一个相当大的项目,有很多关于特定边缘情况的翻版,其中翻译要么在运行时不能编译或产生意外行为。我选择了双语解决方案,其中所有新代码都是用C#编写的,旧的VB.NET代码随着时间的推移逐渐被移植。

#5


hi this code answer not

嗨,这段代码答案不是

public student ()
        {}
        private string code;
            private string name;
        public string code()
        { 
        set (code=Value);
            Get return code;

        }

#6


Telerik has a converter you might want to take a look at.

Telerik有一个你可能想看的转换器。

#7


Since others have mentioned online conversion tools I've found www.carlosag.net to work the best for my code. Maybe b/c I work other 3rd party API's but it seems like a lot of the other online converter just error out if they hit a line they can't convert.

由于其他人提到了在线转换工具,我发现www.carlosag.net最适合我的代码。也许b / c我工作的其他第三方API,但似乎很多其他在线转换器只是错误输出,如果他们达到他们无法转换的线。

#8


SharpDevelop is quite good, but at my company we've found VBConversions to provide a much more complete conversion. It's a commerical app though, but for the time saved over SharpDevelop it was a no-brainer for us.

SharpDevelop非常好,但在我的公司,我们发现VBConversions提供了更完整的转换。这是一个商业应用程序,但是在SharpDevelop上保存的时间对我们来说是一个明智的选择。

As a specific example, one thing we found that SharpDevelop didn't convert correctly was VB indexes, which use curvy brackets. It seemed unable to distinguish between indexes and method calls so didn't convert the indexes to square brackets. VBConversions converted them fine. This one thing made it worth its purchase for us.

作为一个具体的例子,我们发现SharpDevelop没有正确转换的一件事是VB索引,它使用曲线括号。它似乎无法区分索引和方法调用,因此没有将索引转换为方括号。 VBConversions转换它们很好。这一件事让我们值得购买。

It looks like Tangible Software have a very similarly product to VBConversions, but I don't have any experience with it. Jon Skeet suggested it though, so it must be pretty good.

看起来有形软件与VBConversions的产品非常相似,但我对它没有任何经验。 Jon Skeet虽然提出了这个建议,但一定非常好。