More servicesWindows Live
HomeHotmailSpacesOneCare
 
MSN
Sign in
 
 
Spaces home  dotnet o ramaProfileFriendsBlogMore Tools Explore the Spaces community

Blog

June 29

How to determine if MOSS is installed.

An easy way to determine if MOSS is installed is to check the farm's property bag for a property named "SearchProviderName".  If that property exists and its value is "Office SharePoint Server Search", then MOSS is installed. 

Here is a snippet of code that shows the property in action (it assumes that the site variable is a SPWeb object):

SPFarm farm = site.Site.WebApplication.Farm;

if (farm.Properties["SearchProviderName"] != null
    && farm.Properties["SearchProviderName"].ToString() == "Office SharePoint Server Search") {

    // MOSS is installed.
} else {    // MOSS is NOT installed.
}

May 06

An easy way to debug SharePoint SPFeatureReceiver classes

Until now, I used to debug SharePoint feature activation by using the Attach Debugger feature to launch the debugger from inside the IIS worker process my SharePoint site was using.  After some tinkering, I was able to determine that you can also debug by configuring your SharePoint feature product to start STSADM.EXE and supply the command line options to activate the feature.

See this screenshot for details:

image

If you don't already know the location of STSADM.EXE, it is located at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE.

Once your project is configured, you can set a breakpoint in the FeatureActivated method of your feature receiver and debug the project.

May 04

Anonymous Audiences in MOSS

In a past project, I needed to be able to create an audience in MOSS that would apply only to anonymous users in an SharePoint site configured to use forms-based authentication.  Additionally, anonymous users could not access a page in SharePoint if the page contained a web part that was configured with an audience.

I noticed that the RuntimeFilter tag in the web.config file referenced the AudienceManager class: 

<RuntimeFilter Assembly="Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Class="Microsoft.Office.Server.Audience.AudienceManager" BuilderURL="audience_chooser.aspx" />

Using Reflector, I was able to determine that this class was responsible for both supplying the audience controls in the tool part window and for determining whether or not the user was in the audience configured for the web part. 

Normally, these controls are displayed when a web part is edited:

image

But after writing a wrapper for the AudienceManager class, I was able to add an additional checkbox to allow the user to specify that only anonymous users should see the webpart:

image

Now, when the user checks the check box, only anonymous users will see the web part.  I also made an additional change to workaround the problem of anonymous users not being able to see pages that had web parts configured with audiences.

To implement the same functionality, you will need two classes:  one that implements the Microsoft.SharePoint.WebPartPages.IRuntimeFilter2 interface and one that implements the Microsoft.SharePoint.WebPartPages.IToolPaneControl interface.  The IRuntimeFilter2 interface is used to determine if the current user is in a particular audience when the web page is rendering and the class you create will need to be configured in the RuntimeFilter tag in the web.config file.  The IToolPaneControl interface is used to display the audience control in the tool pane when the web part is edited.

You can download the code I used here.

Technorati Tags: ,

Exception when calling SharePoint web services

You may get the following exception when calling SharePoint web services:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Attempted to perform an unauthorized operation.

In my case, the problem was that the URL I used did not map to a site collection in SharePoint since I had previously deleted that site collection and forgot to recreate it.  Once I recreated the site collection, the error went away.

Technorati Tags: ,,
April 18

"Object reference not set to an instance of an object." when trying to Detach from Page Layout in SharePoint Designer.

If you get this error message in SharePoint Designer when you are detaching a page from its page layout, reopen the site using the original public URL for the zone you configured for Windows Auth.  If you don't know the URL, open Central Administration, click the Operations tab, and click the Alternate Access Mappings link.  Then, select the web application from the Alternate Access Mapping Collection dropdown.  The URL you need to use will be in the Public URL for Zone column.

Technorati Tags: ,

Tab order is reset to zero when changing a control to another type

When you right-click a control and choose "Change To", it will reset the control's tab order to zero. Remember to set this value after changing it if you are using a specific tab order in your form.
November 15

Slow InfoPath form performance

If you have data connections that are unused on the view you are displaying, be aware that the data returned by the data connections is still transfered from the server to the browser during post backs. This will cause any business logic or custom code to be slow since so much data is returned after the code on the server runs.

Making file attachments work in InfoPath Form Server

File attachments in InfoPath browser-based forms will not work unless the form tag of the master page is modified to include the encoding type. Ex: <form enctype="multipart/form-data" .... >

Saved forms and alternate access paths

If you try to view a saved form using a different alternate access path than the one used to save it, you will get an error message. The problem stems from the fact that the saved form XML has a fully-qualified, hard-coded path to the site collection where it was saved and it is not being translated to another other alternate access path.

Promoting properties of forms already published

If you promote a new property in a form that has already been published, it will not update the form's content type until you deactivate and reactivate it to the site collection where it is deployed.

Beware of unused secondary data connections in InfoPath

If you display a view in the XmlFormView web part that does not reference ALL of the secondary data connections, it will cause an exception inside Form Server when the form posts back to the server. To workaround this, modify your main data source to include a group named "Workarounds" and under the group, create one element for each secondary data connection. Next, right-click the "Workarounds" group and select "Section with Controls". Modify the properties of the section and uncheck the display checkbox to make it invisible in production. Afterwards, right-click each textbox in the section and convert it to a drop down list. Finally, bind each drop down list to its matching secondary data connection. These steps only need to be done of the first view. Subsequent views can be updated by copying and pasting the entire section into each view.

Common InfoPath Form Server Errors and What They Mean

