简体   繁体   中英

I am trying to use SPMETAL generated model classes with Sharepoint 2016, getting errors on Microsoft.Sharepoint.Linq

After running SPMETAL.exe against my Sharepoint 2016 site, I imported the generated model to my project. I get 263 errors of the type "The type or namespace name 'Linq' does not exist in the namespace 'Microsoft.Sharepoint' (are you missing an assembly reference?).

By the way, in order to generate a datacontext model from your Sharepoint site for use with Linq to SQL with SPMETAL.exe, here's the command: "C:\\Program Files\\Common Files\\Microsoft Shared\\Web Server Extensions\\16\\BIN\\SPMETAL.exe" /web: /namespace: /code: Change the "16" above, depending on the version of Sharepoint you have / which folder you have there.

I have already referenced Microsoft.SharePoint.dll and installed the client and client runtime using Nuget.

Did something major change and can I still use SPMETAL? I've done a ton of searches, but other namespaces with Linq show up and I still haven't found what assembly or package Microsoft.Sharepoint.Linq resides in.

After Googling quite a bit, I found a reference to the assembly the Microsoft.Sharepoint.Linq namespace is located within: "Microsoft.Sharepoint.Linq.dll". I did a file search for that and found it in the .NET install, assemblies subfolder: C:\\Windows\\Microsoft.NET\\assembly\\GAC_MSIL\\Microsoft.SharePoint.Linq\\v4.0_16.0.0.0__71e9bce111e9429c\\

I included a reference to that in my project and all the errors went away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM