Skip to main content
SharePoint Evolved, Small Steps for a Big Solution

Blog

Go Search
Home
Blog
Wiki
Contact
Themes
TV
  

SharePoint Evolved > Blog
Sandboxed Solution Error: The UserCodeToken is Invalid
Sandboxed Solution Error: The UserCodeToken is Invalid

I have been playing around with the Sandboxed Solution capability in SharePoint 2010. It's quite powerful and I have been trying to test the limits in regards to practical solutions. While deploying a new Sandboxed Solution to my farm, I ran into the following error:

The error says "Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: The UserCodeToken is invalid". While this error message is very descriptive, it wasn't very helpful in determining a solution. No events in the error

Visual No Longer a Dirty Word for Sandboxed Solutions
Visual No Longer a Dirty Word for Sandboxed Solutions

Part of the allure of SharePoint 2010 is the ease in which customizations can be developed and deployed to your SharePoint environment. The dark spot on the silver lining was that Visual Webparts in Visual Studio required the solution to deploy as a Farm Solution. In this case it requires modifications to the file system that can only be done when deployed as a Farm Solution. Farm level deployment is not available to the majority of developers out there, so developers writing solutions for sandboxed environments were forced to do the visual rendering manually.

The team working with the Power Tools for Visual Studio has come up with a solution that enables any developer to create visual webparts for sandboxed solutions. Taking it one step further they also customized the compilation process to alert you when you've used members or functions unavailable in the sandboxed environment. You'll first need to download the Visual Studio SharePoint Power Tools pack from the Visual Studio Gallery.

Once you have the tool pack installed, you'll want to create an empty SharePoint project, I've chosen to name mine SandboxedVisualWPTest in this scenario.

   

Choose the Deploy as Sandboxed Solution option on the SharePoint Customization Wizard and it will create the empty project for you.

From here you'll want to right click in the Solution Explorer on the Project and select "Add" -> "New Item"

   

You'll see the option for Sandboxed Visual WebPart partly down the list, create your own name I chose "MySBVisualWebpart"

Note: You'll see if you have the CKSDev tools installed on your machine that there is also a "Sandboxed Visual Web Part" which is different from this latest release. It's an easy mistake to make, I did it myself.

You'll see that it added the webpart as a user control, and it has opened up the Source view for you

 

You can switch over to the Design view to start creating your webpart. I have added a CheckBoxList control as well as a TextBox and a Button just to demonstrate the drag and drop functionality.

   

You can enter whatever code you like, but I'm just going to demonstrate adding the text existing in the TextBox to the CheckBoxList

   

At this point please feel free to deploy the sandboxed solution in whatever method you like. You have the choice of using "F5" deployment or packing up the solution and using the solutions gallery to deploy. It's easier to use F5 to debug any errors that my come up during runtime. In my environment, I have configured a page in which I test webparts, and I now need to add the webpart to the page. On the ribbon, choose the "Insert" tab and from there select the webpart icon. Choose the webpart that you've created under the custom category and add that webpart to the page.

   

You should now be able to interact with your webpart like any other on SharePoint, and you'll have the created a SharePoint solution in under ten minutes.

   

This capability really shows how quick and easy it is to deploy a webpart to SharePoint, without having to have server side access. The learning curve necessary for developers coming from other technologies is substantially reduced with the visual webparts regardless of whether the solution is deployed to the farm level or not. Special thanks to Mike Morton and the team who gave us this capability for SharePoint. Be sure to send them lots of positive feedback.

/Isaac

Quick TagReader for Android Demonstration
Quick TagReader for Android Demonstration

Downloaded the new TagReader for Android and thought I'd give a short demonstration how it works on the platform.

 

More About the Tag Reader:

Create your own tags here: http://tag.microsoft.com/

Adding Dynamic Bing Search to CKS:EBE Blogs
Adding Dynamic Bing Search to CKS:EBE Blogs