Having spent a *lot* of time troubleshooting the implementation of Form Server without much help from others, I have compiled a list of the errors I ran into along with the causes and fixes I used to resolve them.  The MOST important thing to do when using InfoPath Form Server is to mentally or literally track your steps carefully so that when you run into one of these vague errors, you will be able to retrace your steps.  Otherwise, you could easily spend a day trying to figure out why something broke.

Here is my list.  If you want me to include your additions, let me know.

 

Error Message Meaning Fix
The security validation for this form is invalid. It means that your session expired while the form was open. Log back into the site.
An entry has been added to the Windows event log of the server. InfoPath Server had an exception. Enable diagnostics logging on ALL categories that start with Form and examine the trace logs for the exception.
The form has been closed. InfoPath Server had an exception. Enable diagnostics logging on ALL categories that start with Form and examine the trace logs for the exception.
This form template is not currently browser-enabled. It must either be republished as a browser-enabled form, or opened using Microsoft Office InfoPath 2007. It means the XML document you are editing is hard-coded for a different site than the one you are using to edit it. Either modify the XML file to match the current site or switch to the site definited in the XML document.
November 07

Yet another fix for when the clipboard stops working between the host OS and Virtual PC

As you may know, sometimes cut and paste stops working between the host OS and the guest OS in a Virtual PC.  If you don't already know, this functionality is actually provided by the Virtual Machine Additions, specifically the Virtual Machine Additions Services Application windows service.  So the next time the clipboard stops working, try restarting this windows service and it should start working again.  If not, you may have a program on the host OS or the guest OS that is keeping the keyboard locked.  A simple test for this is to copy and paste between programs in the host OS and between programs in the guest OS.  If one of these tests fails, you may have to close programs on that OS or reboot it.

October 25

Code for preventing Visual Studio from locking files

Last April, I blogged about using a detour library to prevent Visual Studio from locking files.  Visual Studio 2003 and 2005 tend to lock files when the size any of the compiled projects in a solution get too big or when the number of projects in a solution gets over 10.  In the former case, you could see problems when the assemblies grew over 64K in size.  In the latter case, the chance of the problem occurring increased with the number of projects in the solution and the number of interdependencies between the projects themselves.  However, with my hack, I was able to have a solution with over 20 projects (mostly C# class libraries) and virtually unlimited assembly size.  The size of our assemblies was due to localization of the application for 7 languages not including English.  Since that original post, several people have requested the code so here it is.  This code is NOT supported by anyone so use it at your own risk.

The code I added is in the detours\samples\fakecreatefile folder.  The OpenVisualStudio.bat file calls one of the detours utilities which loads devenv.exe into memory and rewrites the calls to the CreateFile Win32 functions to call my functions instead.  My functions are in the fakecreatefile.cpp file.

Download the zipped code including old version of detours library from here.

September 07

When MOSS Audiences don't work

If you create an audience whose rules are based on user profile properties, make sure that those properties don't have their Default Privacy Setting set to "Only Me".  Otherwise, the audience compiler will not "see" the values for those properties.  Unfortunately, the audience editor allows you to create properties on private properties without giving you any warning.  :-(

August 30

Running older games on Vista

I have found that Vista seems to be able to run older games that XP would not.  This includes older adventure games that were targeted at Win 95/98.  There are two important hurdles to overcome when running these games:  getting the game to load without errors and keeping the game in the foreground when the game reduces the screen resolution.

 

To get the game to load without errors, try these steps:

  1. To be able to save your save, you will mostly likely need to either run the game using "Run as Administrator" or add your account to the NTFS permissions for the installation folder and all subfolders and files.
  2. Changing the compatibility level of the game's exe to an operating system supported by the game.

 

Once you are able to get the game to load and you can see some video, you may be dumped to the desktop with the game still running.  The problem is that programs like Windows Sidebar that appear always on top interfer with the game.  So if you have this problem, close Windows Sidebar and other applications like it and try again. (I had to close XBoxStat.exe, the resident program for the XBox 360 Controller driver, since it also interfers with the game.)

 

One caveat is that for games that are purely DOS based, I always use DOSBox which emulates DOS and is still fast enough to provide a good gaming experience.

 

These are some games that I have been able to load even with the UAC enabled:

  • All Nancy Drew games
  • Most Sierra adventure games

 

I plan on keeping this list up to date so if you have any additions, let me know.

July 07

MSI packages that fail to install on Vista

If you have the UAC enabled in Vista, MSI packages may fail if they require administrative priviledges to install correctly.  If you run into this situation, you can work around this by running the command line console (cmd.exe) as administrator and installing the MSI from the command line.  Since the command line is running with administrative priviledges, any process it starts will also run with administrative priviledges.

Rob Bogue's open letter to the InfoPath team

If you are thinking of using InfoPath Form Services for a project, read this post before you make the jump.  I have had many problems of the problems that Rob addresses in his blog post.  In future posts, I will share some of the workarounds and hacks I have used to tame many of the problems with InfoPath's browser-based forms.

May 06

Activation could not be completed because the InfoPath Forms Services support feature is not present.

You may get this error when trying to activate an uploaded InfoPath form to a site collection.  I was able to fix the problem by deactivating and re-activating the "Office SharePoint Server Enterprise" features at the site collection and site levels.

April 25

Unable to load workflow actions from the server.

If you get this message and you edited your SharePoint server's WSS.ACTIONS file to add custom activities to SharePoint, then you put invalid XML in the WSS.ACTIONS file.  This happened to me when I edited the file in Notepad and caused the XML to be invalid because of some missing whitespace.  If you can't edit the file in a real XML editor, you can still use Internet Explorer to open the XML and make sure that the XML is valid before you do any testing.  In order to do this, make a copy of the file and give it the .xml file extension.  Otherwise, Internet Explorer won't know what to do with it.