Export-SPWeb Tells Me “InvalidData” But the Data is Valid

I’m in the process of writing an article for the good people at www.sharepointbriefing.com and it involves deploying an list from a development farm to a production farm.  I’m still accustomed to using stsadm and need to break that habit, so I fired up the SharePoint 2010 Management Shell and played around using Export-SPWeb to backup my list.  What a strangely difficult thing that proved to be!

I kept getting this error:

image

That error, “InvalidData: (Microsoft.Share…CmdletExportweb"”) was killing me.  I’m embarrassed at how long I struggled with this.

I had previously run into a wall with PowerShell and used stsadm to get around it.  I tried it again this time and I got good results.

I spent a lot of time fiddling around with the –Identity option and then finally with –ItemURL.  It turns out that the ItemURL option requires a full path of the list/library you  want to export without the http://server bit.  So, despite the fact that the Identity argument is pointing to a subsite, the ItemURL is not relative to the Identify but relative to the site collection.

It would have been nice for the cmdlet to tell me what was minimally valid (the Identity in this case) and what was invalid (ItemUrl).  These little touches help people embrace the product.  Not a big ding against SharePoint, but a little one at least 🙂

Hopefully this post will save someone a bit of grief in future.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Working With TreeNodeBinding in the ASP.NET Treeview Control

I’ve been working on what I hope will be a soon-released CodePlex project that provides a nice integrated bit of web parts talking to each other via provider/consumer connections for the purpose of exploring a SharePoint site under the covers.  (This has certainly been done before, but this is a learning project as much as anything else).  This is meant to be a replacement for the windows explorer view of SharePoint 2010 document libraries.

The code has the usual recursive call down the SPWeb’s and SPLists from a given starting point.  The object that does all that traversing builds up an XML string that looks something like this:

<sitecollection url=’http://demo2010a:9090′>
 
<web
     title=’Hello World Sandbox’ 
     Template=’A site for teams to quickly organize, author, and share information, BLAH BLAH BLAH’>

     <list
        title=’BCC_Health_Services_FAQs’
        Template=’CustomList’
       
listid=’http://demo2010a:9090/helloworldsandbox[delim]1e02b001-3cb2-4f17-b63d-7809e86b4174′>
    
</list>

     <list
        title=’BCC_Notifications’ 
        Template=’CustomList’ 
        listid=’
http://demo2010a:9090/helloworldsandbox[delim]5a5a13d1-877c-41c0-9063-b9612be80d5e’>
     </list>

  </web>

</sitecollection>

I expect to clean up that XML before all is said and done.

I want to ultimately get that information up and into a Treeview control.  Not exactly earth shattering stuff.

The challenge I took on here was to connect the tree view to an XML Data Source control instead of manually building up my treenodes as I traverse the tree.  I did this partly because I’m deliberately making things harder on myself (this is a learning project after all) and partly because I have this vague notion that building up tree nodes as I traverse the tree isn’t a good idea for the long term.

The problem with this approach is that the Treeview control doesn’t know about the good attributes on the interesting nodes like “list” or “web” so it shows this output by default:

 

image

That’s not useful.  This is where the TreeNodeBinding class helps.  I can use this to tell the Treeview control how it should interpret the XML.  Here’s an example:

tnb = new TreeNodeBinding();
tnb.DataMember = "list"; // This is the label in the xml for a site.
tnb.TargetField = "listid";
tnb.ValueField = "title";
tnb.ToolTipField = "Template";

This binding tells the treeview that when it finds a <list> node in the XML, apply the bindings for TargetField, ValueField and ToolTipField.  In may app, these map as follows:

  • TargetField: When someone clicks on a node value, this is what you’ll get for SelectedNode.Value.  This is not to be confused with…
  • ValueField: This is what you want the Treeview to display to the user.
  • ToolTipField: The value from the XML that you want as a Tooltip.

Add that TreeNodebinding to the tree view’s DataBindings and you get output like this:

 

image

I’ll have more on all this as I continue on the project and eventually put this up on Codeplex.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Finding Great SharePoint Talent

Here is another article I wrote for the good people at SharePoint Briefing entitled “Finding Great SharePoint Talent”.  The article tries to give some advice on how to find truly good and well-experienced people when you’re looking to expand your staff.

Here is a teaser:

Teaser

Check it out.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Backup-SPSite cmdlet Silently Fails When Executed with Wrong Permissions

I was on a server and running a boring site collection backup command with the Backup-SPSite powershell cmdlet and got the following error:

Backup-SPSite : Cannot find an SPSite object with Id or URL: …  (full message below)

image

I’ve had issues with this server so it made me think that the server was sick or something.  I switched over to good old stsadm and this time I got a different error:

This operation can be performed only on a computer that is joined to a server farm … (full message below)

image

Of course, it it on the farm and all that, but it did occur to me that I was logged in with my own account and I normally log in as a system account onto this server.  I did that and the backup succeeded.  What I find interesting is that the cmdlet gave me a security trimmed error message.  That’s kind of neat but didn’t help me much :) 

<end/>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Straight to Jail List – Cisco VPN Client

Last summer, I created a “straight to jail” list for the refrigerator.  #1 on the list is Lawrence O’Donnell (for inaccurate predictions), but that’s way beyond the scope of this blog :)  Today, I’m adding Cisco’s VPN client to the list, and that’s in scope by a nose.

