Hello,
I am currently deploying an ASP.Net Website(Not Web application) and met this problem: CS0246: The type or namespace name 'MyClass' could not be found (are you missing a
using directive or an assembly reference?).
The Visual Studio I used to write my codes are Microsoft Visual Studio Community 2015. I am using an ASP.Net Website, not the Web Application. I put two CS files( e.g.SQLHelper) into the folder App_Code. When I started this project, the .NetFramework I used is .Net 4.5.2. ( Ididn't have much idea of the version of .Net Framework at that time). Later I came into realized that this may cause an issue. So when I build the website, I set the target Framework to .Net 4.0 so as to match my Virtual Host. (I did this by right click website ->property page->Build->target Framework-->choose 4.0).
As for Deployment, I used the right click-->publish Web-->publishMethod:FTP-->fill out username and password. I left the desination URL blank since I do not know how to fill it. The FTP I had is provided by Alibabacloud(I bought a Cloud Virtual Host from Alibabacloud). I already set the .Net Framework settings of my Virtual Host to ASP.NEt 4.0 Integrated mode.
The website run on my computer fine. But after deployment, when I type the logOn page in the Browser, it showed the error Website error CS0246: The type or namespace name 'UserGate' could not be found (are you missing a using directive or an assembly reference?).UserGate is the class I defined in the CS file in App_Code foler. So I add namespace MyClass to the CS File and added Using MyClass at the top of ever .aspx.cs file in my project. Then I requested the LogOn page in Browser again and found the error is "The type or namespace name 'MyClass' could not be found (are you missing a using directive or an assembly reference?". So I guess somehow the contents of App_code cannot get run.
What shall I do?
Oh, BTW, the name of my project is called TicketSystemWeb, but somehow in the Solution Explorer, Under the solution'TicketSystemWeb(1 project), it shows the earth-like image and the name TicketSystemWeb(2). It automatically added (2). I do not know whether the name caused this issue.
Below is the Web Configuration.
<?xml version="1.0"?><!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --><configuration><connectionStrings><add name="bds_dbConnectionString" (I omit the username and password here) providerName="System.Data.SqlClient"/></connectionStrings><system.web><compilation debug="false" targetFramework="4.0"><assemblies><add assembly="System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/><add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/><add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies></compilation><customErrors mode="Off"></customErrors><httpRuntime/></system.web></configuration>