Archive for the 'Programming' Category

Mar 10 2009

The SharePoint Adrenalin Moment

Published by under Programming,Software

I’ve been developing with SharePoint for about 9 month now, and by developing I don’t mean airy-fairy SharePoint Designer drag-and-drop, I mean proper getting your hands dirty in code because SharePoint doesn’t have an *cough* out of the box *cough* feature that does what you want.

Mostly, deployment is done in two stages, firstly to a UAT box and then to a Live box.  Obviously the most efficient way to do this is to bundle your features into a solution which can easily be deployed onto any number of machines.  But, it does mean you have to make sure you’ve got everything right.  Untangling mistakes in your code can be a right royal pain in the arse.

By the time you’ve developed your solution, tested it out, deployed it to UAT and tested it again you should be fairly confident that when you come to deploy it on the Live server things should go pretty smoothly.  And, touch wood, to date things have gone smoothly.

But I still can’t get over that rush of adrenaline that comes with clicking “Activate Feature” after deploying the solution on Live.  In the second or two whilst the page waits to reload my mind runs through all the possible things that could go wrong and how long it would take me to unpick the changes my code might have got half way though.  Then the page finally loads…..

….. “Feature Activated”, phew!  Time for a lie down to clam my nerves.

2 responses so far

Feb 25 2009

CRM 4 iFrame Printing

Published by under Programming,Software

Last year I was working with a client to develop some ISV add-ins for Microsoft Dynamics CRM.  Recently I was alerted to the fact that one of them – a seperate aspx page that loads in an iFrame on the account details panel – wasn’t printing correctly.

It displayed correctly in the normal view form, appeared correctly on the print preview form but when actually printed it was collapsed down to one or two pixels high.

After doing a bit of research, I found this post by Vince Bullinger, in which he gets around the problem by, as far as I can tell, modifying a core CRM css file.  Whilst this will work, it should be noted that any modification to core CRM files is not supported and will almost certainly break or be lost by updates and hotfixes.

Another problem with the code Vince Bullinger gives is that the iFrames a fixed height and that applies to ALL ISV iFrames.  However, with this knowledge I was able to  come up with my own solution that uses a bit of Javascript to ensure that iFrames are printed and at the correct height to display all the content:

<%@ Page Language="C#" AutoEventWireup="true"
    CodeBehind="Summary.aspx.cs" Inherits="CRMWeb.SummaryStatus.Summary" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Summary Status</title>
    <style type="text/css">
        #pageWrapper
        {
            position: absolute;
            top: 0;
            left: 0;
        }
    </style>
</head>
<body>
    <div id="pageWrapper">
    <form id="form1" runat="server">
        <!-- content goes here -->
    </form>
    </div>
    <script language="javascript" type="text/javascript">
        var dh = document.getElementById("pageWrapper").offsetHeight;
        document.parentWindow.frameElement.height = dh;
        document.parentWindow.frameElement.style.display = "block";
        document.parentWindow.frameElement.style.height = dh + "px";
    </script>
</body>
</html>

This solutions requires that you surround the content of your page with a div, in this case <div id=”pageWrapper”></div>.  This is used by the block of Javascript at the end.

The purpose of the Javascript is to use the pageWrapper div to find out the height of the content.  This height is then used to set the height of the iFrame that contains the page and to set the display style of the iFrame to block.

It probably doesn’t require the iFrame height and the iFrames style.height both being set but I decided to take a belts and braces approach.

In addition to ensuring the iFrame content is printed, I am also planning on implementing the code on Vince Bullingers page for loading a specific css stylesheet for printing.

kick it on DotNetKicks.com

2 responses so far

Feb 11 2009

Microsoft Enterprise Search Roadmap

Published by under .NET,Programming,Software

When I first started developing with SharePoint in June last year the last thing that was on my mind was Enterprise Search.  I had considered it the sort of technology that you just plug in a magic box and it just did all the work for you.