I ran into the issue where I was modifying themes for multiple blog sites on the MicroLink Blogs site: http://blogs.microlinkllc.com and I decided to modify the themes to use Bing search for the blogs. Bing search provides search results without ever leaving the page, and you can scope the results to the site, site collection, or parent domain; its quite customizable. You can see this in the screen capture:

The issue is that it can be quite tedious to modify the javascript for each blog, and keep it updated for the different sites. I went searching for a solution, and found that I could use the tags from the Community Kit for SharePoint Enhanced Blog Edition. The solution is to use the following tag within the javascript <asp:Literal ID="Literal1" runat="server" Text="<%$BlogUrl:~site%>" /> This just returns the current blog in a relative url which you can use to set the scope of the blog for the search. The script that makes this possible is below:

    "type":"web", -> Type of the scope

    "caption": "&#x54;&#x68;&#x69;&#x73;&#x20;&#x42;&#x6C;&#x6F;&#x67;",-> Sets the title of the Scope, in this case "This Blog"

    "searchParam":'site:http:\/\/blogs.yourdomain.com\<asp:Literal runat="server" Text="<%$BlogUrl:~site%>" />' -> This is sets the scope to the current blog

 

To modify this for use on your blog sites you'll have to change the url in the SearchParam field, change the domain to your collection and then you can change the caption of the search cope to what you desire. These values have to be encoded and I recommend using a utility such as Ishida's Unicode Converter to generate the text that you desire. You can find it here: http://people.w3.org/rishida/scripts/uniview/conversion.php

The complete script can be found below:

<meta name="Search.WLSearchBox" content="1.1, en-US" />

<div id="WLSearchBoxDiv" style="float: right; text-align: right; padding: 10px 10px 0px 0px;">

<table cellpadding="0" cellspacing="0" style="width: 230px; height: 32px;">

<tr id="WLSearchBoxPlaceholder">

<td style="width: 100%; border: solid 0px #cccccc; border-right-style: none; padding-left: 10px;

padding-right: 10px; vertical-align: middle;">

<input id="WLSearchBoxInput" type="text" value="&#x4c;&#x6f;&#x61;&#x64;&#x69;&#x6e;&#x67;&#x2e;&#x2e;&#x2e;"

disabled="disabled" style="background-image: url(http://www.bing.com/siteowner/s/siteowner/searchbox_background_k.png);

background-position: right; background-repeat: no-repeat; font-family: Arial;

font-size: 14px; color: #000000; width: 100%; border: none 0 transparent;" />

</td>

<td style="border: solid 0px #cccccc; border-left-style: none; padding-left: 0px;

padding-right: 3px;">

<input id="WLSearchBoxButton" type="image" src="http://www.bing.com/siteowner/s/siteowner/searchbutton_normal_k.gif"

style="border: none 0 transparent; height: 24px; width: 24px; vertical-align: top;" />

</td>

</tr>

</table>

 

<script type="text/javascript" charset="utf-8">

    var WLSearchBoxConfiguration=

    {

        "global":{

            "serverDNS":"www.bing.com",

            "market":"en-US"

        },

        "appearance":{

            "autoHideTopControl":false,

            "width":600,

            "height":400,

            "theme":"Blue"

        },

        "scopes":[

            {

                "type":"web",

                "caption": "&#x54;&#x68;&#x69;&#x73;&#x20;&#x42;&#x6C;&#x6F;&#x67;",

                "searchParam":'site:http:\/\/blogs.microlinkllc.com\<asp:Literal runat="server" Text="<%$BlogUrl:~site%>" />'

            }

            ,

            {

             "type": "web",

             "caption": "&#x4D;&#x69;&#x63;&#x72;&#x6F;&#x4C;&#x69;&#x6E;&#x6B;&#x2C;&#x20;&#x4C;&#x4C;&#x43;&#x20;&#x43;&#x6F;&#x6D;&#x6D;&#x75;&#x6E;&#x69;&#x74;&#x79;&#x20;&#x42;&#x6C;&#x6F;&#x67;&#x73;",

             "searchParam": 'site:http:\/\/blogs.microlinkllc.com'

            }

            ,

            {

                "type":"web",

                "caption":"&#x57;&#x65;&#x62;",

                "searchParam":""

            }

        ]

    }

    </script>

    <script type="text/javascript" charset="utf-8" src="http://www.bing.com/bootstrap.js?market=en-US&ServId=SearchBox&ServId=SearchBoxWeb&Callback=WLSearchBoxScriptReady"></script>

 

