SharePoint Solutions Manager or The WSP Manager

Tool Description
Here is a nifty tool which can be used to deploy, redeploy, upgrade and retract/delete the solutions in the SharePoint environment. It handles all these jobs using the object model. This tool will be definitely handy for developers for quick deployment while debugging.

Purpose
The best way to get anything or any component into SharePoint environment is by creating a WSP aka Solution file. Many tools exists to create the WSP like WSPBuilder, STSDEV and Andrew Connell’s way of doing it. Having done that the next step would be deploying the same into SharePoint environment. WSPBuilder supports deploying directly though Visual Studio but some times it could get messy. It also limits to the project you set up using WSPBuilder. This tool is built in a generic way which can be used to manage already deployed solutions and also for deploying new solutions. So given a WSP file this tool can help you get that into SharePoint environment.

I agree there is another tool SharePoint Solution Installer on codeplex but I never was happy with that as it didn’t serve the purpose many a times for me. Moreover that tools was closed to administrators.

ShareTools Solution Manager does many things which can be done with stsadm command line tool. Below are a salient list of those:

  • View existing solutions in our server environment
  • Add new solutions
  • Upgrade existing solutions either immediately or at a given time
  • Redeploy an existing solution if you have a latest WSP of the same solution
  • Retract and Delete the existing solution
  • Deploy a new solution with all the parameters used in stsadm command line tool
  • Execute the administrative timer job definitions i.e stsadm.exe -o execadmsvcjobs with a single click of the button

Currently you can take action on a single item at a time.

You can download it from: http://solutionmanager.codeplex.com/

Unauthorized exception even after using SPSecurity.RunWithElevatedPrivileges

In various cases while developing custom web parts or controls for SharePoint we have to use the SPSecurity.RunWithElevatedPrivileges construct to execute some part of the code which needs elevated permissions or which cannot be run with the current user permissions. For example, updating a SPWeb object or SPList object needs elevated permissions.

If you are getting an unauhtorized access exception even after using this block then the reason could be as follows:

While using this construct: You cannot use the objects available through the Microsoft.SharePoint.SPContext.Current property. That is because those objects were created in the security context of the current user.

So the best practice for using the SPSecurity.RunWithElevatedPrivileges is to get the SPSite/SPWeb objects using the SPContext.Current and then create the SPSite and SPWeb objects seperately. See the code below:

 

SPSite siteColl = SPContext.Current.Site;
SPWeb site = SPContext.Current.Web;
SPSecurity.RunWithElevatedPrivileges(delegate() {
  using (SPSite ElevatedsiteColl = new SPSite(siteColl.ID)) {
    using (SPWeb ElevatedSite = ElevatedsiteColl.OpenWeb(site.ID)) {
        //Code to execute
    }
  }
});

The following code is wrong:

SPSecurity.RunWithElevatedPrivileges(delegate() {
    SPSite siteColl =    SPContext.Current.Site;
    SPWeb site = SPContext.Current.Web;
 //Code to execute

});

InfoPath Managed Form Templates Deployment Tool for SharePoint

This tool is an effort towards helping all those who are working on InfoPath Forms with SharePoint. It helps to upload/install, re-install, upgrade a form template with just a click of the button. The tool also can help in generating a script/batch file so that you can run it manually later on. Also, the tool has ‘Feature Management’ addon, using which you can see a list of activated and deactivated features using a filter if needed. It also provides the ability to activate, deactivate and uninstall a feature.
You can get the tool and read more about it at http://www.codeplex.com/InfoPathFormsInstall
Please let me know of the bugs and enhancements if anyone uses it.
Below is the screen shot of the tool:

InfoPath Form Template Deployer

InfoPath Form Template Deployer

Rapid access to 12 Hive and stsadm.exe

Every SharePoint developer needs to have quick access to the 12 Hive, 12Hive/Bin for the stsadm for various purposes in our daily development work. But, I have seen many of them never try to make this process easier. Even though this is a trivial issue, sometimes its pretty annoying. So here are a few ways to avoid those annoying moments.
(*12 Hive = C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\)

1. Add a shortcut link to the 12 Hive folder in the task bar.Just open the windows explorer and navigate to 12 Hive. Drag the left top corner icon and drop it on the task bar in the right corner. The end result is as follows:

