Missing Linq to SQL namespace in Visual Studio 2012 Web Site Project - asp.net

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

Related

App_Code folder not recognized in "WebSite" project

I built a Web Site project (not Web Application) in Visual Studio 2017. I have a couple of generic classes in App_Code folder which are required in many Code Behind pages. It works perfectly in my local environment. But, when I upload them to the server, I get following compilation error.
CS0246: The type or namespace name 'UserInfo' could not be found (are you missing a using directive or an assembly reference?)
I created the App_Code folder by right clicking on the project; and even those classes were created there (not copied from anywhere outside).
Now, when I look at the solutions here, people are often mistaken Web Site with Web Application. In Website you cannot change the "build" to Compile; you don't even see the "build" option under class properties menu. OR my Visual Studio hiding that option from me?
Can anyone help me out please?
How are you uploading to server? Simply XCopy or Publish? Try publishing. It should solve the issue.

What default dll's are imported into an asp.net webforms project

I've inherited a legacy code base that doesn't currently compile and has no project or solution file (there are multiple repositories including winforms and asp.net).
I'm not certain what .net version the original code was written in, nor what the project template was, although I know some are web forms.
I'm re-creating new solution and project files to import the code into, but need to find some of the default dll's included in old Visual Studio project templates (e.g. webforms).
Any ideas where I might find this information?
Anyone know an MSDN link with this on it?
P.S. I don't have access to the production code, although it is running in production.

F# the namespace or module 'XXXX' is not defined

I'm trying to create a basic ASP.net f# application and when I'm trying to reference the Youtube .net API I'm getting a "The namespace or module 'Google' is not defined" in my code behind file.
I've used the default ASP web forms template in Visual Studio, removed all of the contents, then loaded in the examples from Expert F#, Chapter 14. The default examples run fine, the problem only occurs when loading the Google API. The API works fine when I load it through an f# console application.
The first few lines behind file looks like:
#light
namespace MyASPApp
open System
open System.Web
open System.Web.UI
open System.Web.UI.WebControls
open Google.YouTube
Can anyone think of a resolution to the problem, or anything I could check to understand why its not picking up the Google API?
The Google assembly may require that the application not use the Client Profile, which is the default in VS 2010. Try editing the project settings and changing the Target Framework property.
Did you check which version of .NET Framework that google assembly is built for? If it .NET 3.5 or .NET 4.0? If that is not set properly too this will occur.
-Fahad

What is my problem with ASP.NET pubslishing?

I am done testing my site and I want to upload it to a site like this
http://www.university.edu/mydepartment/myname
the admin told me the server runs on .NET 3.5. So i used Linq ...
now i tried to upload the site by two ways:
when i just copy everything (with modification of web.config database settings) i get an error:
CS0246: The type or namespace name
'DataClassesDataContext' could not be
found (are you missing a using
directive or an assembly reference?)
Version Information: Microsoft .NET
Framework Version:2.0.50727.3082;
ASP.NET Version:2.0.50727.3082
Note here it says version 2.0
did he just lie to me? or its my configuration mistake?
anyway, i added the reference, nothing changes.
I tried also publishing (Build, publish) with option to keep the pre-comiled site updatable, and I get one line saying:
this is a makefile and should be
deleted!
what is going on?
It looks like it can't find your DBML file, or your DBML file isn't called "DataClasses.dbml". Also, the .NET Framework Version is not lying. It is reporting the CLR version, which is still 2.0 for the 3.5 .NET Framework.

CodeFile vs CodeBehind

What is the difference between CodeFile="file.ascx.cs" and CodeBehind="file.ascx.cs" in the declaration of a ASP.NET user control?
Is one newer or recommended? Or do they have specific usage?
CodeBehind: Needs to be compiled (ASP.NET 1.1 model). The compiled binary is placed in the bin folder of the website. You need to do a compile in Visual Studio before you deploy. It's a good model when you don't want the source code to be viewable as plain text. For example when delivering to a customer to whom you don't have an obligation to provide code.
CodeFile: You provide the source file with the solution for deployment. ASP.NET 2.0 runtime compiles the code when needed. The compiled files are at Microsoft.NET[.NET version]\Temporary ASP.NET Files.
I'm working with an Application Project in Visual Studio Express 2012 For Web and using .NET 4.0. In the code behind files for my login and change password pages I found a situation where I needed both CodeBehind and CodeFile in the declaration.
If I don't add a code file reference like
CodeFile=login.aspx.cs
The web page doesn't parse and the browser displays a parser error. It doesn't matter whether I compile the project or not.
If I don't add a code behind reference like
CodeBehind=login.aspx.cs
References to Security classes like MembershipUser fail both at compile time and when attempting to use intellisense with an error like "The type or namespace MembershipUser cannot be found". I have added a reference to System.Web.ApplicationServices as required by the .Net 4.0 framework.
I should add that these troublesome files are running in an application within the website created using the IIS Application tool. When I open the website from Visual Studio I have no difficulty with parser errors or reference errors. This confusion only occurs when I open the application as a project in Visual Studio.
Codebehind file need to compile before run but in src we dont need to compile and then run.. just save the file.

Resources