<!-- Bing -->

This script generates the following output using the three different scopes This Blog, MicroLink, LLC Community Blogs, and Web

Working with Windows Live Authentication and SharePoint
Working with Windows Live Authentication and SharePoint

I recently began a quest, deciding how to use a domain that I purchased recently. I came upon the idea of using Tobias Zimmergren's Discussion web parts as a starting point for an online discussion for SharePoint Users. Not a huge undertaking, but it did present a problem. Account management for any public site can be difficult, considering SharePoint's structure it can be even more so. After weighing Active Directory in Creation Mode, Straight SharePoint Security and more universal authentication mechanisms, I decided to try out Windows Live Authentication. Two options that are under consideration are Facebook Connect and OpenID.

    After deciding to go with Windows Live Authentication, I then set about researching options for using WLA with SharePoint. I came up with three options, the first being the Community Kit for SharePoint's solution which was released over two years ago and has not had a major release in a while. The second is a project by Wictor Wilen of the Swedish SharePoint Community which was announced this past April. The last is a trialware solution by Shetab Tech which is a commercial product with a price tag of $269.

CKS Windows Live Authentication

I downloaded and installed the solution and followed the instructions to configure it correctly. Following the instructions can be a little counter intuitive and while is sets up the default zone for windows live authentication, it may not be the desired result in a multi-zone installation. Once I got this up and running the only thing left to do was to enable anonymous access and set up user permissions. Being that this was my first attempt setting up Windows Live Authentication for SharePoint, I hit many snags and issues. Some are well known within the SharePoint Community including assembly caching, others involved correct parameters and web.config settings.

I have found that deviating from the instructions a bit is the easiest way to get CKS WLA up and running. I used the following web.config settings as opposed to the recommended instructions.

Recommended:

<membership defaultProvider="LiveID">

 

<roleManager defaultProvider="LiveRoles" enabled="true" cacheRolesInCookie="true" cookieName="liveroles">

 

I Used:

<membership>

<providers>

<add name="LiveID" type="CKS.WindowsLiveAuthentication.LiveMembershipProvider, CKS.WindowsLiveAuthentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b5adbad25a892e4a" />

</providers>

</membership>

<roleManager>

<providers>

<add name="LiveRoles" type="CKS.WindowsLiveAuthentication.LiveRoleProvider, CKS.WindowsLiveAuthentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b5adbad25a892e4a" enabled="true" cacheRolesInCookie="true" cookieName="liveroles"/>

</providers>

</roleManager>

 

 

Windows Live ID for SharePoint

After adding the solution and deploying to the server and configuration for this solution was a lot more straightforward and used an application page in Central Administration page. The process is pretty self explanatory but the documentation is robust for an open source project. Installation consists of activating a couple features at the site and farm level, the easiness of this installation is a major plus of using this project.

 

 

Short Comparison
 

CKS Windows Live Authentication

Windows Live ID for SharePoint

Farm Configuration

Application Page in Central Administration

Command line with STSADM

Site Configuration

Application Page in Layouts

Part of STSADM Command Line Setup

Administration Web Parts

N/A

All Members, Last Logged In Members, Last Updated Members, New Members

Security Groups

Authenticated Live Users

Authenticated Live User, Live Users, Unapproved Live Users, Locked Live Users

 

Shetab WLA for SharePoint

