Saturday, November 6, 2010

CMAP Presentations

Please see http://alex-tfs.blogspot.com/2010/11/cmap-presentations.html for the presentations I made on Application LifeCycle Management (ALM) and de SharePoint Control Container Web Part (deCCWP) for ASP.Net User Controls.

Saturday, September 25, 2010

Resources for 2010 Development

Click on http://tinyurl.com/2010move to download an ebook titled "Moving to Microsoft Visual Studio 2010".

Click on http://tinyurl.com/sp2010pptx to download 17 advanced developer training presentations on SharePoint 2010.

See http://tinyurl.com/sp2010apps for "Developing Applications for SharePoint 2010" where you can download a guidance documentation, detailed examples, and a reusable class library to help developers and architects make the right decisions and follow proven practices when designing and developing applications for SharePoint 2010. The guide has four core areas: application foundations, execution models, data models, and client models. It also includes eight reference implementations illustrating the core concepts covered in the guide. The reusable class library provides code to help developers build more manageable, flexible, and testable applications. Source code is provided for all reference implementations and for the reusable library. The reference implementations have automated setup scripts to configure the applications.

See http://tinyurl.com/sdk2010 for the SharePoint 2010 SDK. It includes documentation and code samples for Microsoft SharePoint Foundation 2010 and for Microsoft SharePoint Server 2010, which builds upon the SharePoint Foundation 2010 infrastructure. The documentation includes detailed descriptions of the technologies that SharePoint Server 2010 and SharePoint Foundation 2010 provide for developers, reference documentation for the server and client object models, and step-by-step procedures for using these technologies and object models and programming with them. This SDK also includes best practices and setup guidance to help you get started with your own custom applications that build and extend upon the SharePoint Foundation 2010 and SharePoint Server 2010 platforms.

Wednesday, September 22, 2010

InfoPath Form Services for SharePoint 2010 is Missing

Yesterday I was working with my new SharePoint 2010 development farm. I had an InfoPath form template (i.e. .xsn file) to deploy. I opened up SharePoint Central Administration and went to the General Application Settings page (i.e. generalapplicationsettings.aspx on the Central Admininstration site). I noticed that the "InfoPath Forms Services" section between "External Service Connections" and "Site Directory" is missing.

Obviously I didn't have the Enterprise version installed. So here's how I solved it:
1. Go to MSDN subscriptions - http://msdn.microsoft.com/en-us/subscriptions/downloads/default.aspx
2. Login and open/expand the Servers link in the left navigation to find the "SharePoint Server 2010" product.
3. In the content panel you'll see the "SharePoint Server 2010 (x64) - DVD (English)" product information display. Click on the "View" link of the "Keys" column. Copy the "Enterprise CAL" product key for use in step #7 below.
4. I opened up SharePoint Central Administration and went to the (i.e. upgradeandmigration.aspx on the Central Admininstration site).
5. In the "Upgrade and Patch Management" section click on the "Convert farm license type" link to bring up the Conversion.aspx page.
6. Enter in the new product key and convert to the "SharePoint Server with Enterprise Client Access License" edition.
7. Now go back to the General Application Settings page in SharePoint Central Administration and you should now see the "InfoPath Forms Services" section with its links.

CopyAppBinContent and Workflow Error with InfoPath Form

Kudos to David Stampfli of Microsoft on his valuable assistance solving this dilemma.

I deployed an InfoPath Form template (.xsn file) to a SharePoint 2010 farm and configured a form library to use this template for new documents. In the InfoPath form a call is made to a custom workflow. Everything appears to be configured correctly. But when I save the form I get the following primary error message:

"Unexpected WinWF Internal Error, terminating workflow Id# f7967a24-ee3b-4056-8513-61a10854058c"

An internal exception has the following message:
Unexpected System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Resources.[............].resources" was correctly embedded or linked into assembly "App_GlobalResources.nkxekvue" at compile time, or that all the satellite assemblies required are loadable and fully signed.


What happened? The page resource files weren't properly deployed to the Web Application on the Farm during the WSP deployment. In order to mitigate this issue we have the CopyAppBinContent command for STSADM. See http://technet.microsoft.com/en-us/library/cc261996(office.12).aspx for more. On the WFE I ran the following command to resolve this issue:

stsadm.exe –o copyappbincontent

Monday, September 20, 2010

Configuring Site Usage Reports

I noticed that my site collection administrators weren't able to see their usage statistics. The issue was that the "Enable advanced usage analysis processing" checkbox was unchecked on the SSP's "Configure Advanced Usage Analysis Processing" screen. Here's what needs to be done to resolve this issue.