A bunch of years ago many of clients used Cisco VPN to enable remote access to their site.  Back then, I created virtual PCs for each of these clients and installed Cisco on that? Why?  Because Cisco locks your machine up so that you can’t even browse local network printers, let alone dangerous tools like Skype, Communicator and the “~” key.  But,  if you install it on a VM, your VM is locked down but not your host. 

I’m reminded of those glory days today because I have to use a Cisco VPN client *again* and it locks me and I have to use it in a minute.  I’d rather blog about how much Cisco VPN client deserves to be in jail rather than use it…

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

SharePoint Fest – Denver

I’ll be speaking in Denver at the SharePoint Fest event on May.  I’m going to discuss some common business and technical want-to-do’s in SharePoint Designer workflows and outline some patterns you can use to solve them.

There’s a lot of other very interesting stuff going on at the conference, so check it out: http://www.sharepointfest.com/Denver/

It’s not a free event and I have a discount code handy, so leave a comment or ping me and I’ll gladly give out.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Implement a Global Pop-up Notification System

I wrote up an article for www.sharepoint.briefing.com entitled “Implement a Global Pop-up Notification System.”  This function was implemented for a community college to communicate school closings due to snow and so forth. 

It uses a custom list, out of the box SharePoint web services and some jQuery to do the work.

Here’s a teaser:

image

Read the whole thing here: http://www.sharepointbriefing.com/features/article.php/3918471/Implement-a-Global-Pop-up-Notification-System.htm

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Connecting Text Field Filters to Your Custom Web Part

I wanted to receive information from a Text Field filter in SharePoint 2010 into my custom web part.  I tried using this MSDN article as a basis but the article is either broken or I’m just not following it correctly.

A little more searching turned up Mike Smith’s MSDN contribution here (http://social.msdn.microsoft.com/forums/en-us/sharepointdevelopment/thread/72F1732A-7F93-441E-8644-2E82BBB153D9).

There’s a lot of stuff out there on connectable web parts but Mike’s article is as simple as it gets.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Renaming Web Part Namespaces (Or, One reason for “A Web Part or Web Form Control on this Page cannot be displayed or imported)”

I’ve been working to get my dev chops back and to that end, working on a hobby project that has the following bits:

  • Connected web part that receives a site or site collection URL from an out of the box SharePoint Text Filter web part.
  • This web part looks up all the info about the the selected site, generates an XML package and hands it off to another WP on the page (via connections).
  • 3rd web part receives the XML and does some XSL transform stuff.

I wanted to rename the name space of all the bits to “Nivlag” and I was getting hit up with the following error when I deployed the web part to  my test environment:

A Web Part or Web Form Control on this Page cannot be displayed or imported.  The type could not be found or it is not registered as safe.

This is a beginner’s problem but I thought I’d jot down a note on this anyway.  I caused the error when I right-clicked on the default name space (which defaulted to the project name), selected Refactor and then Rename like so:

image

That did rename things in a bunch of places in the project, but it’s not enough.  You also need to make several other adjustments:

1. Manually open up and edit a file, “ShaerPointProjectItem.spdata”. That an XML file that has a <SafeControls> section.  The namespace rename function isn’t aware of this file for whatever reason, so you need to update the Namespace there manually.

2. Manually edit the .webpart file.  For whatever reason, Visual Studio doesn’t change this reference either.  Change the "<type>” node to reflect your changed namespace there.

3. Lastly, depending on how you refactored the namespace change, visual studio may have also updated the string that references your .ascx file here:

private const string _ascxPath = @"~/_CONTROLTEMPLATES ……

You may need to change that back.  You’ll because you’ll get an error similar to the following when you try and add the web part to a web part zone on a  page:

Server Error in ‘/’ Application.


The file ‘/_CONTROLTEMPLATES/Nivlag/VisualWebPart1/VisualWebPart1UserControl.ascx’ does not exist.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The file ‘/_CONTROLTEMPLATES/Nivlag/VisualWebPart1/VisualWebPart1UserControl.ascx’ does not exist.
Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

 

Fix the reference there and you should be good to go.

4. Lastly, the actual ASCX file still had a reference (for me) to the old original namespace (the refactor/rename function didn’t fix this).  You’ll know about this error when you try and add the web part to the page and get the following message:

Server Error in ‘/’ Application.


Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type ‘RenameNameSpace.VisualWebPart1.VisualWebPart1UserControl’.
Source Error:

Line 6:  <%@ Import Namespace="Microsoft.SharePoint" %> 
Line 7:  <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
Line 8:  <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="VisualWebPart1UserControl.ascx.cs" Inherits="RenameNameSpace.VisualWebPart1.VisualWebPart1UserControl" %>

Source File: /_CONTROLTEMPLATES/RenameNameSpace/VisualWebPart1/VisualWebPart1UserControl.ascx    Line: 8


Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927

Edit the .ascx file directly and fix the broken namespace.

At this point, I finally had a web part living in the namespace of my choosing.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Performance Point – It’s Not Just for BI Geeks Any More

I wrote up a little article about Performance Point earlier this week and it’s just been published www.sharepointbriefing.com.  Here’s the intro:

 

image

Click here to read the article.

I think that the overall Performance Point development experience is awkward at this point in time, but it’s definitely accessible.  In prior versions, it felt like it was simply a bridge too far for most SharePoint people.  The new environment requires getting your hands dirty, but when you get under the covers, it’s quite recognizable.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin