Something is locking me out of my assemblies ... after a clean Get Latest from TFS, i go to a command prompt and run my MSBuild script ... it fails with errors reporting it cannot delete the directory as it is not empty, and then proceeds to report a host or errors updating assemblies as access is denied. If I then go back to Visual Studio I get the following error for every project .... "Cannot analyze project output:"
I don't know if this is Visual Studio, TFS or ReSharper causing this but it is annoying me to hell ... closing the solution lets me run MSBuild perfectly again ... anyone got any ideas?
UPDATE: Turns out that this is a ReSharper error certainly present in 3.1 ... I found this out as the amazingly responsive ReSharper team took a look at my post, and replied immediately admitting it was a bug of theirs. It also turns out it was already fixed in version 4.x but not in 3.x ... after a very short whine by me to Ilya at JetBrains, he then dropped me back an email very soon after telling me the changes had been back ported into the 3.x build, and would appear there from the next nightly build. Now that is responsive!
Suffice to say, and good to their word, the error is no longer present ... Yippppeeee!!!!!
Thanks for the many suggestions I had to try and pin this down!
OK, so I figure it's 6am - in the interests of personal education, and possible improvement of my framework for my client, I decide I best get down and dirty with Unity and see how simple it is to replace Windsor in our current application. If it is simple, and it makes the application simpler, then I'll go the Unity route (as a MS fanboi I really do prefer the MS option where all other factors are equal). Some debate on altdotnet made me consider my position on it. Unity is roughly comparable to IoC containers like Windsor and StructureMap, the CodePlex site description says: The Unity Application Block (Unity) is a lightweight extensible dependency injection container with support for constructor, property, and method call injection. So ... I download the project from CodePlex ... and double click the solution file ... I only have VS2008 Development Edition on this laptop, no VS2005, so a conversion is required. OK - I have done this before - it should work right, after all CodePlex says: You can modify or extend the Unity Application Block using Visual Studio 2008. When you open a solution, Visual Studio 2008 will upgrade the projects to its format and you can edit and compile the code to create assemblies targeted at version 3.0 of the .NET Framework. However, you will not be able to convert the projects back into Visual Studio 2005 format. Therefore, it is a good idea to work with a copy of the original solutions and projects. Guess what ... the conversion fails. Well mostly it works, but all of the Unit Test projects fail to convert. Come on MS ... these are your things ... your IDE, your conversion wizard, your CodePlex project, and your unit testing framework - this is not rocket science. OK - I'll give you a little leeway as Unity is a CTP ... So I close it down after struggling a little with the sample applications when I don't have unit tests to read (more on the sample apps shortly). Go and read CodePlex for 20 mins to try and see if anyone has these problems, but with no luck. I brace myself to figure this stuff out without unit tests, and double click the solution again. It now tells me it needs to do a conversion. Deja Vu moment ... surely I just converted it already ... maybe I was dreaming. I tell it to do the conversion, and bingo it converts successfully, including all the unit test projects it failed to convert 20 minutes ago. Inconsistent behaviour annoys me ... either fail to convert every damn time, or work every damn time, but don't pick and choose based on some ethereal criteria I am unaware of! Right ... I have a full solution loaded ... lets compile this and see it fly ... Nice idea ... except VS thinks otherwise ... all references to using Microsoft.VisualStudio.TestTools.UnitTesting are showing red in the test projects. All references are broken ... they point to Microsoft.VisualStudio.QualityTools.UnitTestFramework correctly, but they show pointing to version 0.0.0.0 which I guess is the VS2005 reference misbehaving in VS2008 ... so I have to manually update each reference, either by changing the "Specific Version" property to false in which case it auto picks the version 9.0 assembly, or by removing the reference and re-adding it (and we all know how tedious that is to do). Why????? Why make me go through all this to see Unity, when every tool I was using was from MS ??? I understand it isn't entirely the fault of the Unity team here, but surely you guys are in the best possible position to know about the way each others products work. I choose MS products because I expect them to *just work* out of the box ... I choose certain OSS products expecting them to not be packaged as nicely, or as well documented, and expect a few niggles. So I have wasted at least 30 minutes on Unity already, and haven't read any code. Please Microsoft, make your things play nicely with each other ... is that too much to ask? Right ... off to actually see how Unity works, and how it can make my life easier now ...
Whilst reading a great article on getter and setter methods, I came across a small quotation that perfectly encapsulated the problems I see with a lot of code at my current client: Developers by their nature have a desire to hang on to global data, and to create global methods.
In 1989, Kent Beck and Ward Cunningham taught classes on OO design, and they had problems getting people to abandon the get/set mentality. They characterized the problem as follows:
The most difficult problem in teaching object-oriented programming is getting the learner to give up the global knowledge of control that is possible with procedural programs, and rely on the local knowledge of objects to accomplish their tasks. Novice designs are littered with regressions to global thinking: gratuitous global variables, unnecessary pointers, and inappropriate reliance on the implementation of other objects.
This problem is particularly common where I am at present as a large part of the development work is in MOSS 2007, which encourages global data and methods in a large number of insidious ways.
I'm now off to re-read Beck and Cunningham in more detail ... but in the meantime, pretty please MS, could you stop encouraging bad practices!
There are many forms of speed bump in development, things that cause you to slow down, stop, change your train of thought. From large things like people coming to your desk and asking questions, to smaller things like your IDE pausing for that half a second to refresh the screen. In fact if you think about your day, it is amazing how you get any work at all done with this many distractions and diversions. But, to me, the most annoying of all these things is a poorly thought out IDE - after all I spend a lot of my time inside it, and that means a lot of my wasted time is caused by it too. On the ALT.NET mailing list Frans Bouma suggested that most refactorings were small things that take less than a minute to do without a tool like ReSharper or Refactor. To me - that is a speed bump - it is a minute I really shouldn't have to waste, just because I thought of a better way to structure a small part of my code. I don't think I have ever written a piece of code that was right first time, so pretty much I refactor everything I write to some lesser or greater degree. Visual Studio is a great IDE, but it still has lots and lots of annoying things, and the refactoring it supports is pitiful. So for me, ReSharper is essential, it removes so many speed bumps from my daily path, that I can continue onwards and keep watching the road.
Surely some mistake? I write an Event Handler for SharePoint 2007, deriving from SPItemEventReceiver, and all is well. Until I try to put in some basic IoC using the Windsor container. My thinking is that Windsor will allow me to separate the mechanism and plumbing of the Event Handler from the implementation of my nitty gritty stuff - and indeed it does - all is well and good. Until, that is, I decide to put the Windsor container where it really belongs, in the HttpApplication global scope. My first try for testing this was : if (HttpContext.Current.Application["WindsorContainer"] == null)
HttpContext.Current.Application["WindsorContainer"] = new WindsorContainer(new XmlInterpreter());
IWindsorContainer container = (IWindsorContainer)HttpContext.Current.Application["WindsorContainer"];
Which was all well and good until my Event Handler just fell over ... so I stepped into debug mode ... and was beffudled ... there is no HttPContext.Current ... Nor is there any SPContext.Current either ...
This is confusing, and annoying ... my event is clearly working from an event on a list, which is clearly running within a web application, and within a SharePoint application. Apparently I'm not the first to discover this, but I haven't found a solution yet ... AAARRRRGGGHHHHHH!!!!!!!
Update: Oren and Ken both came up with similar suggestions on how to improve this situation specifically for Windsor, by putting a static class within the assembly that has the container within it. Certainly makes this a little more palatable from the Windsor point of view, but this isn't just a Windsor issue ... SharePoint really does enjoy making my life hell! :)
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!
It looks like even the released version of ReSharper for VS2008 may have some quirks and glitches, even when targetting .NET2.0 - apparently the C#3.0 compiler is always lurking ...
ReSharper 3 can be installed with Visual Studio 2008 and works fine, unless you are using C# 3.0 new features, like lambdas, LINQ, extension methods and such. This constructs are not parsed by ReSharper 3, which was developed to support C# 2.0 only. It is not only highlighting which doesn't support C# 3.0, it is all the core and code intelligence. For example, rename refactoring will not find usages of extension methods and will not update them. There also could be some glitches, even if you don't use new C# 3.0 constructs. This is due to the fact that C# 3.0 compiler is always used in Visual Studio 2008 C# projects, regardless of target framework. It it is not widely discussed, but changes in language are wider than just several new features. There are differences in type inference in generics and candidates lookup for binding, to name few. If you happen to hit this special cases, ReSharper could behave incorrectly. ReSharper and Visual Studio 2008
Still not a good reason not to use it, but something to be aware of.
OK, I am slightly exaggerating ... but honestly, without ReSharper, Visual Studio 2008 is painful to use.
Why on earth couldn't they have improved refactoring and editor support as part of the upgrade. Sure the .NET 3.5 stuff is fun, multi targetting is cute, and those yummy visual designers ... but I spend 90% of my VS time actually typing code, and for that VS2008 still sucks almost as badly as VS2005 did. Have MS conceeded that Jetbrains can do a better job of the editor than they can?
ReSharper works in VS2008 - but not quite...