1. Open up SharePoint Central Administration
2. Click on the link to the SSP site home page.
3. Click on the link to "Usage Reporting" under the "Office SharePoint Usage Reporting" heading. This is _layouts/SpUsageConfig.aspx on the SSP site.
4. You will be on the "Configure Advanced Usage Analysis Processing" screen. Make sure that both checkboxes for "Enable advanced usage analysis processing" and "Enable Search Query Logging" are checked. Then press OK.
5. Now go to each Site Collection's Features (i.e. _layouts/ManageFeatures.aspx?Scope=Site from the site collection root).
6. If the Reports feature is activated then deactivate it.
7. Now click the Activate button for the Reporting feature.
8. As data is collected the site adminsitrators can use _layouts/SpUsageWeb.aspx on their site to see their site's statistics.
9. As data is collected the site collection administrators can use _layouts/SpUsageSite.aspx on their site collection root to see their entire site collection statistics.

Monday, August 16, 2010

Branding, Design, Skinning, etc. for SharePoint 2010

Microsoft has sure done plenty to improve the look/feel and user experience in SharePoint 2010 over MOSS 2007, WSS, STS, etc. earlier editions of SharePoint. But alas there are always going to be people/groups who will want to spend money on more design customizations. To do so wisely I recommend the following procedures:

1. Think first. The proper term for site look/feel customizations in SharePoint is "branding". You also want your SharePoint 2010 "branding" to be usable long-term so stay tuned in to the key SharePoint 2010 branding strategies so you can have confidence that Microsoft will implement a migration path for future editions of SharePoint.
2. Make the focus of the design changes/implementations to be on the Master Pages. See http://startermasterpages.codeplex.com for a good starting point.
3. Read up on SharePoint 2010 branding. See http://www.sharepointpodshow.com/archive/2009/12/21/sharepoint-2010-branding-episode-40.aspx, http://www.sharepoint911.com/training/Pages/Branding2010.aspx, and http://community.bamboosolutions.com/blogs/sharepoint-2010/archive/2009/10/21/spc-customizing-amp-branding-my-sites-in-sharepoint-2010-with-heather-solomon.aspx to get started.
4. Understand the basics of what a WSP is. As you are building branding capabilities such as master pages, CSS, other stylings, etc. you will be doing so in SharePoint Designer, Visual Studio, Notepad, a CEWP or some other tools. Ultimately you'll want them all packaged up in WSP(s) for sustainability, maintainability, reusability, migrations, and collaboration. See http://www.bing.com/search?q=sharepoint+2010+WSP+%22Solution+Package%22 to get the latest info on WSP(s).

Wednesday, August 4, 2010

maxRequestLength and Large File Uploads for Web Server

I had an end user working with InfoPath Form Services in MOSS get an error when he attempted to load large attachments to his InfoPath document. Sure enough there was no httpRuntime tag in the machine.config file on the Web Front Ends (WFE), and thus no maxRequestLength attribute setting. The default value is 4096 which means 4096 kilobytes or 4 Meg. I upped it to 16 meg and the problem went away.

See http://msdn.microsoft.com/en-us/library/e1f13641(VS.71).aspx for technical specifications on the httpRuntime tag and its maxRequestLength attribute.

Here's a snippet of machine.config to demonstrate the concept.

<configuration>
<system.web>
<httpRuntime maxRequestLength=16384 />
</system.web>
</configuration>

You can locate the machine.config file in the MOSS WFE's .NET framework runtime's config directory within the Windows Microsoft.Net directory tree. In my case it was the C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Config directory.

Monday, August 2, 2010

Page_Load and OnLoad

Today I relearned an important lesson on the Page_Load and OnLoad event handlers for ASP.Net user controls. We cannot assume that they are one and the same in the page lifecycle. By default Visual Studio will create an event handler for Page_Load when you doubleclick on the designer panel for a user control.



This default behavior of Visual Studio set up a disaster in conjunction with my SharePoint development framework.

In my framework I've created a Framework.Base.BaseUserControl class that inherits from the System.Web.UI.UserControl class. The purpose of this BaseUserControl class is to serve as an ancestor class for all my user controls that get deployed with SharePoint solutions. In addition, the web part wrapper class (i.e. Framework.Base.BaseWebPart) assumes that the wrapped user control descends from this class.

Here's the OnLoad event handler in BaseUserControl.

protected override void OnLoad(EventArgs e)
{
this.MyBaseControlLoadLogic();
base.OnLoad(e);
}

Here's the result in Visual Studio for my user control.


