Compiling VB.Net and C# Code in an Application

Posted: March 4, 2011 in ASP.Net

Sometimes you might be working on an application that has both VB.Net and C# code in the App_Code folder. For example, you might have VB.Net code in a folder called App_Code | VB_Code and C# code in a folder called App_Code | CS_Code.

When you go to build the application, you might get the following error:
The files ‘/Application_Folder/App_Code/VB_Code/Code_Page.vb’ and ‘/Application_Folder/App_Code/CS_Code/Code_Page.cs’ use a different language, which is not allowed since they need to be compiled together.

To fix this you will have to make the following changes in your Web.config file:

<compilation debug="true">
  <codeSubDirectories>
    <add directoryName="VB_Code"/>
    <add directoryName="CS_Code"/>
  </codeSubDirectories>
  <assemblies>
  ...
  ...
  ...
  </assemblies>
</compilation>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s