This product looked interesting from its website, but this is actually a commercial product which put it out of the running for this no budget project. I think it deserved inclusion in this short list of Windows Live Authentication providers.     

The Result

By far the Windows Live ID for SharePoint fit the billet for this project. The robustness of the solution and the ease of configuration made this one a win in my book. It would have been much easier if I had tried this solution first, but using CKS WLA first helped me understand the solution much more, and made installation much easier the 10th time around.

Recommendations

Most guides recommend installation on the default zone, the approach I took was to extend my zone into the internet zone. This is how I would recommend doing it in other secnarios, mainly because it enables integrated authentication on your main url which in my case is much better for development. Each situation is different, but this approach worked best, and I would recommend it again.

Article Resources

SharePoint Conference 2009 Kicking Off
SharePoint Conference 2009 Kicking Off

As people slowly trickle in to Las Vegas for the SharePoint Conference this week, I wanted to point out a couple resources that will help you follow the storm of information after the calm. If you're not on twitter, now may be a good time to join and acquaint yourself with some of the SharePoint Twitterati. Or you can just follow the tweets and livebloging coverage from many of the blogs that will be following the conference.

Preparing for the SharePoint Conference:

  • Joel Oleson's 10 Step Program to Prepare for the Event [link]
  • Friendly Advice for Blogger Covering the Conference from Michael Gannotti [link] How True!

Informational Dashboards

  • SharePoint Development Wiki [link] As Information becomes available about development in the next version of SharePoint, the wiki pages will be updated, probably quite quickly. Perhaps subscribe to the RSS feed of Changes [RSS Feed]
  • End User SharePoint's Conference Dashboard for Twitter and LiveBlogging [link] Caution: 1 Twitter Stream, and 7 Live Blogging groups will ensure an overload of information.
  • Make Your Own Dashboard from End User SharePoint [link]

Other Links

  • My Schedule if You're Interested in Meeting Up In The Sessions [link]
  • #ShareEvents [link] Where SharePointers get together in a relaxed setting wether its dinner, drinks, or a show.
  • Where to Eat In Vegas A Local's Perspective [link]
  • Conference Website [link] Catch the Keynote Streamed Live!
  • Follow Mike Gannotti(The SharePoint Samurai) Through his Twitter Stream[link]

I'll be updating this post as information comes out, but now its time to travel. So I am boarding a plane here soon, but I look forward to meeting everyone in Las Vegas.

Dynamically Generating Technorati Tags for SharePoint Blog Posts
Dynamically Generating Technorati Tags for SharePoint Blog Posts

For those of you who post regularly, Technorati is a great way to categorize your posts on the Technorati site, it is also a great way for other blog search engines to figure out what your posts are about. Its also good for you to see what other content is generated the category that you're writing about. I personally forget to create the Technorati Tags in my blog posts, so I wanted a way to create the tags automatically with SharePoint. One thing that I've done differently with my blogs is enabled the Category lookup for selecting multiple items from the Category list. You don't need to do this for this script to work, but this modification was designed for tagging multiple categories with ease.

This is the first step is to enable multiple categories on your blog post list. Navigate to the list settings for the Posts list.

Make sure you select the "Allow Multiple Values" field underneath the Title selection.

Next we're going to want to open up the Post.aspx file in SharePoint Designer.

Navigate to "Data View" -> "Insert Data View "on the Toolbar. Click on the Posts List, and go to "Show Data"

From the Current Data Source View, select only the Category Field, and select the button that says "Insert Selected Field as" and select "Single item View"

Now we need to turn of Paging for the view:

Sometimes it automatically creates the PostID Paramter for you, but if it doesn't show up in the Parameters dialog, you will need to create a new parameter that is called ListID. Select New Paramter and choose "Query String" from the Parameter Source. The Query String Variable should be "ID" and you can put whatever default you like. I put the ID of the first blog post that I have.

