Reference Required for Assembly that is definitely part of a project
I have a project that I am in the process of migrating to using Linq To SQL. On the whole it's fine, but I'm stuck on an issue where if I try to put a timestamp from an DTO into a hidden field I get this error at runtime:
BC30652: Reference required to assembly 'System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' containing the type 'System.Data.Linq.Binary'. Add one to your project.
I definitely have a reference to the assembly, otherwise other sections of the code wouldn't compile. I tried removing all references and deleting the bin and obj folders, but I still get the same error.
It happens on this line in the markup:
<asp:HiddenField ID="hfTimestamp" runat="server"
Value='<%#CType(Conta开发者_JAVA技巧iner.DataItem, CommunicationType).pslTimestamp.TimestampToString() %>' />
Where TimestampToString is an extension method that looks like this:
<Extension()> _
Public Function TimestampToString(ByVal binary As Binary) As String
Return BitConverter.ToUInt64(binary.ToArray(), 0).ToString()
End Function
Has anyone seen this kind of behavior and know a fix to it?
Are you separating you logic in an different assembly? If so then you must reference it in the web app also. You can add it to the web.config
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
</compilation>
I had this happen related to code modules that were part of the project. What solved it was closing the solution and reopening it. I had been debugging an ASPX project that was upgraded, and had eliminated all of the errors, only to have this issue pop up at the end.
精彩评论