web 2.0

Archive: Castle Windsor, SharePoint, the GAC and You

I am pleased to say, not only do I have a full working Model-View-Presenter implementation running within a SharePoint WebPart now, but I am very very close to having the rendering abstracted away from the WebPart and into a UserControl too. I'll blog more about this when I'm happy with the whole solution end to end.

In the meantime however, one annoying problem got me very very confused for a while ... if only SharePoint didn't give such stupid error messages and let you debug it properly, my life would have been much easier ... It was silly mistake really ... would have found it in 30 seconds in an ASP.NET application ... anyway I digress.

Remember, if you are using Castle Windsor from the GAC (as you need to for SharePoint work), then the web.config entry must specify the stong name of the assembly in the ConfigSections entry:

<section name="castle"
type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc" />

 

 

 

I had copied and pasted the entry from another project, not in the GAC, it only had the entry as Castle.Windsor and voila I got a lot of cryptic errors from SharePoint.

As a secondary note, remember all of your entries in the <castle> section must also specify the strong name, or they too will give you cryptic messages and a lot of wasted effort.

Another one to watch out for!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

configuration

Archive: Debug Step Into Missing in Visual Studio

I have little idea why, but I have now encountered this a fair few times, so much so that I thought I might as well blog it, others must be getting it too.

If you are missing your 'Step Into' option from the Debug menu and toolbar in VS, there is a simple fix: Select Tools / Import and Export Settings from the menu, then select Reset All Settings and follow through the next parts of the wizard.

This should have your Debug menu items back, though you may have to fix some other things back to how they were (like fonts and colours). Also if you have ReSharper installed, you need to go to the ReSharper / Options menu and under the General section reset your ReSharper shortcuts there.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

visual studio

Archive: The GAC Can Really Screw You Up!

I have my MVP project coming along nicely, unit tests all running, presenters and interfaces doing their basic stuff. The assemblies are all being stongly named for SP deployment (into the GAC). Then I add my WebPart and implement IView on it.

Problem Numer 1 : Implementing an Interface on a WebPart using VSeWSS Causes Deploy to Fail

Oh yeah, that was fun. For speed and as I am working on a VM, I used the VSeWSS extensions to quickly create and deploy the web part. An hour later wasted, I pin down a problem with the Deploy command the Visual Studio extension provide. Just implementing an interface on the WebPart class causes the Deploy to fail - with a cryptic message about a reflection error.

Well done guys, I guess you are trying to find something that implements WebPart and nothing else? Whatever the reason, VSeWSS gone for good from my machine, I'm going back to doing this the hard way, where at least I have some control.

Problem Number 2 : The GAC ... "I'm not lying. Take my pen, write this down. Do not trust her."

So, my WebPart is now working, and all seems happy. With the assemblies deployed, I can now view my WebPart in all it's glory displaying "Hello World" with data coming from my repository via the presenter. All is good. All is level. All is pretty.

Then I do a bit of basic refactoring. Following some suggestions from ALT.NET people, I play around with my event signatures, remove out 'object sender' as this will be provided to the presenter on construction, and define an EmptyEventHandlerArg.

All pretty simple stuff. Hit build, all compiles just fine first time. Run all unit tests ... whoa there donkey...

System.InvalidOperationException: You have called the event raiser with the wrong number of parameters. Expected 1 but was 0
at Rhino.Mocks.Impl.EventRaiser.AssertMatchingParameters(MethodInfo method, Object[] args)
at Rhino.Mocks.Impl.EventRaiser.Raise(Object[] args)

 

Surely some mistake. Go over all code. Try to figure out if my usage of Rhino Mocks is wrong. Nope - all is correct, the IEventRaiser is being called correctly with the right number of parameters. The correct number of parameters in the view and the presenter.

Try this a dozen time more. Can't figure out why this worked just fine in my first prototype project where I had damn near the same code, so go back to that project. It all works just fine there. Change the signature there. It works just fine.

Back to my WebPart project. Stare blankly. Drink more coffee. Spark of inspiration ...

Delete the previous built assembly from the GAC. Now it all runs just fine.

It seems that the unit tests/Rhino are getting their references from the GAC, where as my projects are getting their reference from the build directory. On a machine where the assembly is built, but may also be in the GAC this is an issue for unit tests.

Off to try and find an explanation or solution. Of course I can copy to the GAC every build ... but I'm not sure I want to ... and I don't think it is healthy to have to ...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Archive: Recycle Application Pool Instead of IISRESET

Simple ... and SO MUCH FASTER than iisreset ...

cscript "c:\windows\system32\iisapp.vbs" /a "AppPoolName" /r

... where "AppPoolName" is replaced by the pool you want to recycle. Damn useful for MOSS development, where the environment dictates a lot of resetting of IIS to see changes made.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

code samples

Archive: Reflector and GacUtil Shortcuts on Explorer Context Menus for DLLs

Whilst looking for something entirely different, I came across a post by Eric Kraus on putting options on the explorer context menu for .DLL files to allow them to be installed in the GAC and to open them in Reflector. As posted his code didn't quite work, so I modified it a little and it is below.

Create a dll.reg file in notepad, copy and paste the following in, then double click it to install the shortcuts. Make sure you change the paths if needed, but be careful to keep the escape sequences intact:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\dllfile\Shell]
@="\"c:\\Program Files\\Reflector\\reflector.exe\" \"%1\""
[HKEY_CLASSES_ROOT\dllfile\Shell\Reflector]
[HKEY_CLASSES_ROOT\dllfile\Shell\Reflector\command]
@="\"c:\\Program Files\\Reflector\\reflector.exe\" \"%1\""
[HKEY_CLASSES_ROOT\dllfile\Shell\InstallGAC]
[HKEY_CLASSES_ROOT\dllfile\Shell\InstallGAC\command]
@="\"c:\\Program Files\\Microsoft Visual Studio 8\\SDK\\v2.0\\Bin\\gacutil.exe\" /i \"%1\""


Thanks Eric

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

code samples