Category Archives: Debugging

View CAML Queries in Real Time With ULS Viewer

My colleague, Ashsih Patel, wrote up a nice walk-through describing how to see the CAML behind various SP queries that happen in the course of business in real-time using the ULS viewer.

Here’s the intro:

Did you ever want to know what CAML queries are executed by SharePoint Server?

Well, for troubleshooting and learning purpose, it is not a bad idea. After all, SQL Profiler has been helping us troubleshoot a lot of issues.

There may be products out there but I figured out a way to do it without spending extra bucks! And here it is…

You can read the whole thing here: http://www.bigapplesharepoint.com/pages/View-An-Insight.aspx?BlogID=68&rsource=pgblog&rtitle=caml.

</end>

Quick and Simple: Solve “Invalid URL Parameter” problem with UpdateListItems in lists.asmx

When working with UpdateListItems via lists.asmx, it’s easy to generate the error:

Invalid URL Parameter.

The URL provided contains an invalid Command or Value. Please check the URL again.

You can get this error when you forget to include ID in the the list of fields to update.  This, like a lot of these SP web services, is a bit counterintuitive since you need to include the ID in the ID attribute of the <Method> element.  And you’re not updated ID and probably never want to in the first place.

This SOAP envelope works:

<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>
  <soapenv:Body>                      
    <UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>                     
      <listName>{C712E2EA-54E1-47AD-9D99-1848C7773E2F}</listName>                     
        <updates>                     
         <Batch OnError="Continue">
          <Method ID="1" Cmd="Update">
            <Field Name="CooperativeLock">locked!</Field>
            <Field Name="ID">1</Field>
          </Method>
        </Batch>                     
        </updates>                
      </UpdateListItems>             
  </soapenv:Body>         
</soapenv:Envelope>

If you strip out the ID field reference then you’ll get the annoying “Invalid URL parameter” message.

</end>

undefinedSubscribe to my blog.

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

 

Quick Fix: “The content type name ‘$Resources:ReportServerResources … cannot contain … special characters”

I’ve been spending some time cleaning up a SharePoint 2010 site and one of the cleanup issues relates to a corrupt / incorrectly installed SQL Server Report Services issue.  The issue arose when one of my colleagues tried to save a site as a template and then create create a new site based on that template.  The save operation worked fine, but when she tried to create the new site, SharePoint displayed the following error message:

Error

The content type name ‘$Resources:ReportServerResources,DataSourceContentTypeName;’ cannot contain: \ / : * ? “ # % < > { } | ~ & , two consecutive periods (..), or special characters such as a tab.

Here’s a screen cap:

 

image

I had a look at the content types in the site and found this:

image

Those content types are clearly unhealthy.

This issue seems to come up a lot on the Internets and there doesn’t seem to be a single consensus on how to solve it.  I found a handy table that mapped the bad content type names to good content type names here: http://social.technet.microsoft.com/Forums/en-ZA/sharepoint2010programming/thread/cb03e866-8184-4943-acfe-cafffa1b8b7a.  I manually updated them thusly:

image

(BrightStarr in the name is obviously optional, but it can’t hurt Smile )

This allowed me to create a new template and didn’t break anything on the other sites, including some PerformancePoint Server stuff that a completely different group of people were working on.  I was then able to create a new site on the template.  Success!

I am not sure this is a 100% solution, but it got me and everyone involved past this annoying error.  If I find anything new, I’ll post an update.  My nervousness stems from the fact that these names shouldn’t be wrong in the first place and by fixing the display name, I am not touching the internal name. 

</end>

Subscribe to my blog.

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

Quick and Easy: Debugging VS 2010 Solution Deployment

Visual Studio 2010 reports hard-to-debug errors during deployment some times.  A quick and easy way to do some very rough debugging is to throw your own named exceptions.  Visual Studio will show them in the output console.

Consider this bit of code:

image

If this feature is scoped to a web application, site will be null.  If you try and reference a property of site, you’ll get the ambiguous error:

Error occurred in deployment step ‘Add Solution’: Object reference not set to an instance of an object.

However, if throw a new Exception and pass a string to the constructor, you get a slightly more useful message:

image

It’s a crude technique, but pretty fast and easy.

</end>

Subscribe to my blog.

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

Use owssvr.dll to Display Useful Site Information in SP2010

I was reading forums this afternoon and learned something new (something that happens almost every day).  This is the posting:

http://social.technet.microsoft.com/Forums/en-US/sharepointadmin/thread/1cbdb0b4-eeda-4c61-9a52-da6212eebec5/

Basically, you can get some interesting information about a site by invoking owssvr.dll against it (h/t to Bil Simser and John Timney).

I gave this a try in a both a MOSS and an SP2010 environment.  It worked fine in the MOSS environment.  However, in the 2010 environment, Internet explorer didn’t want to download the XML:

image

As you can see, I know it had 21k or so of content.  However, when I clicked the Save button, I got:

image

(Unable to open this Internet site.  The requested site is either unavailable or cannot be found.  Please try again later.)  

I fired up Fiddler and and I was able to see the output, however.  It seems like there may be something happening in SP2010 that prevents owssvr.dll from transmitting its XML payload the way it wants.  Or, my SP2010 environment is just acting funny.

Thought it was interesting…

</end>

Subscribe to my blog.

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