...and that 'not quite' bit is very irritating. It is better than nothing, but roll on ReSharper for VS2008 proper.
edit: Jeffrey Palermo has a couple of good tips ... but I still feel the pain!
As a contractor I move between clients on a regular basis, and there are certain things I miss when I arrive ... the things I miss the most though, are:
ReSharper
Seriously, how can you develop without it? I guesstimate I lose 2-3 *hours* a day ithout it just typing redundant code or manually refactoring code. The auto rename of files to match the containing class alone saves massive amounts of time. Not to mention it just makes my code 100% better than if I had coded it by hand.
TestDriven.NET
Testing without it is just ... tedious. Right click a method to run the unit test, right click a class to run all the tests in the class, right click a solution ... well you get the idea. There is nothing faster or easier.
Now that Jamie has sorted his differences with MS, we can all get on and enjoy using it.
Almost everything else I can live without ... well except caffiene!
I'm still not sure this is a great idea, but I'm sticking with it for the moment.
Previously I would be described as a MS Addict ... Outlook + Exchange Server (remotely hosted) for Mail, Outlook for Calendar, Outlook for Tasks, Outlook for RSS, Office for Spreadsheets and Word Processing, One Note for note taking. Damn, I'm even writing this in Live Writer!
Recently I have found that I tend to switch machines fairly often, or rebuild machines, or swap disks, or a multitude of other things that the MS suite was not making easy for me. So I decided to try out Google Apps. It was also an opportunity to change my host for my blog saving me a tidy sum per month, and to switch from SubText to dasBlog almost entirely because I couldn't face setting up SubText again (I'm sure it isn't really that hard, but shared hosting providers tend to make any task painful).
I also have a few other people at my domain, notably my father, who is the most computer illiterate person on the planet bar none. He has mastered Outlook over the past couple of years to the point where he can send and receive emails but not a lot more. Even Internet Explorer is a challenge.
So in summary:
- Exchange mail to be replaced with Google Apps mail
- Google Apps mail to auto read my personal GMail stuff (which primarily existed due to hassles with spam in Exchange and the less than brilliant web access front end)
- Use Google Notebook instead of One Note as I tend to be remote when I tend to need to note something down
- Use Google Calendar for some basic reminders
- Use Google Reader for my RSS reading
- Setup my personal homepage to have my new Google Apps stuff in the WebParts
- Cancel my existing hosting accounts and setup a new one (I have 2 companies so it was time to consolidate too)
- Setup a new mail account for my dad, and remotely get his Outlook talking to it.
That shouldn't be too hard should it!
And within reason it wasn't, though there are certainly some peculiarities, and some things still bugging me.
The easy part was setting up Google Apps. Simple process, quick to do, plenty of simple options, easy verification - in fact I can't knock the setup process. Well done Google.
Next was pointing my MX records to Google. OK, that wasn't so easy, but mostly as my name registrar had some odd settings in my DNS records, and after a lot of messing around I got it sorted. MX pointing to Google, CNAME or ANAME (still not sure which) pointing to GoDaddy. GoDaddy got chosen based on a lot of comments I have read around the net, about the general good quality of their service. And for their prices, you can't go far wrong.
Google Apps mail took off right away, and is working beautifully. The spam settings are so much better than I had, though I miss decent rules management and I'm still not totally sold on Tags vs Folders. I still have my Outlook connected via IMAP to my Google Apps mail, for those times I want to send a nicely formatted email (Google's editor is terrible), but I'm trying not to use it.
The blog was a bit harder, and still irritates me. Most is fine, though as dasBlog couldn't import my BlogML from SubText, I had to repost manually some old posts, so most are missing. To make that worse, the permalinks in SubText use '-' characters for spaces, where as dasBlog uses '+' or nothing. So all the old permalinks are broken. I'll just set a 404 I thought, but oh no, that won't work. Between GoDaddy's 404 rules, and .NET customerrors, and dasBlog URL rewriting, I can't get anything reasonable working. Sorry!
Google Notebook works nicely, and works just fine on my start page in a web part.
Google Mail works nicely too, with a few of the quirks of Google Mail that I can live with.
Google Reader doesn't. It seems not to like the Google Apps account from the web part that Google provides and always shows an error. Clicking on it is fine - I get to all my feeds, but just can't see them from the start page.
Google Calendar does the same as Reader, sort of. In fact so far I haven't managed to use the calendar really, because the link to get to it is quite convoluted if it isn't a GMail account. I'm working on this.
I found a few 'To Do' web parts to use, they all work nicely, much better so far than tasks in Outlook.
Getting my dad setup was ... an experience. Suffice to say after we retyped all the settings I asked him to enter into Outlook a dozen times, he now has POP access working, and very nice it is too. I didn't want to give him IMAP as it would be a culture shift with the way Google exposes tags as folders. I also ran him through using the web interface, in the hope he may prefer it, and he is starting to like it - if I can get him off Outlook one of my support nightmares goes away.
Today I started putting all my expenses and VAT onto a Google spreadsheet, and hopefully I will use it more this way, the lack of my local file meant I often forgot to record things, or put them in too late. This is something I am very poor at, and I'm hoping having the data online will mean I can update it when I think of it, from wherever I am.
Overall, not painless, but a lot better than it could have been. And hopefully I can get back to basics in my information management, and perhaps improve something which I am notoriously bad at.
Alex believes that SharePoint is driving him a bit crazy, and Ayende defines that as a nightmare platform. I agree to a large amount of what has been said. SharePoint does drive you crazy. Currently I'm looking at doing things in SharePoint that will take a number of times longer to make work in SharePoint than if I was to write it in ASP.NET directly. It will also be less maintainable, harder to deploy, and nearly impossible to test. There are however very valid business reasons for a lot of the decisions being made, and the approach that is being taken. It probably wouldn't be the way I would approach it if it were my business, but it isn't. So that leaves me in a similar position to Alex ... I don't much like the platform, and I'm doing a lot of hacky things to make it do some really simple things, but in theory the pain will pay off in the end because the power of SharePoint will let users do some useful and clever things. Until then, I console myself knowing that the work pays fairly well.
If anyone actually wanted to read anything I have written in the past (a vague possibility I know), then I apologise in advance for switching hosting providers and blog engines ... because eveything is lost in Limbo Land (tm) for the moment ...
Normal service will resume shortly.
Update: I have recovered some of my more useful posts. Due to a tedious process to get these into DasBlog, the ones that were mostly for my own information I will keep on my hard disk for now. If there is anything you really needed ... email me!
It is amazing how much time you have to think while painting a house. Painting is tedious, repetitive, and one lapse of concentration leads to a mess that takes a lot of effort to sort out. In fact, whilst painting it occurred to me there were a lot of parallels with software development.
Firstly, preparation. Doing your groundwork first saves time in the long run, makes for a much better job overall, and prevents "unforeseen eventualities". In software that means making sure you have your requirements established, have your processes in place, have your team up to speed on the technologies you will be using, and in general have a plan of attack.
Secondly, attention to detail. It is so tempting to just skip a bit, not paint right up to the edge, use only one coat when two are really needed. After all - who would notice? Likewise with software, the temptation is always there to skip proper exception handling, not check values passed to your function, assume that the developer that uses your class won't care if you don't use meaningful method names. Short term gain, for long term pain.
And satisfaction value ... a job well done is one you can be proud of, that makes you feel all fuzzy and warm inside. So it has some plus points even if it takes a little longer and takes a little more care.
On the plus side, the hallway is nearly finished, shiny new white woodwork, deep luxurious 'sienna sun' walls (brown to the uninitiated).
Technorati Tags: development
|