views:

171

answers:

3

I have two projects 'HOD', and 'Controllers'. Controllers is a class library with a namespace of 'Controllers'. In the code file for HOD I am trying to reference the Controllers namespace by 'using Controllers'. I added a reference in the HOD project to Controllers and it does show up in VS2008 under the references folder.

When I build out the project I get no errors, but when I go to view the page I receive the error 'The type or namespace name 'Controllers' could not be found (are you missing a using directive or an assembly reference?)'.

Controllers.cs ( class library, Controllers project )

using System;
using System.Collections.Generic;
using System.Text;

namespace Controllers
{

    public class Controller {    }

}

index.aspx.cs ( HOD project )

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Controllers;


public partial class HOD : Page
{

    string sop() { return "sop"; }

    protected void Page_Load(object sender, EventArgs e)
    {
        blahmsg.Text = sop();
    }

}

The project is located on our webserver, and the Controllers.dll is located in the same bin folder as HOD.dll. Thanks in advance for your help!

edit: .sln contents

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "T:", "T:\", "{1D5F28B3-E6A0-4CF8-B7A3-43121225C73E}"
    ProjectSection(WebsiteProperties) = preProject
    TargetFramework = "2.0"
    Debug.AspNetCompiler.VirtualPath = "/T:"
    Debug.AspNetCompiler.PhysicalPath = "T:\"
        Debug.AspNetCompiler.TargetPath = "E:\DEV\webdev\webdev\PrecompiledWeb\T:\"
        Debug.AspNetCompiler.Updateable = "true"
        Debug.AspNetCompiler.ForceOverwrite = "true"
        Debug.AspNetCompiler.FixedNames = "false"
        Debug.AspNetCompiler.Debug = "True"
        Release.AspNetCompiler.VirtualPath = "/T:"
        Release.AspNetCompiler.PhysicalPath = "T:\"
        Release.AspNetCompiler.TargetPath = "E:\DEV\webdev\webdev\PrecompiledWeb\T:\"
        Release.AspNetCompiler.Updateable = "true"
        Release.AspNetCompiler.ForceOverwrite = "true"
        Release.AspNetCompiler.FixedNames = "false"
        Release.AspNetCompiler.Debug = "False"
        VWDPort = "53327"
    EndProjectSection
