views:

521

answers:

2

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(Container.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?

A: 

Do all of your projects have a reference to that assembly?

Is the version correct?

SLaks
+2  A: 

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>
Gary
I added the last two assemblies you listed and it now works, which is odd since the same assemblies are in the project references.
ilivewithian