2. Create a shortcut to the command prompt and set the default directory to the 12 Hive’s BIN directory. Add that shortcut to the quick launch bar so that it would be one click away. Even better, you can set shortcut key to open up the command prompt. Set the Target, Start in properties as following:
Shortcut to 12 Hive/BIN

3. Add the 12 Hive to your “Favorites” in the explorer window.

4. To have access to stsadm.exe command irrespective of the folder you are in. Update the “Path” environment variable to add the path to the 12 Hive/BIN folder. (Right click My Computer – Go to Advanced Tab – Click Environment Variable , under system variables, edit Path variable and append the 12Bin path using semicolon as a delimiter).

access stsadm.exe everywhere

5. This is yet another good one posted by Daniel in the comments:

“I usually create a junction point (officially a ntfs reparse point) in the file system using the junction tool from sysinternals (http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx)

junction.exe c:\wss “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\”

That gives me something like c:\wss pointing to the 12 hive and stsadm.exe under c:\wss\bin.

(I do the same for the Windows Debugging tools and create a junction for them under c:\Debug.)”

If you have any more options to make a developers life even more better and easier, please add to the comments.

ASP .Net tab missing or SharePoint site leading to Page not found and IIS 32/64-bit modes

Problems:

  • ASP .Net Tab Missing in the IIS Managers Website properties
  • SharePoint site shows “Page cannot be found error”.
  • SharePoint sites shows “You are not authorized to view this page”, “HTTP Error 403 – Forbidden: Access is denied.”
  • Either of the above problems in a server farm.

Possible Solutions:

There could be couple of reasons for the ASP .Net tab missing in the IIS manager. And this issue in turn could be the reason for the SharePoint site throwing the Page cannot be found or You are not authorized to view this page errors. Reasons that could be are:

  1. Improper installation of IIS and ASP .Net framework.
  2. IIS running in 32-bit mode on a 64-bit windows 2003 server.
  3. Having multiple versions of ASP .Net framework lying around on the machine which needs registry cleanup.

If your server is a 64 bit machine, then make sure your IIS is not running in 32-bit mode. For this run,

cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs GET W3SVC/AppPools/Enable32bitAppOnWin64

The output tells if enable32bitapponwin64 is true or false. If its true then, go ahead and run the following to disable 32 bit mode and enable 64 bit mode:

cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

If your server is a 32 – bit machine, and your ASP .Net tab is missing then, you might follow the below steps I found in this msdn blog post and KB Article from MicroSoft:

  • Manually run the install for ASP.NET: ASPNET_regiis -i
  • Register the dll for the MMC: regsvr32.exe “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mmcaspext.dll” “rundll32.exe” “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\webengine.dll”,RegisterAspNetMMC
  • From a command prompt run: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\AspNetMmcExt.dll /tlb:AspNetMMCExt.tlb
  • Change the About value in “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MMC\SnapIns\{fedb2179-2335-48f1-aa28-5cda35a2 b36d}” from {7D23CCC6-A390-406F-AB67-2F8B7558F6F7} to {7D23CCC6-A390-406F-AB67-2F8B7558F6F6}

If you want to have just the .net framework 2.0 on the machine go cleanup the earlier versions of it in the registry. Run regedit.exe and remove all the versions other than 2.0 below these registry entries:

  • HKEY_CLASSES_ROOT\CLSID\{7D23CCC6-A390-406E-AB67-2F8B7558F6F6}\InprocServer­32
  • HKEY_CLASSES_ROOT\CLSID\{FD5CD8B1-6FE0-44F3-BBFB-65E3655B096E}\InprocServer32
  • HKEY_CLASSES_ROOT\CLSID\{FEDB2179-2335-48F0-AA28-5CDA35A2B36D}\InprocServer­32

Try to unregister the .net framework and re-register it. Depending on your machine if 32/64-bit and the asp .net version (1.1 or 2.0?):

%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -u //for uninstallation

%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i //for installation

%SYSTEMROOT%\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -u //for uninstallation

%SYSTEMROOT%\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -i //for installation

If doing all the above doesn’t bring back the ASP .Net tab then reboot the machine.

