Hello I have an ASP web application runs on C# as its backend that I’m trying to get running but the webpage (ran locally on my box) gives me the error message. Now the namespace the webapp is trying to reference is “using LAD.CDD.NSJ;” which are located in the App_Code folder.
The name of the files are Common.cs, Email.cs, Data.cs, and User.cs.
They all have a namespace call LAD.CDD.NSJ within the code. The previous programmers didn’t make those files into a dll and just kept it as a .cs file. I’m trying to use these files for another project but keep getting that error message.
The
App_Codefolder is a special folder in ASP.NET. ASP.NET will compile the typesApp_Codeinto an assembly which is actually separate from your web application assembly. This means, when you try and use those types from your backend code (e.g. an MVC controller), it is unable to resolve the type because those types will have aBuild Actionset toContent. With that build action, the file will not be included in the compilation of your main application.What I would recommend doing, is ditch using
App_Codebecause simply changing the build action toCompilewon’t stop ASP.NET dynamically compiling anApp_Codeassembly, so you end up with ambiguous types (i.e., the runtime doesn’t know whether to use the type compiled into your main application assembly, or the dynamic App_Code assembly.Move those files to another location, and set the Build Action (in Properties) to
Compile.