I am using asp.net 2012 and have c# class project where I would like to include some existing vb.net classes.
What would be the best way to be able to use both c# and vb.net classes?
Either convert the vb.net classes into C# or put the vb.net classes into their own assembly and add a reference to the assembly.
put the VB.NET classes in a project of its own and then reference that project, just as you would any third party control.
As already mentioned, one of the alternatives is to convert c# to vb.net or vice-versa.
You can find many pages in the internet to do that, like these ones:
http://www.developerfusion.com/tools/convert/vb-to-csharp/
http://www.developerfusion.com/tools/convert/csharp-to-vb/
If you convert the code from one language to the other make sure you test the changes properly.
If you decide to keep VB.NET code in a separate Visual Studio project and reference it in the C# code you need to ensure that the VB.NET code is CLS compliant. This is a good starting point:
Writing CLS-Compliant Code
See also:
Cross-Language Interoperability
Make C# a .NET library and include it in your VB.NET/ASP.NET project.
Follow this http://msdn.microsoft.com/en-us/library/t990ks23.aspx for more info...
Related
I just installed VS 2017 a couple of days ago.
Normally I work in C#.
However, I have one project that was written in VB.Net.
I want to pull out a selection of VB procedures and functions and put them in a static class.
However, when I try to add a new Class to the project it only gives me the option of a C# class, no VB at all.
Yes I could convert the VB code to C# but that is a lot of work and I don't want to do it since I shouldn't have to.
Has anyone encountered this and if so did you find a solution?
Thanks.
C# and VB.Net can coexist in the same solution, but not the same project. You can add a second project to your solution. Make it a VB.Net class library. Add any VB.Net modules to the new class library. Add a reference in your C# project to the VB.Net class library. Build all and enjoy!
If you do decide to translate from VB.Net to C# to keep things cleaner, I have had good luck with the code translator found here: http://converter.telerik.com/
Is there any way to use C# classes (of a project) into another java project?
Or any other possible solution for this (like conversion - example: Java Language Conversion Assistant).
Since now, thanks.
C# -> Java
CodePorting C#2Java is a web-based tool for converting C# applications and source code into Java. (http://visualstudiogallery.msdn.microsoft.com/9789645d-9b31-4033-bcb1-53dc5ff58e05)
Google give you several options
https://www.google.com/search?q=C%23+to+Java
Frequently i have to program in VB.Net and Visual C#, so it would be helpful if someone can provide with a list of Refrence for Classes of in VB.net and C#.
I mean like
My.Computer.Registry in VB Maps to Microsoft.Win32.Registry in C#.
Similarly i want a refrence of other classes.
In your example, you can use the latter in both C# and VB.NET. The former is a VB.NET "crutch" (or "shortcut", to put it nicely) so that VB developers can find stuff via IntelliSense, and are contained within a special assembly used in VB (but that can also needlessly be referenced from C#). My suggestion: don't use "My.*", use the real classes that are available from any .NET language (incl. C#) - it will make moving between languages easier and you will be able to ask BCL questions more clearly on SO.
I have to convert a C# project to VB.NET and VBA. It's a console app that uses the Microsoft Office API (Microsoft.Office.Interop.*).
My two questions:
C# -> VB.NET: .NET Reflector is a good tool for this, except that it doesn't preserve source code comments. Is there a way to do this?
.NET -> VBA: is there an automated tool to do this conversion? It would need to be a client side tool (because the code is proprietary).
The best conversion seems to be done by SharpDevelop. Open your project and from the tools menu and select convert code to. Since it has all of your c# source code it does a very good job.
There are many ways to convert C# to VB.Net; for example, try Developer Fusion.
It is not possible to automatically convert C# to VBA because the environment, language, and libraries are radically different. However, you could expose the C# code as a COM server and call it from a thin wrapper in VBA.
Answer for question #1:
You cannot use Reflector to preserve source code comments because Reflector is disassembling the compiled code, which has had all comments removed.
Consider using a commercial tool like InstantVB, which will converts C# source code into VB source code (including comments):
http://tangiblesoftwaresolutions.com/Product_Details/Instant_VB.html
You could convert the C# source code to VB.Net manually with this:
http://www.developerfusion.com/tools/convert/csharp-to-vb/
which will preserve comments. As far as automatically converting C# to VBA or VB6, I'd be willing to say that that is almost certainly going to be completely impossible. There are many aspects of C#/.Net that are not available in VBA or VB6 (like inheritance, for one).
Is is possible to mix C# and VB.NET files in one project when using SharpDevelop?
Probably not, at least not directly... you would have to use two compilers to produce one assembly, which is not supported AFAIK. However, if your final goal is to produce a single assembly, you could probably compile two separate assemblies and merge them using ILMerge
if you are trying to make a vb project, but vb doesnt have the expressions and statements you were looking for, make the two parts seperately, and convert one to the main language the program is made in. to convert it, use sharpdevelop, which is a better version of vs.net