简体   繁体   中英

Generate LINQ classes with SPMetal for Site Collection in Sharepoint

I try to generate LINQ classes for my Site Collection root in Sharepoint with this command (all in one line):

SPMetal.exe
/web:http://myserver 
/namespace:mynamespace 
/code:myfile.cs 
/parameters:mysettings.xml

The mysettings.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Web AccessModifier="Internal"
 xmlns="http://schemas.microsoft.com/SharePoint/2009/spmetal">
    <List Name="List1"/>
    <List Name="List2"/>
    <ExcludeOtherLists/>
</Web>

But it doesn't work, the resulting error is (roughly translated from German):

The specified file name can not be used. Perhaps already a file or directory with this name exists, or permissions are not sufficient to access the file.

And I think it can't be a file problem because:

  1. If I change the web URL to http://myserver/subsite it works pretty good, the file gets generated
  2. I can see the file being created with 0kb and after 1-2 seconds the file gets deleted and the error message is shown
  3. I have more than enough space and permissions are ok as well (see 1.)

So what am I missing? Or can't I create LINQ classes for the root Site Collection?

If you are using Visual Studio 2010 try LINQ to SharePoint extension . It allows to use nice UI wizard for generating models classes.

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