Recently, however, I have been involved in developing a customised search solution using Microsoft Office SharePoint Server (MOSS) to allow a client to search client and non-client related documentation within their organisation.   What I rapidly discovered is that enterprise search is not a plug-and-play affair.  A lot of thought needs to go into the meta data that is used to define the taxonomy of the data (in this documents) and also how users are going to interact with search and how to make sure they get the information they need.

I have also recently been on a training course at FAST Search,which was acquired by Microsoft in April 2008.  The course was both an introduction to the structure of FAST ESP and also an in-depth look into customising the internal, both feeding content into the indexing engine of FAST ESP and building a rich user experience for getting content from the FATS ESP search engine.

The two activities have really awaken me to how powerfull enterprise search can be in empowering users to find information which previously they either may not have know how to access or, more likely, simply hadn’t known existed.  Whilst I was learning about FAST Search, it was generally anticipated that it would be included with the next generation of MOSS.  Today that was confirmed at FASTForward ’09 when Microsoft announced its roadmap for enterprise search which has two initial streams, firstly FAST Search for Internet Business which is mainly aimed at internet retail businesses – like you’d use to find products on Amazon.  The second, and more interesting for me, stream is FAST Search for SharePoint, which will integrate FAST Search more closely with SharePoint and would be used for the type of internal information discovery that I have been working on recently.

Mark Harrisson also noted on his blog that Microsoft is going to be offering ESP for SharePoint immediately which is

a special offering that allows customers to purchase high-end search capabilities today, with a defined licensing path to FAST Search for SharePoint when it becomes available.

I haven’t been able to find out more information about ESP for SharePoint, but it certainly looks like it could be an interesting product to get hold of.  I the mean time I’m keen to continue working with MOSS Enterprise Search and have just the right project lined up to flex my new found love of search on.

No responses yet

Aug 26 2008

CRM4 Web Service Errors

Published by under Programming

As well as starting to work with SharePoint in the last two months, I’ve also been doing some development in Dynamics CRM4.  In the past week I’ve been porting an ISV add-on that was written for CRM3.  Whilst most of the code is pretty much the same, there are a few gotcha to watch out for.

The first problem I came across was the web-service authentication.  I’m not a CRM expert but I believe this has something to do with the new multi-tenancy installation option.  Now when you connect to a web service you need to create a CrmAuthenticationToken and pass it to the web service.  This allows you to specify which organisation you are connecting to.

Once connected to I started getting the following error when running a FetchXML query:

<error>
  <code>0x8004111a</code>
  <description>An aggregate operation was initially specified, but no aggregate operator was encountered.</description>
  <type>Platform</type>
</error>

This error was being generated by the following FetchXML query:

<fetch mapping="logical" aggregate="true">
   <entity name="account">
      <filter>
         <condition attribute="accountid" operator="eq" value="edd2b749-9f58-dd11-90aa-00155d0a0e03" />
      </filter>
      <link-entity name="contact" from="accountid" to="accountid">
         <attribute name="contactid" aggregate="count" alias="myCount" />
      </link-entity>
   </entity>
</fetch>

The purpose of this query is to count all the contacts that are linked with a specific account.  It does this selecting an account entity with a specific id and then counting all the contact id’s for the contacts that are linked to the account.

For some reason the xml parser finds the aggregate=”true” flag but doesn’t find the count aggregate on the linked entity.  Quite why this works in CRM3 but not in CRM4 is beyond me but what I do know is that turning this query around works:

<fetch mapping="logical" aggregate="true">
   <entity name="contact">
      <attribute name="contactid" aggregate="count" alias="count" />
      <link-entity name="account" from="accountid" to="accountid">
         <filter>
            <condition attribute="accountid" operator="eq" value="edd2b749-9f58-dd11-90aa-00155d0a0e03" />
         </filter>
      </link-entity>
   </entity>
</fetch>