Doing all this should at least get rid of the ‘Page cannot be found‘ error but may lead  to the authorization error.

For the 403 or the authorization error, if you get this error when you access the site using the url like http://portalsite:<port&gt; then try access the site as http://portalsite:<port>/default.aspx. If the later is successful then try to create a new application pool and map it to the corresponding website. Otherwise delete the web application and recreate it from scratch and it should work. This blog post something similar.

To learn more about how to maintain multiple versions of .net framework on the same machine and serve various web applications , read the article from MSDN which talks specifics about the same.

Using stsadm to deploy, upgrade, update InfoPath Forms Templates with Managed code behind

This post talks about using stsadm and batch scripts to deploy InfoPath form with code behind which usually is called as InfoPath forms with managed code or the InfoPath forms managed templates.

The problem: If it’s just a couple of InfoPath forms with simple code behind we can deploy the form using the InfoPath Forms Client application itself. As laid out neatly here. To summarize, it involves the following steps:

  1. Publish to a network location
  2. Verify its browser compatible while uploading to InfoPath managed templates in Central Admin.
  3. Upload to InfoPath managed templates found in Central Administration
  4. Wait for the status to upload complete.
  5. SharePoint admin should activate it for a particular site where the developer want to use it.
  6. Wait for the activation to complete.

Imagine doing all this every time you make change to the code behind of the form or change the user interface. The worst part is waiting for the status to get completed as SharePoint does those kind of jobs based on the timer job service. To run these tasks forcefully the stsadm’s execsrvcjobs command operation comes handy.

Below is the script to install a new infopath form template and activate for a particular site collection:
::Publish the form to a location lets say it is published at C:\InfoPathForms\Publish\sample.xsn
cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
::uncomment the below three lines if you want to uninstall and re-install the infopath form template
::stsadm.exe -o DeActivateFormTemplate -url http://demosite -filename ::C:\InfoPathForms\Publish\sample.xsn
::stsadm.exe -o RemoveFormTemplate C:\InfoPathForms\Publish\sample.xsn
::stsadm.exe -o execadmsvcjobs
stsadm.exe -o verifyformtemplate -filename C:\InfoPathForms\Publish\sample.xsn
stsadm.exe -o UploadFormTemplate -filename C:\InfoPathForms\Publish\sample.xsn
stsadm.exe -o execadmsvcjobs
stsadm.exe -o ActivateFormTemplate -url http://demosite -filename C:\InfoPathForms\Publish\sample.xsn

Below is the script to upgrade or update the existing infopath form template for a site collection:
cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
stsadm.exe -o DeActivateFormTemplate -url http://demosite -filename C:\InfoPathForms\Publish\sample.xsn
stsadm.exe -o verifyformtemplate -filename C:\InfoPathForms\Publish\sample.xsn
stsadm.exe -o UpgradeFormTemplate -filename C:\InfoPathForms\Publish\sample.xsn
stsadm.exe -o execadmsvcjobs
stsadm.exe -o ActivateFormTemplate -url http://demosite -filename C:\InfoPathForms\Publish\sample.xsn

UPDATE: If you just changed the code behind of the form and want to deploy it there is even better and quicker way to do it. When the form is deployed using the above stsadm scripts what it does is, it depoys the form as a content type feature and the folder name is some what like FT- which is found under C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\
Under this you will find folder liek solution.xsn.1.0.0.210.1.0.0.210. Find the latest one and drop the updated DLL’s in there and then reset the IIS or recycle the app pool for the site collection. That is it!!

PS: I got the initial help of preparing the batch script from here.

InfoPath cannot connect to a data source when viewed in browser – Cross Domain Issues – Universal Data Connection

InfoPath cannot run the specified query.

InfoPath cannot connect to the data source.

Access is denied.

One of the big issues with InfoPath Forms is its error reporting. It could sometimes piss you off. It says there is a problem that is it! We have to spend lot of time clicking and clicking and clicking buttons all over trying to find where is the problem. May be that is how these tools should work…