protected override void Page_Load(EventArgs e)
{
base.OnLoad(e);
this.MyControlLoadLogic();
}


Everything compiles. But then all I got was a blank screen. I did some debugging and then discovered my mistake. The base.OnLoad(e) call im my Page_Load was causing a stack overflow that crashed my development web server. All I had to do was rename Page_Load as OnLoad.


protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.MyControlLoadLogic();
}

It worked :)

Thursday, July 29, 2010

Referencing the current user in SharePoint Code

In this example I'm making the assumption that you have a web page or web part hosted in SharePoint that is calling a user control with a C# codebehind (i.e. a .ascx.cs file). The code here is called in the partial class.

There are 2 object references available to use in gathering current user information:

System.Web.HttpContext.Current.User.Identity has a type definition of the System.Security.Principal.IIdentity interface.

Microsoft.SharePoint.SPContext.Current.Web.CurrentUser has a type definition of the
Microsoft.SharePoint.SPUser class.

In my code if my Active Directory account is adegaston on the domain called MyDomain then the output of the following function would be:

"Login:MyDomain\adegaston; Display:Alex Degaston."

private string SampleCode()
{
string loginName = System.Web.HttpContext.Current.User.Identity.Name;
string displayName = Microsoft.SharePoint.SPContext.Current.Web.CurrentUser.Name;
string kFormat = "Login:{0}; Display:{1}.";
return String.Format(kFormat, loginName, displayName);
}

Colors are the Key to Asthetic Appeal

I found a great color chart at http://cloford.com/resources/colours/500col.htm to help me with the look/feel of websites.

Monday, July 19, 2010

Upgrading an Existing SharePoint Solution Package

If I already have a solution installed on SharePoint 2007 but I need to quickly upgrade it then I run the following script.

stsadm -o upgradesolution -filename mySolution.wsp -name mySolution.wsp -immediate -allowgacdeployment
stsadm -o execadmsvcjobs
stsadm.exe -o copyappbincontent
stsadm -o execadmsvcjobs


Note: replace "mySolution" with the solution's actual name.

Thursday, July 8, 2010

Post-Build Event Script in Visual Studio

When doing SharePoint development its good to choose on-the-fly whether I want to compile for the sake of making sure my code is compilable or to verify that my code deploys/activates successfully to a website. To accomplish this I've created a Post-Build Event script for my project as follows.


if $(ConfigurationName) == Debug GOTO DoDebugSkip
DEL "$(TargetDir)$(ProjectName).wsp"
"C:\Program Files\WSPTools\WSPBuilderExtensions\WspBuilder" -SolutionPath "$(ProjectDir)" -OutputPath "$(TargetDir)"

ECHO ON
call "c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
gacutil /u $(ProjectName).dll
gacutil /i $(TargetDir)$(ProjectName).dll
@set PATH=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN;%PATH%

stsadm -o deactivatefeature -filename $(ProjectName)\Feature.xml -url http://localhost/
stsadm -o execadmsvcjobs
stsadm -o retractsolution -name "$(ProjectName).wsp" -allcontenturls -immediate
stsadm -o execadmsvcjobs
stsadm -o deletesolution -name "$(ProjectName).wsp" -override
stsadm -o execadmsvcjobs

stsadm -o addsolution -filename "$(ProjectName).wsp"
stsadm -o execadmsvcjobs
stsadm -o deploysolution -name "$(ProjectName).wsp" -url http://localhost -immediate -allowGacDeployment -allowCasPolicies -force
stsadm -o execadmsvcjobs
stsadm -o activatefeature -filename $(ProjectName)\Feature.xml -url http://localhost/
stsadm -o execadmsvcjobs
stsadm –o copyappbincontent
stsadm -o execadmsvcjobs

iisreset
:DoDebugSkip

Monday, June 28, 2010

HRESULT: 0x80040E14

When attempting to add content to a List we got the following error "Exception from HRESULT: 0x80040E14". This error may occur when the file system on the data tier has run out of space. I used mstsc.exe to login to the server running SQL Server for this SharePoint farm and discovered there was only 500K left on the 40 gig C: drive. In SQL Server Management Studio I found the chief culprits were two log files hogging up approx. 23 gig and confirmed the files' location/sizes on the C: drive. I truncated both of them, this C: drive now has over 23 gig of free space, and this resolved the issue. Here's the command I used for truncating one of these log files.

USE SharePoint_Config
GO
ALTER DATABASE SharePoint_Config Set Recovery Simple
GO
ALTER DATABASE SharePoint_Config Set Recovery Full
GO
DBCC SHRINKFILE('SharePoint_Config_log', 2)
GO