Strange exception: Active Project's DLL being referenced in two places?
I hope its okay to do this, but after some help in my last question it basically raised a new question as to what's happening. Here's the original question.
As you can see, I'm getting a very strange exception, and it seems to be the reason my type comparisons were not returning true:
[A]Stuff.Things.Web.ProgramHierarchy cannot be cast to [B]Stuff.Things.Web.ProgramHierarchy. Type A originates from 'Stuff.Things.Web, Version=1.0.5282.29772, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' at location 'C:StuffCommunities In SchoolsSolutionStuff.Things.Web/bin/Stuff.Things.Web.dll'. Type B originates from 'Stuff.Things.Web, Version=1.0.5282.29772, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:WindowsMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET FilesStuff.Things.web94104cc5724c3b9dassemblydl355541b78a421c72d_458bcf01Stuff.Things.Web.DLL'.
Keep in mind that Stuff.Things.Web
is the active project. How could it possibly be referencing the DLL of the active project (result of the build) from anywhere other than the bin folder?
I had a similar problem with an ASP.Net solution I was deploying: The DLL being referenced was strongly named and and the correct version but I was still suffering from casting errors. I fixed it by setting 'Copy Local' on the DLL properties in Visual Studio to 'False'. That seemed to force the solution to use the same instance of the DLL.
链接地址: http://www.djcxy.com/p/72712.html