开发者

are you missing an assembly reference?

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\6开发者_开发知识库db59b13
    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!


I got this error when a project with a Target Framework of ".NET Framework 4 Client Profile", was referencing a project with a Target Framework of ".NET Framework 4".

Hope this helps somebody, if not the original poster.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