简体   繁体   中英

Missing Linq to SQL namespace in Visual Studio 2012 Web Site Project

The hosting provider for one of the web sites I manage has forced us to only be able to modify the site as a web project instead of as a web application. When it was initially a web application it was working fine, but after converting to a web site project I had many issues involving missing namespaces and references and was able to resolve them by placing all of my libraries inside of the top-level App_Code folder of the web site. I have one last issue with my linq-to-sql class - in Visual Studio the class is recognized now that it's in the top level App_Code folder, but when I call a page which references it I get the following error:

The type or namespace name 'LIFH_IntakesDataContext' could not be found (are you missing a using directive or an assembly reference?)

Initially there was no namespace whatsoever, but in my attempts to fix this I addded a "LIHS" namespace and placed the Data Context within that:

在此处输入图片说明


Here are the references for the site:

在此处输入图片说明




And here is the Build configuration: 在此处输入图片说明




And, here is my directory structure (Linq-to-SQL class is referenced in the circled "reports.aspx" page): 在此处输入图片说明




Code in reports.aspx:
在此处输入图片说明

Both the master page and the reports page are both in the LIHS namespace.

I am developing on Visual Studio 2012 and the application pool is set to .NET 2.0. The hosting provider does not allow anything above 2.0.

I have researched and found many references to my issue but most of them solve the problem by converting to a web application, which I cannot do, or by changing the target framework or by using a namespace, which I have done, but to no avail. I would appreciate any insight on this.

Pay Attention: Linq is only available in .Net 3.5 and later
If you are using .net 2.0 it wont work.

You can see it in your screenshot.

Hope it helps.
Mike

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM