Showing posts with label Invalid file name. Show all posts
Showing posts with label Invalid file name. Show all posts

Tuesday 12 October 2010

CKSDev tool issue - The custom tool SPMetalGenerator failed

Problem: When adding a SPMetal Definition (CKSDev) item in visual studio, the SPMetal proxy generation fails with the error message: The custom tool 'SPMetalGenerator' failed.  Object reference not set to an instance of an object.

Hypothesis: CKSDev item template is failing, next I tried SPMetal from the command line and received the "Invalid File Name" error.  I had previously fixed this issue and here is the link.

I check the issue using the browser:

Resolution: Delete the list showing the Invalid file name error.  I could not do it from the UI so I used PowerShell.

More Info:
http://sp2010uk.blogspot.com/2010/08/issues-with-site-columns-content-types.html

Thursday 19 August 2010

SPMetal Invalid file name error

Problem: SPMetal fails with the following error:
Error: Invalid file name.
The file name you specified could not be used. It may be the name of an existing file or directory, or you may not have permission to access the file.

Initial Hypothesis: Permissions on the directory are wrong or the SPMetal proxy code file being created is locked.  Folder permissions haven't change and the file is removed from previous runs.  So my initial hypothesis is wrong.  Previously I was working on building lists created from custom content types and deployed via a feature.  There are 2 lists based on content types.  The list definition, custom content type & site columns have been removed.  The 2 lists still appear in my UI and when I click on the list I get an application NullReferenceException error.  Makes sense as SharePoint hasn't cleared up the list instances.
                            ============
Updated Problem: I have 2 lists on my SharePoint 2010 site that I can see in the web UI and through my Visual Studio Server Explorer however, I can't get into the UI as I am getting the NullReferenceException error.  I need to remove the lists to allow SPMetal to work.

Initial Hypothesis: Use another tool to delete the list, VS solution explorer won't let me update the list.  Use SharePoint Designer, on opening SPD it won't show me any lists or libraries.  So I'm left with using an stsadm cmd or Power Shell.  As I am loving PowerGui I went for the Power Shell Solution.
Resolution: Open the SharePoint Power Shell window, delete the lists using the following code:
$url = "http://demo1"
$site=new-object Microsoft.SharePoint.SPSite($url)
$web = $site.OpenWeb()
$list = $web.Lists["Customers"]
$list.Delete()
Now SPD works, SPMetal works - Problem resolved.
Summary: I created lists from content types, I removed the content types, list definitions however I left the list instance.  This cause SPD, SPMetal to err.  Cleaning the defunct lists using Power Shell corrects the issues.
More Info:
PowerGui sharePoint CheatSheet