Next you need to filter by that PostID which you just created. The Field name should be ID, with the "Equals" comparison and the value you should find at the bottom of the Value list which is "[PostID]". Hit OK to filter the view.

.

Now here comes the fun part, we need to modify the XSLT to strip some of the formatting that SharePoint uses for multiple categories and enable multiple tags for multiple categories. Luckily I've done all the hard work already, so you should just need to copy this script into your Code View. Find the <xsl:template name="dvt_1.body"> and the <xsl:template name="dvt_1.rowview">

tags in your body. Select both templates them and replace them with the following code in your source code view.

 

<xsl:template name="splitstr">

<xsl:param name="str" select="."/>

<xsl:choose>

<xsl:when test="contains($str,';')">

<xsl:text disable-output-escaping="yes">&lt;a href=&quot;http://technorati.com/tag/</xsl:text>

<xsl:call-template name="technorize">

<xsl:with-param name="tag" select="substring-before($str,';')"></xsl:with-param>

</xsl:call-template>

<xsl:text disable-output-escaping="yes">&quot; rel=&quot;tag&quot;&gt;</xsl:text>

<xsl:value-of select="substring-before($str,';')"></xsl:value-of>

<xsl:text disable-output-escaping="yes">&lt;/a&gt;</xsl:text>

<xsl:text> | </xsl:text>

<xsl:call-template name="splitstr">

<xsl:with-param name="str" select="substring-after($str,';')"></xsl:with-param>

</xsl:call-template>

</xsl:when>

<xsl:otherwise>

 

<xsl:text disable-output-escaping="yes">&lt;a href=&quot;http://technorati.com/tag/</xsl:text>

<xsl:call-template name="technorize">

<xsl:with-param name="tag" select="$str"></xsl:with-param>

</xsl:call-template>

<xsl:text disable-output-escaping="yes">&quot; rel=&quot;tag&quot;&gt;</xsl:text>

<xsl:value-of select="$str"></xsl:value-of>

<xsl:text disable-output-escaping="yes">&lt;/a&gt;</xsl:text>

 

</xsl:otherwise>

</xsl:choose>

</xsl:template>

<xsl:template name="technorize">

<xsl:param name="tag"></xsl:param>

<xsl:choose>

<xsl:when test="contains($tag,' ')">

<xsl:value-of select="substring-before($tag,' ')"></xsl:value-of>

<xsl:text>+</xsl:text>

<xsl:call-template name="technorize">

<xsl:with-param name="tag" select="substring-after($tag,' ')"></xsl:with-param>

</xsl:call-template>

 

</xsl:when>

<xsl:otherwise>

<xsl:value-of select="$tag"></xsl:value-of>

</xsl:otherwise>

</xsl:choose>

</xsl:template>

<xsl:template name="dvt_1.body">

<xsl:param name="Rows"/>

<xsl:param name="FirstRow" />

<xsl:param name="LastRow" />

<xsl:for-each select="$Rows">

<xsl:variable name="dvt_KeepItemsTogether" select="false()" />

<xsl:variable name="dvt_HideGroupDetail" select="false()" />

<xsl:if test="(position() &gt;= $FirstRow and position() &lt;= $LastRow) or $dvt_KeepItemsTogether">

<xsl:if test="not($dvt_HideGroupDetail)" ddwrt:cf_ignore="1">

<xsl:call-template name="dvt_1.rowview" />

</xsl:if>

</xsl:if>

</xsl:for-each>

 

</xsl:template>

<xsl:template name="dvt_1.rowview">

<tr>

<td>

<table border="0" cellspacing="0" width="100%">

<tr>

<td width="25%" class="ms-vb">Technorati Tags</td>

<td width="75%" class="ms-vb">

<xsl:call-template name="splitstr">

<xsl:with-param name="str" select="@PostCategory"></xsl:with-param>

</xsl:call-template>

</td>

</tr>

</table>

</td>

</tr>

</xsl:template>

 

You should end up with the following output:

SharePoint Saturday Copenhagen Welcome
SharePoint Saturday Copenhagen Welcome

 


Welcome to SharePoint Saturday Copenhagen

It is our pleasure to welcome you to SharePoint Saturday in Copenhagen on August 22nd. SharePoint Saturday Copenhagen is a free event for professionals who have an interest in SharePoint, and would like to learn more about the product. The speakers at the conference are a mix of Consultants, Professionals, and SharePoint MVPs who are valued for their community contribution. The purpose of this event is to engage the SharePoint community both locally and internationally. Topics will be presented by a variety of Danish and International SharePoint professionals, making this a truly international event.

A wide variety of topics will be covered that should appeal to any professional that works with SharePoint on a daily basis. This includes a specific Business Track that will enable decision makers to share ideas and experiences in a collaborative environment. Other tracks will include an IT Professional track whose subjects will include Administrative duties regarding SharePoint, or the Architecture track which covers Governance among other topics. The last track is a Developer track that is focused on a deep dive into SharePoint development. The developer track will culminate in a collaborative session where attendees can bring their issues or questions and have them answered by a panel of SharePoint Experts.

While networking is not the purpose of this event, beneficial relationships can be formed while interacting with colleagues at the event. Attendees will have a chance to meet some of the premiere companies producing SharePoint products. SharePoint Saturday is a sponsor funded event and would not be possible without the generosity of the sponsors. We encourage attendees to visit the sponsor booths and find out more about how SharePoint can be enhanced through third party products and services.

Lastly, I would like to focus on the community aspect of SharePoint Saturday. It started as a community event for a few SharePoint professionals in New York about a year ago. It has since grown into an event that has reached three continents in such a short time. Community events like SharePoint Saturday make working with SharePoint even more enjoyable. SharePoint is a collaborative platform, and SharePoint Saturday is hoping to expand that collaboration to the entire industry.

More information about SharePoint Saturday Copenhagen can be found at the website listed below, or via the email also listed below.


Take the Next Step, Register for SharePoint Saturday Copenhagen
http://spscph.eventbrite.com

 

SharePoint Saturday Copenhagen August 22nd, 2009 in Lygby, Denmark
Email: spscph@live.com Website: http://www.spscph.dk

Fixing a 404 Error on CKS:EBE Blog Post
Fixing a 404 Error on CKS:EBE Blog Post

I was troubleshooting a colleague's blog, the blog in question had a post that would throw a 404 error whenever browsed to the full name of the post. If you're familiar with Community Kit for SharePoint, the Enhanced Blog Edition, you'll know that when you open a url to a post that doesn't exist or has been deleted, it redirects you to the main page of the blog, which makes this error even more intriguing. CKS:EBE was recognizing the post, but somewhere along the line, was not able to display the post.

I tried changing the title of the blog post to no avail, as well as created other posts that I thought would end up throwing the 404 error. What I ended up doing is changing the "BlogTitleForUrl" field on the post. It went from the original title,

To this title with an update prepended to the post.

And this fixed the problem that you can see here.

Announcing SharePoint Saturday Copenhagen
Announcing SharePoint Saturday Copenhagen

It is my pleasure to announce the first European conference of the SharePoint Saturday Series. The event will happen on August 22nd in the Copenhagen, Denmark. Come join SharePoint professionals in a day of learning and interacting in all aspects of SharePoint. Come hear talks on SharePoint Administration, Development, Architecture and more. There will be presentations that will engage anyone works with SharePoint. SharePoint Saturday is free to all attendees and a not for profit event.

Visit the SharePoint Satuday Copenhagen site: http://www.sharepointsaturday.org/copenhagen

Interested at speaking at SharePoint Saturday in Copenhagen? Contact spscph@live.com to receive a speaker submission form.

If you would like to sponsor Sharepoint Saturday Copenhagen, please send an email to spscph@live.com and we will send you a sponsorship package.

1 - 10 Next