30 July 2009

Get Byte Array using Enterprise Library

It took me a while to figure this out so I thought I would post the solution here. I needed to get a blob out of the database and assign it to a byte[] in my object

Solution

//initialise the byte[] and get its size
byte[]
byteArray = new byte[(dr.GetBytes(dr.GetOrdinal("File"), 0, null, 0, int.MaxValue))];
//Assign bytes to byte array
dr.GetBytes(dr.GetOrdinal("File"), 0, byteArray, 0, byteArray.Length);
//Assign Value
file.FileByte = byteArray;

Enjoy

25 July 2009

SharePoint 2007 & .Net 3.5 SP1

Problem

“The Registry Records Center could not be found or accessed”

Last week I was working on a few problems we were having with SharePoint and Office 2007. One of those problems happened all of a sudden and the Send to Records Centre stopped working. The error we were getting was The Registry Records Center could not be found or accessed. Registry being the name of our Records Centre.

I was told that an emergency service pack needed to be installed for .Net Framework 2.0 to resolve some of our issues but nothing was mentioned about .Net 3.5 and SP1

It turns out that after installing .Net 3.5 all seems to be well in the SharePoint space, but installing 3.5 SP1 breaks the Send to Records functionality.
I can across this blog entry by Aghy: http://dotneteers.net/blogs/aghy/archive/2008/10/31/moss-2007-and-net-framework-3-5-sp1.aspx

Solution

I created a .reg file described in the kb and all my problems went away, well at least this one. You can download the file here

It seems that it is the loopback check that .NET 3.5 SP1 introduces that is causing a problem. The solution is described in the MS kb 896861

KB description
You receive error 401.1 when you browse a Web site that uses Integrated Authentication and is hosted on IIS 5.1 or IIS 6 http://support.microsoft.com/kb/896861

The file contents are:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]
"DisableLoopbackCheck"=dword:00000001

Silent

I have been silent for a while. I have been completing my MSc in computer science at Birkbeck which I found out I passed, what a huge relief.

I still have a SaaS project using WCF and Silverlight that I working on to hand in to seal the deal. It is coming along nicely and I will post parts of the project here and some cool things I have learned. The new part of the framework, WCF, that I have not used before is super cool & powerful

22 April 2009

2007 Office System Driver and 64 bit architecture

I wrote a spread sheet upload component for our web application at work. We have now decided to move to 64 bit architecture and an upgrade from .Net Framework 2.0 to 3.5.

On the initial analysis of this migration we realised that the 2007 Office System Driver used does not support 64 bit

Solution:
So I did a bit of research and it turns out that the solution is to compile you application in 32 bit mode, which sux for us as we can’t utilise the 64 bit

To compile you applications in 32 bit do the following:

1. Open menu "Build/Configuration Manager..."
2. Select "" in the "Active solution platform:" combobox
3. Select "x86" and click ok.

With regards from Walter Wang [MSFT]

There does not seem to be a planned release for a 64 bit version

Tags
2007 Office System Driver: Data Connectivity Components 64 bit
Access Database Engine
Microsoft.ACE.OLEDB.12.0

21 April 2009

Boost your tool set and your PC

I was going through a few sites and picked up and few tips and tools to boost your development productivity and your PC at the same time

Check it our you might find something useful

PC: 50 Tools to Speed Up or Otherwise Enhance Your PC
http://www.cio.com/article/print/450652

Development: Scott Hanselman's 2007 Ultimate Developer and Power Users Tool List
http://www.hanselman.com/blog/ScottHanselmans2007UltimateDeveloperAndPowerUsersToolListForWindows.aspx

Hope it helps

20 April 2009

Collection of SharePoint utilities



I have zipped and uploaded a bunch of utilities that I use or have used through my SharePoint development.


You can download them from my SkyDrive at http://cid-fec60a7baa298f04.skydrive.live.com/browse.aspx/SharePoint%20Utilities

The only one not on the list is Sushi butI have added it as a separate download

Laters

Copy SharePoint content types & columns

It seem that there are a few tools out there to handle the modification and copying of content types and columns within MOSS

I have a list of a few options listed here:

Possibly paid for products:

Hope this helps

16 April 2009

Nedstats webpart for SharePoint

I wanted to give you a feel for the creation of a Nedstats webpart for use in a SharePoint master page.

I am using MOSS and not WSS. Not sure if it makes a difference.


Download the file here

Overview:
The problem is that the script Nedstats provides has two parts to it. One is the JavaScript aspect and a NoScript aspect. The javascript part would not be a problem and can generate the unique counter for each page but the NoScript part is where the issue lies. It can not build the counter dynamically, so we have to build a webpart the solve our woes.

Solution:
We need the counter to be the same no matter what page we are on for the JavaScript and NoScript part. So we need to build the counter dynamically and we can use the breadcrumb SiteMapNode object used by SharePoint and hook into that. We can than deploy the webpart to SharePoint server and add it to the master page.

Code:
Download the file here


The tricky part is building the counter

private string BuildCounter()
{
var stack = new Stack();
sb = new StringBuilder();
var provider = SiteMap.Providers[siteMapProviderString];
if (provider == null)
return string.Empty;


var node = provider.RootNode;
if (node == null)
return string.Empty;


// Stack the nodes, child first
stack.Push(node);
while (node.ParentNode != null)
{
node = node.ParentNode;
stack.Push(node);
}


foreach (SiteMapNode mapNode in stack)
sb.Append(mapNode.Title).Append(".");


var pageName = GetPageName();
sb.Append(pageName);


// Clean any not supported Chars, ect
var cleanCounter = sb.ToString().Replace(" ", "-").Replace("&", "-").ToLower();
//Controls.Add(new LiteralControl(cleanCounter));


return cleanCounter;
}



Implementation:
Copy the DLL to the bin
Make it safe in the web.config
Make the webpart avalible to the website


Open SharePoint designer and then open your website. Open your default.master or custom master page
Locate the PlaceHolderLeftActions placeholder in the master page.
You now need to add the webpart into the master page in-between this placeholder.


This was a tricky one as SharePoint does not allow webpart zones to master pages stipulated here http://msdn.microsoft.com/en-us/library/ms476046.aspx


Example
< id="PlaceHolderLeftActions" runat="server">
< runat="server">
IsIncluded="True"
... / >
< /asp:ContentPlaceHolder >


Don't forget:
Add DLL to GAC or bin
Add the SafeControl into the web.config
Make the webpart avalible to the website
Make sure that the master page has a reference to the webpart (<%@ Register tagprefix="Webpart" namespace="..." %>)


Testing:
To test that it is all working you need to use Firefox.
Download Tamper and install it.
Using Tamper you can then see if your URL is being sent to sitestat with the correct counter name


Small Issue:
It does seem to carry some extra rubish with the URL, but we do not mind that at the moment

Have fun