Question

I'm trying to use an ObjectDataSource in a SharePoint 2013 custom solution but I've the following errors...

Just start with the initial version of the ObjectDataSource:

<asp:ObjectDataSource ID="ods" runat="server" TypeName="BLProject.MyClass" />

MyNamespace.MyClass comes from another class library that interacts with the database using EntityFramework.

So with this ObjectDataSource I get the error

The type specified in the TypeName property of ObjectDataSource 'ods' could not be found.

Using Google I found this link so my control has become:

<asp:ObjectDataSource ID="ods" runat="server" TypeName="BLProject.MyClass, $SharePoint.Project.AssemblyFullName$" />

But nothing changed, so after another search with Google I added this

        <add assembly="BLProject.MyClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

And I get this error:

Could not load file or assembly 'BLProject.MyClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

What I'm doing wrong?

Thank you

Was it helpful?

Solution

When you build your class project it will generate a dll in bin folder. You need to get the dll and add it to package in your Sharepoint project then deploy or build

OTHER TIPS

I found a solution in two steps.

The first step is follow the Akshay suggestion ad after I added the assembly reference in the web.config.

Something like

<add assembly="BLL, Version=1.0.0.0, Culture=neutral, PublicTokenKey=123456" />

You can obtain the PublicTokenKey using the Visual Studio Developer Command Prompt and the command sn -T MyAssembly.dll from the dll folder.

Thank you again

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top