Paks
Paks

Reputation: 1470

Getting Error when start to Debug

When I debug my ASP.NET Web Site I get the following error:

The files "/BookIt.Web/App_Code/VBCode/vCalendar.vb" and "/BookIt.Web/App_Code/CSCode/WebGrid/user/BenutzerCollection.cs" use different languages​​. This is not allowed, because they must be compiled together.

I don't know how to fix that.

Someone can help me?

Stacktrace:

[HttpException (0x80004005): Die Dateien "/BookIt.Web/App_Code/VBCode/QueryStringModule.vb" und "/BookIt.Web/App_Code/CSCode/Webgrid/Dienstleistung/Servicegruppe.cs" verwenden unterschiedliche Sprachen. Dies ist nicht zulässig, weil sie gemeinsam kompiliert werden müssen.]
   System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() +452
   System.Web.Compilation.BuildProvidersCompiler.PerformBuild() +42
   System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +640
   System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +125
   System.Web.Compilation.BuildManager.CompileCodeDirectories() +265
   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +320

[HttpException (0x80004005): Die Dateien "/BookIt.Web/App_Code/VBCode/QueryStringModule.vb" und "/BookIt.Web/App_Code/CSCode/Webgrid/Dienstleistung/Servicegruppe.cs" verwenden unterschiedliche Sprachen. Dies ist nicht zulässig, weil sie gemeinsam kompiliert werden müssen.]
   System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +58
   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +512
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +729

[HttpException (0x80004005): Die Dateien "/BookIt.Web/App_Code/VBCode/QueryStringModule.vb" und "/BookIt.Web/App_Code/CSCode/Webgrid/Dienstleistung/Servicegruppe.cs" verwenden unterschiedliche Sprachen. Dies ist nicht zulässig, weil sie gemeinsam kompiliert werden müssen.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8921851
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +259

Upvotes: 0

Views: 538

Answers (1)

J. Steen
J. Steen

Reputation: 15588

Simply put, you can't mix languages in the same project. You can have a VB.NET project and a C# project in the same solution, one referencing the other. You use one compiler to compile a single project.

You can have code from several languages in the same project if the other languages are included as Build Action: Content, not Build Action: Compile. Of course, you won't be able to use classes and logic from those files.

Code files in the App_Code folder will, however, be automatically compiled

http://msdn.microsoft.com/en-us/library/t990ks23(v=vs.80).aspx

Because the source code in the App_Code folder is compiled into a single assembly, all the files in the App_Code folder must be in the same programming language. For example, the App_Code folder cannot include source code in both Visual Basic and C#.

However, you can configure your Web application to treat subfolders of the App_Code folder as separate compilable units. Each folder can then contain source code in a different programming language. The configuration is specified by creating a codeSubDirectories element in the compilation element of the Web.config file and adding a reference to the subfolder. The following example illustrates how you would configure subfolders named VBCode and CSCode to compile into separate assemblies:

<compilation debug="false">
    <codeSubDirectories>
        <add directoryName="VBCode" />
        <add directoryName="CSCode" />
    </codeSubDirectories>
</compilation>

Upvotes: 4

Related Questions