2

I've a Web Application project that uses VB as programming language. I want to keep using this language due I've more experience and also it works better with IntelliSense.

Anyway, now I am using Open XML SDK 2.0 Productivity Tool for generate code for the generation of a OOXML document through a given template, and this tool only generates C# code.

With the aim to mix both languages in my project, I had followed this tuto but when I try to add a new C# class, the only language that appears in the list is Visual Basic as you can see in the attached screenshot.

Does anyone know how I can fix this?

Thank you very much

Add New Item Screenshot

4
  • Looks like you don't have c# installed... Commented Oct 9, 2012 at 10:52
  • Yes, I do. I've close the project and try to create a new one, and C# appears as available. Commented Oct 9, 2012 at 10:53
  • trying not to be glib... learn c# Commented Oct 9, 2012 at 10:54
  • OK, you should put the c# into a different assembly then. You will be able to reference it from the VB project. Commented Oct 9, 2012 at 10:56

4 Answers 4

5

This is not possible; you cannot mix C# with VB.NET in the same project. When .NET compiles an assembly it can use only one compiler to do so.

What you can do, is have a solution with multiple projects (for instance one Web app and several class libraries), and then you can have each class library in the language of your choice.

Sign up to request clarification or add additional context in comments.

3 Comments

So, MSDN is lying me is this tutorial?
There is a difference between web sites and web applications which is where the confusion comes in. The tutorial is for web sites and you have a web application. Its all in the way they are compiled...
What Chris says. The Web site project in the tutotial does not get compiled to a single DLL as a Web application does. This is indeed confusing... But either way I'd separate code in different languages into their own projects anyway.
1

As others have said in general you cannot do this. The one exception is a web site project.

There is a difference between a web site project and a web application. Mainly in the way they are compiled. A web site is what the tutorial you linked talks about (note the way they say to create it via new website rather than new project and choosing web app) whereas you say above that you have a web application.

You have the option of either changing to a web site or using supplemental projects as others have suggested.

Comments

1

Mixing languages is not what I would go for.

Add a new (DLL)project to your solution that uses C# and handles your XML. Reference that C# project from your VB-app and call into it.

Clean and easy.

Comments

0

You need to install Visual Studio for c#. It looks your current installed language is vb. Here is link for downloading vs:

http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express

About using vb and c# code in same solution, its possible as long they are separated to different projects.

3 Comments

I've Visual Studio 2010 Proffesional and it's a complete installation: Office Developer tools, Visual Basic 2010, Visual C# 2010, Visual C++ 2010, Visual F# 2010, Visual Studio 2010 Team Explorer, Visual Web Developer 2010, ......
Then your screen is from vs project. Just add new c# project to solution and add reference to your vb project. Then you are ready to go.
@GregorPrimar: the whole point is he wants to add C# into the same project, not create a new project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.