Using MVVM 4 ASP in a SharePoint Visual WebPart I am coming across a problem where the compiler is showing me the error:
'object' does not contain a definition for 'Bind'
I have put the DLL’s containing the methods into the GAC (done by the SP package), referenced the assemblies in the markup, and imported the namespace as follows:
<%@ Assembly Name="ASPBinding, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b36aef9f99d7a844" %>
<%@ Assembly Name="Binding, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b36aef9f99d7a844" %>
<%@ Import Namespace="Binding" %>
And IntelliSense shows that the page markup is seeing the extension methods:

Is there a reason why the page compiler sees something different? This works when it is in a normal ASPX page outside of SharePoint.
Update: OK – seems like a ‘problem’ with SharePoint.
Out of the box, SP2010 does not use .Net 3.5 to compile ASPX pages – it uses the .Net 2.0 compiler. Who would have thought?!..
Changing the web.config to use the 3.5 compiler allows us to call the extension method ok.
OK – seems like a ‘problem’ with SharePoint.
Out of the box, SP2010 does not use .Net 3.5 to compile ASPX pages – it uses the .Net 2.0 compiler. Who would have thought?!..
This is a good post on how to get it working.