Sep 6th, 2009 | 3 Comments

Many a times you require to use both C-Sharp (C#) and Visual Basic (VB) code class files in the same project.

If you just place your both the code files in your App_Code directly this is the error you’ll see,

“The files ‘/BlogEngine.Web/App_Code/VBCode/Class1.vb’ and ‘/BlogEngine.Web/App_Code/CSCode/Extensions/BreakPost.cs’ use a different language, which is not allowed since they need to be compiled together.”

But you can get this done, here is a very simple way you can try that out,

1) First make two folders in App_code with foldernames as
- CSCode
- VBCode

2) Modify the Web.config with following code:

<compilation debug="false">
 <codeSubDirectories>
 <add directoryName="VBCode" />
 <add directoryName="CSCode" />
 </codeSubDirectories>
</compilation>
Jul 22nd, 2009 | No Comments

Another one of those problems that can stump you for a while. I often make backups of files as I progress and sometimes leave them in the website folder, this was fine with classic ASP but as I have found with ASP.Net can cause all sorts of problems.One issue I was having was trying to reference a component in my aspx page from the codebehind page and seeing the following error when trying to reference a label control:

“Label2 does not exist in the current context”

So I found that the problem was even though I renamed one of my old files it still contained the class that my codebehind was referencing (i.e. the class names were still the same) – and therefore was not seeing the newly added Label control to my new code.Shame the compiler doesn’t realise the duplication and give some indication.

Lesson: Remove any backed up files from the web folder and/or build directory to avoid pain )

Written by Ajay Matharu

July 22nd, 2009 at 11:24 pm