1
votes

I'm trying to figure out how to get mixed-language support working in Visual Studio 2008. In my app_code folder, I've created two subfolders (CS, VB), and added the following to the web.config file:

<compilation>
  <codeSubDirectories>
    <add directoryName="VB" />
    <add directoryName="CS" />
  </codeSubDirectories>
</compilation>

The main application is a VB.NET Web application (with a .vbproj file).

Any time I attempt to open a C# file from the app_code\cs folder, it treats the file as Visual Basic for compilation and syntax checking purposes. It still tries to build the classes in the CS folder as though they were Visual Basic. (The extension on these classes is, indeed, .cs.)

Any help figuring this out would be greatly appreciated.

2
I wasn't aware that you could mix languages within a project in VS. stackoverflow.com/questions/196677/…RQDQ
@Mike: I think you have a web site and not a web application project. Is that correct?John Saunders
@John, To be perfectly honest, I'm not entirely certain. Is there a way for me to tell definitively?Mike Hofer
@Mike: do you have a .csproj or .vbproj file? If so, then you've got a Web Application Project (which is a Good Thing).John Saunders
@Mike Hofer - is this an academic exercise (i.e. "Can it be done") or is this a practical question ("I want to use this approach in a project"). Either is fine, just curious which it is.RQDQ

2 Answers

2
votes

I think the language is defined at the project level. You could always put your C# files into a separate C# class library project and then reference that project from your web application in Visual Studio.

0
votes

As already stated in the comments, you are using a Web Site project instead of a Web Application project. The Web Site project is there for backwards compatibility and should not be used for new application development.

If you use a Web Application you can mix and match .cs & .vb class files in the project. No configuration is necessary.

http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx#wapp_topic5