Error while creating wsp package: Both “Site definitions” and “Site definitions” contain a file that deploys to the same Package location

SharePoint ErrorToday while trying to create Package for a project through Visual Studio, it started to give below error:

Both “Site definitions” and “Site definitions” contain a file that deploys to the same Package location: SiteTemplates\Admin project\default.aspx

Googled for it, but it gave no trace of such error message, so was now on my own to find the cause for this problem.

One thing was evident that, in site templates, there was this file “default.aspx” (as shown in error message) that was targeted more then once to same location somewhere in the solution. Now we had more then one site templates, and had created few of them recently by copying the file “default.aspx” to newly created templates by copying from older templates. So checked into the “SharePointProjectItem.spdata” file under site definitions. (Note: this file is not shown under Visual Studio’s Solutions Explorer window. But you can manually open it from windows explorer) Once the file was opened, the problem was evident from the entries in it. The problem was that all files copied from older templates to newly created templates had the older target attribute value, that was causing the problem, and was showing up in the error messages Package location value.

The solution: inĀ “SharePointProjectItem.spdata” file, we changed the values of “Target” attributes of allĀ items copied from older templates to point to correct locations, and the problem was solved.

“Web application at URL could not be found” exception while accessing sharepoint site through object model

SharePoint ErrorMany new-comers to sharepoint may encounter this silly exception of “Web application at <URL> could not be found” while trying to instantiate SPSite object to a site url using sharepoint object model.

The exception message may look something like:

Unhandled Exception: System.IO.FileNotFoundException: The Web application at http://myserver could not be found. Verify that you have typed the URL cor
rectly. If the URL should be serving existing content, the system administrator
may need to add a new request URL mapping to the intended application.
at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean con
textSite, SPUserToken userToken)
at Microsoft.SharePoint.SPSite..ctor(String requestUrl)
at Sharepoint.Tools.SPResetAuthor.Main(String[] args) in C:\Users\Program.cs:line 27

We may keep scratching our heads as to why is the object model not able to find the web-application at the specified url, when the same url perfectly works when used in an internet browser.

The problem is that you may be using a 64 bit Windows Operating system and the application that you are compiling is built for 32 bit system.

So how to figure this our?

  • Right click on your project in Visual Studio, select “Properties”
  • Select “Build” tab
  • Check the option selected in “Platform Target:” dropdown

Solution:

Set projects “Platform target” property value to be “Any CPU”. Save these changed properties, rebuild your application, and you are good to go.

“There is not enough space on the disk” error executing Export-SPWeb in Sharepoint

SharePoint ErrorToday while trying to export a large subsite using Export-SPWeb command through powershell, we got error “There is not enough space on the disk“. The command that we tried is as under:

Export-SPWeb -Identity “$siteurl” -Path “$exportfilepath” -IncludeUserSecurity -IncludeVersions all

Now the drive in which we were to export the contents had more then 250 GB of free space, and our content to export was around 170 GB. So the message didnt seem to make valid sence. Then after some research we came to know that the export command exports all contents to the windows TEMP folder (specifiedĀ by %TEMP% environment variable) which normally is located in C drive, and then after completion of export command, transfers the result to our specified export fileĀ location. Our C drive had only 50 GB of free space, and so did the message make sence now as 50 GB was not enough to store 170 GB of data.

So the solution, we changed our %TEMP% environment variable to point to an empty folder on the drive with size more then our export file size.

Note:

  • environment variables on windows 7 can be reached at: my computer > advance systemĀ settings > Advanced tab > environment variables button.
  • to check your current %TEMP% folder location, type “ECHO %TEMP%” using command prompt.

Thus, while exporting sites in sharepoint,Ā always make sure thatĀ the drive where the %temp% (environment variable)Ā folder is located, has space more then your export file size (this can be known through the content database size), andĀ if neededĀ change %temp% environment variables location to drive with enough free space available.

Save site as template giving error in Sharepoint 2010

SharePoint ErrorToday while trying to save a site as template (through “Site Settings” > “Save Site as template” option under “Site Actions” section) it gave sharepoint error page saying “Cannot complete this action” and a correlation id.

Looking up in sharepoint’s log file for the given correlation id, it said:

SPSolutionExporter: Microsoft.SharePoint.SPException: Cannot complete this action.
Please try again. —> System.Runtime.InteropServices.COMException (0x80004005):
Cannot complete this action. Please try again.
at Microsoft.SharePoint.Library.SPRequestInternalClass.GetViewsSchemaXml(String bstrUrl, String bstrListName, Boolean bFullBlown, Boolean bNeedInitAllViews, ISP2DSafeArrayWriter p2DWriter, Int32& plDefaultViewIndex, Int32& plMobileDefaultViewIndex)
at Microsoft.SharePoint.Library.SPRequest.GetViewsSchemaXml(String bstrUrl, String bstrListName, Boolean bFullBlown, Boolean bNeedInitAllViews, ISP2DSafeArrayWriter p2DWriter, Int32& plDefaultViewIndex, Int32& plMobileDefaultViewIndex)
— End of inner exception stack trace —

Googled this and found the solution in one of msdn forum question.Ā The problem was a corrupted list (“Team discussions” in my case).

The solution, such corrupted list cannot be deleted using sharepoint web interface, so deleted it using stsadm command as below:

stsadm.exe -o forcedeletelist -url http://myserver:8080/Lists/Team%20Discussion

Once the corrupted list was deleted, the template creation worked perfectly fine.

So the bottom line, if the site template creation gives error then make sure that all your lists and libraries are in proper state and no one is in corrupted state.