if you get this error:The files use a different language,which is not allowed since they need to be compiled together Solution in asp.net ?
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>
<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.
Comments
Post a Comment