Visual studio unable to detect Sitecore.Web namespace - asp.net

Currently I'm playing with sitecore 7. I followed this blog to setup my visual studio with the sitecore.
Everything is fine until when I tried to create a sc:placeholder on the aspx.
It throws this error regardless whatever sitecore control I have tried to insert:
Error 180 The type or namespace name 'Web' does not exist in the namespace 'Sitecore' (are you missing an assembly reference?)
C:\inetpub\wwwroot\abc Sc7\Website\layouts\Customized\MainLayout.aspx.designer.cs
I tried to create a placeholder using code behind, no error was thrown.
I have tried to create an empty web application project. And added a reference to only Sitecore.Kernel.dll
I created a dummy page to test out the reference to the dll thing.
It still throws the same errors.

I know the blog mentions it, but have you added a reference to the "Sitecore.Kernel" DLL in your project? Open your references folder and ensure that there is not a problem with the reference.

Make sure your project is using .net 4.5 (you will need to use something other than VS2010)

After default sitecore installtion Sitecore.Kernel assembly is placed in bin folder. Maybe you used 'Clean project' and after this operation your assembly was deleted. Please check if this assembly is present in bin folder. It should be loaded by IIS automatically from bin folder, even if you have wrong reference in you csproj file.
When I start new project I always move dlls from bin folder to other folder, and put references to this files in csproj, so when I run clean project (or clean solution from VS) i have empty folder (only one file is present - *.lic file).

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.

Copy Visual Studio Project - Compilation Error

I have an ASP.Net MVC 5 project inside a Visual Studio 2015 solution. I needed an exact copy of the project so in the File Explorer I copied the project and pasted to create a new project.
I renamed the copied project so that both projects now have a different name. I also updated the Namespaces inside of any classes in the copied project to reflect the new project name.
MyProjects.ProjectOne
MyProjects.ProjectTwo
I also deleted the Bin directory in the newly copied project. Both projects are targeted at the .Net Framework 4.0. I've restarted Visual Studio, but I still get the following compilation error when I now try to run either Project:
Compiler Error Message: CS0234: The type or namespace name 'ProjectOne' does not exist in the namespace 'MyProjects' (are you missing an assembly reference?)
I'm running out of ideas with regards to solving this.
Any advice would be greatly appreciated.
Thanks.
Make sure that the project which you copied has the correct references, and that the versions of the assemblies are the same as on the old project. You can also use the Object Browser to inspect an assembly and verify whether it contains the types that you expect it to contain.
For more information, see Troubleshooting .NET Framework Targeting Errors.

Why does the deletion of *.dll.refresh file have no affect?

The *.dll.refresh file tells visual studio about the class library location but whenever I delete it the application still works in debugging mode.
Why is this? Is the location not needed?
Because that's only a pointer to the referenced DLL.
It is used to copy the DLL to the bin location, but if you already copied the DLL, then deleting the .refresh file won't affect Visual Studio
If you delete the DLL from the bin folder and the _*.refresh_ file then you would get compilation errors if you try to access the types defined in the referenced DLL
dll.refresh files gives the path of the DLL in question to tell visual studio where to find it. They will be created each time you add a reference to the project.
They normally appear when you are using a project type that does not create a standard Visual Studio project file, as normally paths to referenced DLLs would go in there.
Their role ends once DLL gets loaded in your project. Hence you will not get any error
when you delete *.dll.refresh files from your project.

ASP.Net build error - assembly not referenced

I am getting a build error when I attempt to build my asp.net application. The error is:
The type 'MediCare.Framework.Authentication.IUserAuthenticate' is defined in an assembly that is not referenced. You must add a reference to assembly 'MediCare.Framework, Version=1.0.1.95, Culture=neutral, PublicKeyToken=1999fa3c42b9'.
I can see the class in the library which is in the references folder. How do I debug this issue?
My intention is to point the references folder to the library source code's bin directory (since the pdb file is lcoated there and any updates to the library will reflect in the application). However, when I point the references folder to the bin directory of the source code, I get the error message above.
Update The application was originally developed in VS 2008 and I am modifying it in 2010. I think I am confused about where the GAC assemblies would be, if I am using VS 2010 (2.0 framework location or 4.0 framework location) ? .NET 4.0 has a new GAC, why?
Update (06-26-2012)
The file in the GAC ("C:\Windows\assembly\") has been deleted. But this error is still occuring.
This could possibly be caused by version inconsistencies. Meaning, in order to fix this, I would do a complete clean build of your assemblies (and also an assemblies that might be nested inside an assembly). Just go out cold and do a new build on all assemblies. That should work.
Go into windows explorer, right click on the DLL file that your project is using that contains this class, and look at the version tab. Make sure version number matches what you see in the error message. My guess is that it won't.
If it does match, then check the GAC and make sure there isn't a different version of the DLL there that it could be picking up. To do that, go to windows explorer, and navigate to c:\windows\assembly. See if that assembly is in there with a different version number. If it is, you may need to delete it from the GAC (use caution though because other apps may depend on it being there).

Attach DLL to ASP.NET Site

How do you attach a DLL to a asp.net site? I want to be able to debug and edit the DLL without having to keep replacing the reference in my asp.net site. I checked attach to process but didn't see the worker process. I am using asp.net, IIS 7.
Just put it into /bin folder of your web application.
OR
Add reference to this .dll by right clicking on References > Add Reference > Browse > Select your .dll file and lick OK.
Then set it's "Copy Local" property to "True". This way .dll will be copied into /Bin folder each time you build application.
alt text http://xmages.net/out.php/i170817_1.png
Using Visual Studio you should create a solution that has your website as a project and the DLL (code) as another project. Make a reference in the website project to the DLL project and it should update it automatically.
If you are not using the web application model and just the website model you could just have your DLL project output to your website's /bin directory directly. That will update the DLL in the website/bin folder whenever you build your DLL project.
If you want to edit the dll, open that project up in a second instance of Visual Studio and treat it like you would for any other project.
Set the reference in your /bin folder to the debug dll that the second Visual Studio creates.
I'm assuming you have Visual Studio...
If you're just trying to add a dll, you can add a reference to it by right clicking on your website node and choosing "Add Reference..." .
You will be able to debug the dll if you have its pdb along with it (to load the symbols from). You will NOT be able to edit the dll.
If the dll is in fact another project you have the source code for, just add the project to your solution, and from your website project add a reference from the "projects" tab. VS should add a reference and dependency so that it keeps the dll updated when you change code in your dll project.

Resources