I’m developing a new functionality for web site project with VB.NET default language in VS 2008. As my preferred language is C# I create subfolder for C# code in the App_Code folder and add appropriate codeSubDirectories element to web.config file. The problem is that I can’t refer VB.NET classes in my C# code. All VB.NET classes and structures are placed in global namespace in the App_Code. But even if I place some VB.NET class in the same namespace I’ve use for my classes in C#, I still can’t use them. Also, I’ve try to move my class to global namespace but this also doesn’t help me.

Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
From the documentation for codeSubDirectories:
The build order is inferred from the top-down order of the codeSubDirectories collection. The App_Code directory is built last.
Which implies that when your C# code is being compiled, the VB code hasn’t been compiled at that point. You might try and separate base classes, etc, and put them in an earlier subdirectory or into a compiled class library, but I’d probably recommend just writing your code in VB – it’s not that tricky to write in one when you’re used to the other – the framework is still the framework.
Method 2
Create two folders under App_Code folder named CSCode and VBCode. Move your respective files to respected folders
Add below code in web.config file:
<codeSubDirectories>
<add directoryName="CSCode"></add>
<add directoryName="VBCode"/>
</codeSubDirectories>
and then try…
-Rakesh
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0