Search code examples
c#asp.netvb.netapp-code

Is it possible to add two language code files i.e. C# and VB.NET to App_Code? If so, how I could achieve this?


While adding two language code files i.e. C# and VB.NET to App_Code, got an error

 The files ... file names ... use a different language,  
 which is not allowed since they need to be compiled together.

Is there a way to add two different language files?


Solution

  • Create sub folders and put all your VB code in one folder and C# in the other. In your case you will have one for C# and the other one for VB

    You will need to modify web.config under the compilation element to include these so that the compiler will know to include them in the compilation

    <codeSubDirectories>
       <add directoryName="MyVBCode"/>
       <add directoryName="MyCSharpCode"/>
    </codeSubDirectories>