In this case the query is run against contract and the id’s are counted where they are linked to a specific account.  I assume this works because the aggregate attribute is on the root entity.  I haven’t tested if it is possible to add more aggregates to the link entities or not.

One response so far

Aug 15 2008

When IIS Wont Start – Error 13

Published by under Programming

This morning I ran into a problem when running a repair on my broken SharePoint installation.  Everything seemed to be going well until the setup needed to restart the World Wide Web Publishing service (IIS).  The error message was rather cryptic, say that it might be due to my login account not having service start permissions – but I know I have.

Debugging step 1:  Look in the windows services list and see if I can manually start the service. This was a little more helpful as it told me it couldn’t start due to a dependency not starting.

Debugging step 2: Check the service dependencies.  It appears that the Windows Process Activation service (WAS) wouldn’t start, although it only returned the message “Error 13: The data is invalid?.

Debugging Step 3: Check the system event log.  Here I found the most helpful message so far:

The Windows Process Activation Service encountered an error trying to read configuration data from file ‘\\?\C:\Windows\system32\inetsrv\config\applicationHost.config’, line number ’0′.  The error message is: ‘Configuration file is not well-formed XML’.  The data field contains the error number.

It seems that at some point the applicationHost.config got trashed.  Luckily, when you make changes to web applications in IIS it creates a backup of the applicationHost.config file in c:\inetpub\history.  All you need to do is copy a good copy from the history and put it into c:\windows\system32\inetsrv\config.

And Roberts your mothers brother, WAS starts, IIS starts and the repair of SharePoint can continue!

ps. I’m running IIS7 on Windows 2008 Server.

38 responses so far

Aug 14 2008

The Quick Way To Trash SharePoint

Published by under Programming

I have just leant the hard way that you should always check the name you have given your feature before deploying it to a server.

Quite stupidly I created several features, at least two of which I now know conflicted with existing SharePoint features.  I used the xcopy method of deploying the feature on my local dev machine with the “/Y? switch to suppress prompts when over-writing existing files, so at the time I didn’t realise what I had done.

It was only when I can to create a new site collection that everything call falling down.  I’m currently downloading the SharePoint installation DVD from Microsoft in the hopes that a re-install will fix the problems.

From now on I’m going to be prefixing all features I create with the clients name.  This will provide two benefits:

  1. It will greatly reduce the risk of a feature name conflict.
  2. It will group all the directories together in explorer for easier deletion.

One response so far

Aug 11 2008

Try…Catch For No Reason

Published by under .NET,Programming

I’ve seen this time and time again and I’m sure just about every developer out there has seem the same sort of thing:

try {
    //many lines of code
catch (Exception ex) {
    throw new Exception("Something went wrong dude!");
}

This is probably the single most un-helpful piece of code a developer can write.  All you are doing is making you life and future developers lives harder when it comes to debugging.  The whole point of the try…catch block is for times when you know an exception may happen and it allows you to gracefully handle it without the whole system crashing to the ground.

So lets have a closer look at what’s wrong with this code:

Continue Reading »

One response so far

Jul 14 2008

SharePoint Event Receiver Manager

Published by under .NET,Programming,Software

One of the things I’m working on is Event Receivers in SharePoint but I’ve found registering the event receivers to be a bit on the annoying side.  Yes you can do it with the feature.xml Receivers section and there is the great El Blanco Event Receivers Manager.

EventReceiverManagerI personally prefer desktop GUI applications and so, based on code by Liron, I’ve created my own desktop Event Receiver Manager.  It allows you to select site & list, browse for an assembly so it can give you the full assembly name and a list of classes inside, and a list of receivers you can attach to.

The current version only allows adding new event receivers.  Before adding a new receiver it will check to make sure the same receiver doesn’t already exist.

Future plans for it include listing existing receivers to allow users to delete them but as I don’t need to do that myself yet I haven’t implemented it.

Download a copy of EventReceiverManager.

3 responses so far

Jul 10 2008

SharePoint Link List – Part 3

Published by under Programming,Technology

These are a selection of list of links that I acquired on a recent SharePoint developer course with Patrick Tisseghem of U2U.  This is part 3 of a 4 part series:

Workflow

Windows Workflow Foundation
http://netfx3.com/content/WFHome.aspx
An introduction and kick-off point for developers wanting to get started with Workflow Foundation.

Custom Workflow Activities
http://codeplex.com/SPDActivities
A set of handy SharePoint workflow activities for people that don’t want to get their hands dirty creating their own custom workflow activities.

Search

Microsoft search services
http://www.microsoft.com/enterprisesearch/products.aspx
Information on the Microsoft Search Server family of products.  Aimed more at decision makers than developers.

MOSS Faceted Search AddOn
http://www.codeplex.com/FacetedSearch
A most excellent add-on for the MOSS search system.  Allows for quick and easy refining of search criteria.

Silverlight

Silverlight for Sharepoint BluePrints
http://www.codeplex.com/sl4sp
Demonstrations of how Silverlight can be used with SharePoint.

Vertigo – FamilyShow
http://www.vertigo.com/familyshow.aspx
Example of using Silverlight in SharePoint

Deep Zoom Composer
http://blogs.msdn.com/expression/archive/tags/Deep+Zoom+Composer/default.aspx
Nothing to do with SharePoint but a very cool application.  Useful if you want to embed a Deep-Zoom show in SharePoint ;)

No responses yet

Jul 09 2008

SharePoint Link List – Part 2

Published by under Programming,Technology

These are a selection of list of links that I acquired on a recent SharePoint developer course with Patrick Tisseghem of U2U.  This is part 2 of a 4 part series:

Utilities

STSAdm extensions
stsadm.blogspot.com
A set of extensions to STSAdm.exe that make just about any SharePoint administration task a piece of cake.  The extensions are packaged as a SharePoint solution package (.wsp) and are installed with the STSAdm.exe utility itself.

Sharepoint Project Utility
http://www.andrewconnell.com/blog/articles/ACs-VS-SharePoint-Project-Utility-Tool-Window-for-SharePoint-Developers.aspx
A utility for VS developers for creating the standard directory structures and default files for various SharePoint development scenarios.  Requires the installation of the DX Core VS addin.

VS2008 Sharepoint Extensions
http://blogs.msdn.com/sharepoint/archive/2008/06/04/announcing-the-vsewss-version-1-2.aspx
A set of projects and project items for VS2008 for SharePoint development.  My initial investigation suggests that these may be geared more towards MOSS2007 than WSSv3.

Event Receiver Management – El Blanco
http://chrissyblanco.blogspot.com/2007/08/event-receiver-management.html
Allows management of event handlers to specific lists, libraries, etc.

Application Pool Manager
http://www.harbar.net/articles/APM.aspx
System tray access to IIS Application Pool tasks.  Runs on the machine that SharePoint is installed on.

Fiddler – HTTP Debugging
http://www.fiddlertool.com/fiddler/
Useful tool for finding FrontPage rpc calls for uploading and downloading documents.

Expresso Regular Expressions
http://www.ultrapico.com/Expresso.htm
Wonderful utility for developing and debugging .Net regular expressions.  Once you’ve created and tested your regular expression, Expresso can generate stub .Net code to get the regular expression into your project.

Caml Query Builder
http://www.u2u.info/Blogs/karine/Lists/Posts/Post.aspx?ID=28
I’ve not had any experience with CAML yet but I’m sure I’ll be using this tool when the time arises.

Word Content Control Toolkit
http://www.codeplex.com/dbe
Assists with binding xml embedded in a Word 2007 docx file to controls in the Word document.  Useful for generating Word documents containing data from SharePoint.

SmartPart for SharePoint
http://www.codeplex.com/smartpart
The SharePoint web part which can host any ASP.NET web user control. Create your web parts without writing code!

One response so far

« Prev - Next »