Introduction: In this article I am
going to explain How to solve the error/exception “The files use a different
language, which is not allowed since they need to be compiled together”. In previous articles i explained The GridView 'GridView1' fired event PageIndexChanging which wasn't handled Error solution in asp.net and Solution to FileUpload control is not working in UpdatePanel and The SelectCommand property has not been initialized before calling 'Fill' Gridview error solution and How to Solve Error Control 'GridView1' of type 'GridView' must be placed inside a form tag with runat=server and How
to solve WebForms UnobtrusiveValidationMode requires a
ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping
named jquery(case-sensitive).
Click on image to enlarge |
Description: While working on
asp.net application I created web services in two different languages i.e. C#
and Vb.Net. The code behind file of the web services goes to App_Code folder by
default.When I run the application I got the error “The files use a different
language, which is not allowed since they need to be compiled together” as
shown in image.
I searched for the solution to
this problem on google search and then find the appropriate solution. Actually
this error/exception occurs due to compiling two different languages together (in
our case C# and VB.net).
Solution Implementation: The solution to this error is to create separate
folder for each language code file. E.g. create a sub folder in App_Code folder
and name it “CsCodes” and place the C# code files in this folder. Similarly create
another sub folder in the App_Code folder and name it “VbCodes” and place the
VB.Net code files in this folder. Now a little configuration is to be made in
web.config file. Open web.config file and in the <complilation> tag write
the following lines as:
<compilation debug="true">
<codeSubDirectories>
<add directoryName="CsCodes"/>
<add directoryName="VbCodes"/>
</codeSubDirectories>
</compilation>
Note:
Here codeSubDirectories maps to
App_Code folder and directoryName maps to the sub folders created in the App_Code folders
(in our case CsCodes and VbCodes)
Now run the application. It will
work.
Now over to you:
"If you like my work; you can appreciate by leaving your comments,
hitting Facebook like button, following on Google+, Twitter, Linked in and
Pinterest, stumbling my posts on stumble upon and subscribing for receiving
free updates directly to your inbox . Stay tuned and stay connected for more
technical updates."
If you have any question about any post, Feel free to ask.You can simply drop a comment below post or contact via Contact Us form. Your feedback and suggestions will be highly appreciated. Also try to leave comments from your account not from the anonymous account so that i can respond to you easily..