Monday, August 27, 2007

Debugging custom navigation providers in MOSS

Microsoft has done quite a bit to ease pain of navigation in MOSS, but there are plenty of scenarios when you would want to have a custom navigation scheme. I am currently building a custom navigation provider for MOSS 2007, which does not need to depend on the site heirarchy and can go many levels deep if need be. I was having trouble debugging this navigation provider (which was created in Visual Studio 2005 as a class in a class library project).

I created and compiled the dll, strong named it and deployed it to the GAC using gacutil. I also added the entry in the providers section. After some cajoling, the custom navigation started showing up in MOSS (not exactly how I wanted it yet, but doing one thing at a time helps ). Now, of course I wanted to debug it :). This is where I came across interesting scenarios. I removed the dll from the GAC and changed the VS output to go straight to the bin directory of the web application. I then got the expected error 'The assembly does not allow partially trusted callers'. Then I added the AllowPartiallyTrustedCallers attribute to the assembly - and guess what (it still didnt work). I then added a safe controls entry and an assembly entry for my assembly and raised the trust level of the web.config to WSS_Medium and it STILL complained about the same error. At this time I raised the trust level to full and that is when things started working.

I think I know why I had to do this but Ill run it by some MCS folks and see if I am right and then update this. Ill also write up an article explaining the design and architecture of the custom navigation provider soon.