When I test my web site (asp.net c# .net4) on the localhost, everything works fine.
However, when I publish it to my webserver, I get the error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'MyWhateverNamedHere' could not be found (are you missing a using directive or an assembly reference?)
My code file (MyWhateverNamedHere.cs) lives in my App_Code folder, which IS moved to the webserver.
I have read where people move codefiles out of the App_Code folder. Didn't work for me. I tried giving them namespaces, and static references and just about everything I can think of. Then I found a solution that said Build Phases > Compile. But that's not an option for "web sites".
Any help?
Related
I am working on an ASP.NET website and as part of the website I created a file called Global.cs which is used to hold all my helper classes. However, unfortunately, I am constantly getting errors saying there has been a problem while compiling this file. All the classes inside the file are included in single namespace - "Global".
When using it 'inline' eg. Global.SomeStaticClass.Method() :
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'Global' does not exist in the current context
When using "using Global;" directive:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'Global' could not be found (are you missing a using directive or an assembly reference?)
As suggested in many posts, I tried including the class in App_Code folder of my project and the namespace, "Global", is detected by the Visual Studio (no errors when adding "using Global;" directive, or when using it inline "Global.Class.Method()". However, it still fails whenever I try to access the page in the browser.
I could not find a simple solution to my problem and decided that the easiest and the most time efficient solution will be to convert my Website project to a Web Application project. You can read how to convert your Website to a Web Application at: https://blogs.msdn.microsoft.com/webdev/2009/10/29/converting-a-web-site-project-to-a-web-application-project/
With the project converted to a Web App I was able to attach my class files after compiling them to a DLL library, as it did not accept any uncompiled files inside App_Code folder by throwing an exception.
The directory '/website/App_Code/' is not allowed because the application is precompiled.
If you encounter the same issue, you can learn how to compile C# files using Developer Command Prompt here: https://msdn.microsoft.com/en-us/library/78f4aasd.aspx
My project is an ASP.Net website that connects to an SQL database.
It compiles fine locally in Visual Studio, but once it is hosted (myWindowsHosting.com) it throws this error:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'IDefaultView' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 9: namespace HFDB2
Line 10: {
Line 11: public partial class Default : System.Web.UI.Page, IDefaultView
Line 12: {
Line 13: public event EventHandler btnNextClicked;
In this example I am trying to implement an Interface to the Default webform. But a similar error occurs for any class I try to reference.
Why cant my project find any classes once it is hosted?
Does it have anything to do with my folder structure?
My classes are not in an App_Code folder because apparently you dont need one for websites. I tried putting them in an App_Code folder anyway, but it gave a different error.
Note that I uploaded everything you see inside my project folder to the host.
I was deploying my application incorrectly. As Ben Robinson's comment says:
Never deploy source code. The easiest way of creating your collection of files to deploy is to use the Publish option in visual studio.
I am following the answer below to make globalization happen.
Globalization in ASP.Net MVC 3
However, I have failed.
I am getting back a compilation fail error for the following line:
using ViewResources;
I have created Resources folder, created 2 resource file per locale(ViewResources.resx, ViewResources.en.resx), added
<add namespace="ViewResources" />
to web.config in Views folder and it fails like a boss.
Compiler Error Message: CS0246: The type or namespace name 'ViewResources' could not be found (are you missing a using directive or an assembly reference?)
You need to specify that the file type as 'embedded resource', to do this select the file in solution explorer, right click-> select properties, change build action to 'embedded resource'
I am using DynamicPDF creator, Visual Studio 2010, and IIS 7.
On my local machine, the line "using ceTe.DynamicPDF;" and subsequent lines work fine, but
when I try to load the page on my server, I get the following error:
"Compiler Error Message: CS0246: The type or namespace name 'ceTe' could not be found (are you missing a using directive or an assembly reference?)"
I have added the .dll file as a reference, and intellisense even works.
I am wondering if it is a problem with assemblies. Any ideas about what I should do to get this working on my server?
May be you lost some of dlls, you can check dll which contains ceTe. ... by dependency walker.
I created my first WCF RESTful service with just one GetData, and it works perfectly in localhost, but when I add it to a hosting environment, I get:
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0234: The type or namespace name 'ServiceModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Does this mean that I need to place the DLL file in the GAC to this work? Shouldn't it work in the BIN folder of my service?
Here is how my service folder looks like:
Service.svc
Service.svc.cs
web.config
BIN
Microsoft.ServiceModel.Web.dll
Microsoft.ServiceModel.Web.pdb
MyService.dll
MyService.pdb
PROPERTIES
AssemblyInfo.cs
What can I do in order to make this work?
I had the same problem when I first tried to create a virtual directory directly in IIS 7.5, prior to publishing my RESTful web service to this folder.
The solution for me was to use Visual Studio 2008 (Project Properties / Web tab / "Use IIS Server") to choose the folder, and then the "Create Virtual Directory" button on the same tab to create the virtual directory. Everything then worked OK.