Steps to go with when you get the above error:

  1. The above error seems to be quite often and it hints that there is some problem with the ‘Data Source/Connection’. If the form is showing the error while loading i.e form never loads but shows a message to ‘continue or start over’, then there is some problem with the data source which is set up to ‘Automatically retrieve data when form is opened’.
  2. If the above is the situation then open up the Data Sources window (Tools – Data Connections) and make sure that the data connection is set up properly and the data source is in place, working and serves requests.
  3. If the above error is shown when user does some action like clicking on button, then check the Rules in the properties of that control (button) and check for those data sources/connections.
  4. If the form works fine when previewed as an application but throws the above error after publishing to SharePoint site or when viewed as a browser form, then most probably the problem will be with the cross domain issue. If the InfoPath is trying to query or submitting to a web service (could be any other data source) and that web service is hosted as http://xyz.com/service.asmx and the sharepoint site is hosted as http://abc.com then thats called a cross domain issue. The infopath form is trying to talk to a service which is hosted in a different domain and it can’t trust it. This can be solved by giving full trust to the form(Tools – Form Options – Security and Trust) but its not the right way to go and your SharePoint admin might restrict that. The only way to go is setting the security and trust to ‘Domain’ and converting the existing data connections or just the cross domain connections to Universal Data Connection (UDC) format. Its very simple to do and gets rid of any cross domain issues. To create UDC connections read this article. For those who have no patience to read the article, below are the quick steps involved:
    1. If Universal data connection document library doesn’t exist in the SharePoint site then create one or request your admin to create one and give you proper rights for you. (Go to ‘View all site content’ – Create – Universal Data Connection Library)
    2. Open up the InfoPath forms Data Connections window, select the cross domain data source connect and then click the ‘Convert’ button and follow the wizar. You need to provide the above created UDC library along with a name for the file for example: http://abc.com/udclibraryname/sampleudc.udcx
    3. Now that is not enough, either you or your admin should approve the sampleudc.udcx document created in the UDC library.
    4. Re-publish the InfoPath form to SharePoint and test it.
  5. In central administration, under InfoPath Forms Services configuration, there is a checkbox to allow cross-domain issues. I am not sure if this is done then above UDC is still required or not. I will update as I learn about it.

More links worth to read:

MOSS WSS Components Architecture in a single diagram

I stumbled upon this image in one of the msdn forms. This image grabbed my attention at once because in single image it encompassed all the components for Windows SharePoint Services(WSS), MS Office SharePoint Server 2007(MOSS) and the various dependent components and add-on servers. Keep this handy to answer any quick question by your friend or a business user.

MOSS-WSS-Components-Architecture

I found this MOSS logical architecture diagram from msdn available in visio and XPS format.

http://www.microsoft.com/downloads/details.aspx?FamilyID=14c6b1c1-ad26-4ed0-87b8-b691ebdd9662&displaylang=en#filelist

Below is the JPEG format of the same:

MOSS Logical Architecture

SharePoint & Windows Workflow Foundation – (Sequential, State Machine Workflows, InfoPath Forms)

Below are the plethora of links to learn Workflows and its integration with SharePoint using InfoPath forms and or ASPX pages. You will find here some nice resources for State Machine Workflows in particular.

If you are new to workflow development then as a 1st step towards it, learn sequential workflows. Either read my former blog post or go for this step by step sequential workflow example.

http://channel9.msdn.com/Showpost.aspx?postid=122931 – this is a quick 9 min video: I recommend this to be your 1st step towards learning state machine workflows. For a detailed video of the same example check out the MS webcast by Pravin Indurkar. The Order Processing Application code is available for download in the below Microsoft Workflow Samples link.

http://msdn2.microsoft.com/en-us/library/ms741723%28VS.85%29.aspx – Windows Workflow Foundation Samples

http://blogs.msdn.com/sharepoint/archive/tags/Workflow/default.aspx – 7 part series

http://kcdholdings.com/blog/?p=68 – links/recommended books

http://jopx.blogspot.com/2008/02/sharepoint-workflow-link-wrap-up.html – More links …

http://www.mannsoftware.com/Blog/?cat=15 – Blog

http://www.devx.com/webdev/Article/34032/0/page/1

The below 4-part series is a good and The Best example or sample available related to Workflows and SharePoint:

https://blogs.pointbridge.com/Blogs/morse_matt/Pages/Post.aspx?_ID=9

https://blogs.pointbridge.com/Blogs/morse_matt/Pages/Post.aspx?_ID=11

https://blogs.pointbridge.com/Blogs/morse_matt/Pages/Post.aspx?_ID=15

https://blogs.pointbridge.com/Blogs/morse_matt/Pages/Post.aspx?_ID=16

https://blogs.pointbridge.com/Blogs/morse_matt/Pages/Post.aspx?_ID=20

Windows Workflow Foundation – Excellent Use Case: http://www.microsoft.com/belux/msdn/nl/community/columns/kurtclaeys/wf.mspx

Add Custom ASPX Pages or ASP .Net Pages in SharePoint

The Problem: Let’s say we have an ASP .Net Web Application with many web forms, user controls, business layer, and data access layer. It works fine as a web application. What we are looking for integrating the files within this web application into the SharePoint site and totally get rid of the web application. This has couple of advantages:

  1. Business users and end users need not go to a separate web application (URL). Users can see all those pages within SharePoint site.
  2. Once the integration is done, we have the SharePoint site’s security and access rules i.e. Authentication and Authorization is in place without any additional work.
  3. Simple development experience as compared to developing with web parts.

In a nutshell this option allows us to build an ASP.Net application outside of SharePoint, build it, test it & then add it to SharePoint. Now, the problem is what are the ways to deploy the ASP .Net application pages into SharePoint and which one is should we go with. After doing some research and work I found that there are many ways in which we can do this. Below is a brief discussion of the sam.

Solutions:

  1. The SharePoint designer approach: This approach can be used if there are few aspx pages with little functionality.
  2. Using web parts. This can be used in conjunction with SharePoint designer. But once again, developing many web parts is not feasible and also raises performance issues.
  3. _Layouts folder approach: This is the simplest of all. Just deploy the web application pages under the _layouts folder of SharePoint and the pages can be accessed from any SharePoint site. Cons: The pages don’t inherit the security and access rules from SharePoint. The pages can be accessed from any site existing on that server farm. Master Page integration is not possible. MSDN Article explains with a sample.
  4. User controls using Smart Part: In this approach, the developer can develop web parts using the third party Smart Part control. In this way the developer can have the drag – drop functionality as he/she can develop it as a user control and drop it in the smart part. This method is similar to web parts but the developer has the privilege of drag-drop functionality but it still carries the negatives mentioned for the web parts approach.
  5. Using features and WSP package: Following some steps as recommended by Andrew Connell (MOSS MVP). Here is the blog. I believe this is the standard approach users are using in the SharePoint developer community.
  6. Using VSeWSS (Visual Studio extensions for WSS): This is yet another and latest solution. Microsoft recently released the VSeWSS 1.1 RTM. Using this, we can deploy all the asp .net pages into SharePoint by setting up a new project in Visual Studio. VSeWSS creates a solution package using features. Setup the project and hit ‘Deploy’ and it is done.

Below are the blog links I referred to:

http://blogs.msdn.com/cjohnson/archive/2006/09/05/application-development-on-moss-2007-amp-wss-v3.aspx

http://blogs.msdn.com/cjohnson/archive/2007/12/15/building-a-simple-asp-net-page-based-sharepoint-application-in-visual-studio-with-the-visual-studio-extensions-for-wss-ctp-1-1.aspx

http://www.andrewconnell.com/blog/articles/UsingCodeBehindFilesInSharePointSites.aspx

http://www.andrewconnell.com/blog/articles/UsingVisualStudioAndMsBuildToCreateWssSolutions.aspx

More Links: Some are related to SharePoint 2003.

http://www.sharepointblogs.com/jessefitz/archive/2008/01/24/integrating-an-asp-net-application-into-our-sharepoint-portal.aspx

http://www.bluedoglimited.com/SharePointThoughts/ViewPost.aspx?ID=242

http://aspalliance.com/936_Including_Your_Own_ASPNET_Pages_in_Your_SharePoint_Portal.all

Yet another nice contribution by Andrew Connell :

http://www.wrox.com/WileyCDA/Section/id-305859.html

Follow

Get every new post delivered to your Inbox.