Can I use C# code in a VB project?

D

Diego F.

Is it possible to use directly C# code into a VB project?

If not, is there any tool to convert from C# to VB.NET?
 
J

Juan T. Llibre

re:
Is it possible to use directly C# code into a VB project?

No. Only one language per project is permitted.

You can, however, VB project(s) and C# project(s) in a single solution.

You can also do a command-line compilation of one of your projects
and add a reference to that assembly ( those assemblies ) in your other project.

re:
If not, is there any tool to convert from C# to VB.NET?

This free online resource works pretty good :
http://www.developerfusion.com/utilities/convertvbtocsharp.aspx
Notice that you can go both ways.

If you prefer a desktop program,
the free SharpDevelop editor has a nifty conversion feature :

http://www.icsharpcode.net/OpenSource/SD/

It will *only* translate *.vb and *.cs files, though.
 
K

Kevin Spencer

Hi Diego,
Is it possible to use directly C# code into a VB project?

With Visual Studio.Net 2005 only, you can do this, not with previous
versions.
If not, is there any tool to convert from C# to VB.NET?

Not any good ones.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.
 
G

Guest

We sell Instant VB, a C# to VB.NET converter. Download the Demo Edition at
www.instantvb.com.

It's the only high-quality C# to VB.NET converter that:
1. Converts entire projects.
2. Converts ASP.NET pages.
3. Has a fully-supported demo.

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter
 
D

Diego F.

I'm using VS 2005 beta1. I add files, but it doesn't recognize the namespace
in VB classes.

In fact it is a complete project and I could generate the dll, but then I
have problems running in a network project. It runs locally, but when moving
to the server it throws security exceptions.
 
K

Kevin Spencer

You're right, David. I'm guilty of making an assumption. I should have said
"not any good ones that I know of." And now I'm not so sure. Your app may
indeed be capable of doing a very good direct translation. I wouldn't use
such a thing, as there are optimizations that can be performed when porting,
but these are not absolutely necessary, and it may well prove quite useful
to many developers.

Thanks for keeping me straight!

--

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.
 
K

Kevin Spencer

Hi Diego,

I did cover the security exception you described in my reply to your other
thread about the exception. that is a simple Assembly Trust issue.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top