EndProject

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HOD", "Y:\HOD\HOD.csproj", "{5F523FB7-B902-4E6E-BAA9-C2EB37D69EC7}"
EndProject

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Controllers", "Y:\HOD\Controllers\Controllers.csproj", "{E6A16990-5FC6-4FE3-8DAB-CD2FEC8CF4FF}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Release|Any CPU = Release|Any CPU
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {C8A12BBE-4483-4560-97A4-795F2E57D667}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {C8A12BBE-4483-4560-97A4-795F2E57D667}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {C8A12BBE-4483-4560-97A4-795F2E57D667}.Release|Any CPU.ActiveCfg = Debug|Any CPU
        {C8A12BBE-4483-4560-97A4-795F2E57D667}.Release|Any CPU.Build.0 = Debug|Any CPU
        {A81C381B-1E12-49B0-8BC0-8532EF9F216F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {A81C381B-1E12-49B0-8BC0-8532EF9F216F}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {A81C381B-1E12-49B0-8BC0-8532EF9F216F}.Release|Any CPU.ActiveCfg = Debug|Any CPU
        {A81C381B-1E12-49B0-8BC0-8532EF9F216F}.Release|Any CPU.Build.0 = Debug|Any CPU
        {BD46969E-9D1C-419A-A82C-388E35BF7C13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {BD46969E-9D1C-419A-A82C-388E35BF7C13}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {BD46969E-9D1C-419A-A82C-388E35BF7C13}.Release|Any CPU.ActiveCfg = Debug|Any CPU
        {BD46969E-9D1C-419A-A82C-388E35BF7C13}.Release|Any CPU.Build.0 = Debug|Any CPU
        {1D5F28B3-E6A0-4CF8-B7A3-43121225C73E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {1D5F28B3-E6A0-4CF8-B7A3-43121225C73E}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {1D5F28B3-E6A0-4CF8-B7A3-43121225C73E}.Release|Any CPU.ActiveCfg = Debug|Any CPU
        {1D5F28B3-E6A0-4CF8-B7A3-43121225C73E}.Release|Any CPU.Build.0 = Debug|Any CPU
        {5F523FB7-B902-4E6E-BAA9-C2EB37D69EC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {5F523FB7-B902-4E6E-BAA9-C2EB37D69EC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {5F523FB7-B902-4E6E-BAA9-C2EB37D69EC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {5F523FB7-B902-4E6E-BAA9-C2EB37D69EC7}.Release|Any CPU.Build.0 = Release|Any CPU
        {E6A16990-5FC6-4FE3-8DAB-CD2FEC8CF4FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {E6A16990-5FC6-4FE3-8DAB-CD2FEC8CF4FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {E6A16990-5FC6-4FE3-8DAB-CD2FEC8CF4FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {E6A16990-5FC6-4FE3-8DAB-CD2FEC8CF4FF}.Release|Any CPU.Build.0 = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
EndGlobal

Compiler output

------ Rebuild All started: Project: Controllers, Configuration: Debug Any CPU ------ C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\Controllers.dll /target:library Class1.cs Properties\AssemblyInfo.cs

Compile complete -- 0 errors, 0 warnings Controllers -> Y:\HOD2\Controllers\bin\Debug\Controllers.dll ------ Rebuild All started: Project: HOD, Configuration: Debug Any CPU ------ C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:Y:\HOD2\Controllers\bin\Debug\Controllers.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.EnterpriseServices.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Extensions.Design.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Extensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.Mobile.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /debug+ /debug:full /optimize- /out:obj\Debug\HOD.dll /target:library index.aspx.cs index.aspx.designer.cs Properties\AssemblyInfo.cs

Compile complete -- 0 errors, 0 warnings HOD -> Y:\HOD2\bin\HOD.dll ========== Rebuild All: 2 succeeded, 0 failed, 0 skipped ==========

A: 

I tried recreating your solution with the two projects listed above. Everything compiled and worked just fine. (I assumed blahmsg was an <asp:Literal/>.)

There doesn't seem to be anything wrong based upon what you have posted which leads me to think it's a caching issue. I would try clearing out the following:

  • Your web application's bin folder
  • C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
  • Delete your .csproj.user files for both projects. I've had those cause issues in the past.

If those don't help I'll look into it further. Can you post any other relevant source code? Perhaps the markup for the web page?

Stuart Thompson
Stuart, unfortunately your suggestions did not work. The only other piece of code is <%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="HOD" Title="House of Delegates" %> now that I've stripped out everything else.
chelfers
+1  A: 

chelfers, thanks for posting sln file here. According to it, you DON'T have project reference in place.

You can either add it from Visual Studio (delete reference, save, add reference), or instead you can add following line:

ProjectReferences = "{E6A16990-5FC6-4FE3-8DAB-CD2FEC8CF4FF}|Controllers.dll;"

right under

ProjectSection(WebsiteProperties) = preProject
    TargetFramework = "2.0"

(and just to be safe make a copy of .sln file first).

PS: And move to 3.5, it's XXI century :)

Vitaly
I'm still receiving the error. I think the issue is my code is on the server not my local machine. When I run it in the 'Visual Studio Development Server' it runs without issue. When I open it from our IIS server ( which is where the code resides ) it errors on viewing.
chelfers
That sln doesn't look like IIS based :) But if you have problems with IIS, it might be security problems. Check this article: http://learn.iis.net/page.aspx/387/using-visual-studio-2008-with-iis-70/
Vitaly
Solution is on my local PC, and all the file are stored on the server; I am accessing them via a mapped drive in VS. Without the using statement the page works perfect.
chelfers
I'm not sure I'm getting what you're saying. If any of the project was from IIS, you would have smth like "http://localhost/" as project folder. So this is not IIS project. And besides - which method did u use from what I said to fix this?
Vitaly
The solution is on my local PC, I've mapped multiple drives to our IIS server to store the files that I am working on. In VS I created the projects on those mapped drives, and when I view the site I visit http://dev.apwa.net/HOD/index.aspx ( restricted, won't work for you ). I've tried all the solutions posted by everyone so far without success. Any and all files related to anything I work on reside on our web server, there is nothing local except the .sln file.
chelfers
I just got an idea - did u see what output says? (View -> Output, then recompile solution). It might be file collision or smth like that.
Vitaly
@Vitaly, check original post, I posted the output there.
chelfers
@chelfers - but it's compiling fine?! 0 errors!
Vitaly
@Vitaly, Yep, zero errors. I will be investigating the server more as I said before running it on the VS Dev server it runs perfectly.
chelfers
@chelfers - do you have dll that has controllers in bin folder of the web site?
Vitaly
@Vitaly, Yep, /HOD2/bin/HOD.dll, Controllers.dll
chelfers
Heh, I give up, you won))) The only advice I have is: copy everything on your local machine, and do development there. Then publish website for a QA/PROD environment. In case you need to sync with other devs, use some source control system.
Vitaly
Thank you for all your help Vitaly, I really appreciate it.
chelfers
A: 

Would you have an antivirus running on your server by any chance?

I've run in issues where aspnet_wp couldn't load the DLL because the file was locked by McAffee on the server.

The fix was to disable the antivirus realtime check on our bin directory.

Cheers, Florian

Florian Doyon
Just disabled AV on the server, still no luck :<
chelfers