The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?) [closed]
What I have "Tried" 1. Adding reference to , System.Core, System.Xml.Linq, System.Data.Linq by right clicking on my website root as well as in individual pages.
By adding assembly in web.config as shown below,
<configuration> <connectionStrings> <add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\PayrollSystem_DB.mdb" providerName="System.Data.OleDb"/> </connectionStrings> <location path="~/Styles/StyleSheet.css"> <system.web> <compilation debug="true"> <assemblies> <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> </assemblies> </compilation> <authentication mode="Forms"> <forms loginUrl="~/Login/frmLogin.aspx"/> </authentication> <authorization> <deny users="?"/> </authorization> </system.web> </location> </configuration>
It was working fine in the project earlier today. I ran into first web.config issue开发者_如何转开发 when I added
<authentication> and <authorization>
tags my CSS stop working on the login page. Then I added Location tag as shown above and it fixed my css for login page but then I started getting this Linq error on every page.
I searched online it was advised it is web.config issue so I should add the reference for System.core assembly in the web.config file which I did but still same issue.
Can you try clearing the WebsiteCache folder and see if that helps. (Back it up before you delete its contents)
https://superuser.com/questions/65615/visual-studio-2008-does-not-remember-my-default-page-for-web-sites/65678#65678
you have your system.web inside location. And location path is CSS file. So, seems that your assemblies effectively missing from the project. Does it work without location element? Or without system.web embedded inside location?
R00T CaUsE
Adding
<authorization>
tag with the code shown in above question would make any anonymous user from accessing any page other than Login, as each request will be redirected to LogIn Page with no other content allowed from server including basic CSS.
Suggested solution 1 on the web was to add
<location>
tag which works for css but causes issue with the System.Linq.
Here is the solution for the StUpIdItY. First of since nothing was working I saved web.config contents and deleted web.config and recreated from scratch as follows.
Step1
<?xml version="1.0"?>
<configuration>
<system.web >
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Forms" >
<forms loginUrl="~/Login/frmLogin.aspx" />
</authentication>
<authorization >
<deny users="?" />
</authorization>
</system.web>
This first step took Linq errors away.
Step 2
Problem with this approach is since I am using external CSS file it will not apply to LOGIN page as
<authorization >
<deny users="?" />
</authorization>
will block any anon user. You can still use CSS by having css in separate folder and adding another web.config file under the folder where your external CSS is. In my case my css file was, StyleSheet.css under Styles folder. So I just added web.config there as follows.
<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</configuration>
Now my css is working fine, as well as I can use LogIn page and Linq.
Thanks to MICROSOFT for wasting my time on these issues but I hope I can save frustrations to many in the future.
精彩评论