views:

624

answers:

2

I'm getting the joyous 'type or namespace name "Something" does not exist in the namespace "Something else" (are you missing an assembly reference?)' error.

What I've got is a Website project that contains the website itself along with several other custom projects upon which the website relies. The issue I'm having is with one of the projects on which the website relies, let us call it A. It relies on a different custom project, called B.

So, B is a part of the solution and I can build B successfully. A has a reference to B and there doesn't appear to be any errors (no little yellow triangle-exclamation point). The website itself also has the dlls for both A and B in its Bin folder. It also had a dll.refresh file for B which was incorrect (wrong path). However, manually correcting the dll.refresh seems to have no effect. Removing those files from the website's bin folder has no effect either.

I've also tried removing A and B from the solution and then readding them. I've also tried removing A's reference to B and then adding it again (both from the project tab and manually browsing to the .dll itself).

I've tagged this Visual Source Safe as well because the project worked until I got the latest version from source control, so this issue is definitely related some change one of my coworkers made (conscious or otherwise). I suspect it was caused by a different file system layout for the project, but I'm not sure and if that is the case I don't understand why I've been unable to fix the problem.

This the result of the Fusion log, I do not fully understand it yet.

    *** Assembly Binder Log Entry  (10/20/2009 @ 1:43:06 PM) ***

    The operation failed.
    Bind result: hr = 0x80070002. The system cannot find the file specified.

    Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
    Running under executable  C:\Windows\SysWOW64\inetsrv\w3wp.exe
    --- A detailed error log follows. 

    === Pre-bind state information ===
    LOG: User = NT AUTHORITY\NETWORK SERVICE
    LOG: DisplayName = A, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
     (Fully-specified)
    LOG: Appbase = file:///C:/source/ProjectRoot/Project/Website/
    LOG: Initial PrivatePath = C:\source\ProjectRoot\Project\Website\bin
    LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\6db59b13
    LOG: Cache Base = C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\6db59b13
    LOG: AppName = 1601d5b6
    Calling assembly : ProjectBO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: C:\source\ProjectRoot\Project\Website\web.config
    LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v2.0.50727\Aspnet.config
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/6db59b13/1601d5b6/A.DLL.
    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/6db59b13/1601d5b6/A/A.DLL.
    LOG: Attempting download of new URL file:///C:/source/ProjectRoot/Project/Website/bin/A.DLL.
    LOG: Attempting download of new URL file:///C:/source/ProjectRoot/Project/Website/bin/A/A.DLL.
    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/6db59b13/1601d5b6/A.EXE.
    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/6db59b13/1601d5b6/A/A.EXE.
    LOG: Attempting download of new URL file:///C:/source/ProjectRoot/Project/Website/bin/A.EXE.
    LOG: Attempting download of new URL file:///C:/source/ProjectRoot/Project/Website/bin/A/A.EXE.
    LOG: All probing URLs attempted and failed.


Judging from this line: "LOG: Initial PrivatePath = C:\source\ProjectRoot\Project\Website\bin" it looks like its going after the dll in the bin of the website rather than going after the dll associated with project A. I do not see any mention of B, however. Anyway, hopefully that helps and I'll keep looking into Fusion, cool tool by the way!

A: 

In situations like this, the Fusion log is always a good starting point.

If I had to guess, one of your teammates has changed the reference from B's project (the correct way) to an actual copy of B (by browsing to B project's Bin folder and adding a reference to the DLL found there).

Clean your solution, remove the reference to B from A, build B, add a project reference to B, rebuild and test A.

If this fixes the problem, kindly gather your fellow employees and explain to them the dangers of referencing a DLL directly.

Will
This did not work. To be 110% clear, I assume when you say 'clean your solution' you mean right clicking on the solution file and selecting the clean solution option. When you say to add a project reference to B, I assume you mean browsing into the particular project (B, in this case) and adding a reference under 'References' via the projects tab. I haven't been able to get Fusion to pick up the results of compiling in VS, but I have got results from trying to view the site in IE, I will post above.
Trajanus
This is what I mean by adding a reference to the project: http://i36.tinypic.com/2ueslxt.png
Will
ok, yes that is how I added the reference.
Trajanus
A: 

It turns out a teammate renamed a namespace so I really was missing an assembly reference, I only thought I wasn't. Thanks for the help though Will.

Trajanus
NP. You can mark this as the answer after a grace period.
Will