Steve Clements

.Net and then some....


News



MCP

Add to Google
Add to Technorati Favorites



Subscribe to this Blog by Email


this is Steve's profile
Locations of visitors to this page

My Stats

  • Posts - 119
  • Comments - 98
  • Trackbacks - 52

Twitter












Tag Cloud


Recent Comments


Recent Posts


Archives


Post Categories


Image Galleries


Fav Blogs


Fav Places


Services!


Top Kudos



The more I work and develop with SharePoint I am learning that 95% of the task, with a little guidance is a walk in the park, especially when compared to that final 5%, which is either impossible or is the most painfully experience any developer can experience!!

Take my Friday hell for an example...

A requirement comes in for custom news item, with a property that is the users department, but could be changed to another. Sure i think, drop down control, bind to all the possible departments, auto select the user department, getting the value from the users profile.

Converting that into SharePoint, create a custom field, inherit from SPFieldChoice, bind to an SPList with all the groups (add to the base.Choices collection), get the current user from the SPContext, use that to the query the users profile to get the department, set the base.DefaultValue. Cool, now that is sweet, test in a simple column adding to a list, works a treat. The field is wanted for a page content type though so...

Create a site column, add to content type, create custom page layout, drop on...we are rocking so far.

Go to create a page and my group is selected, awesome. Change my group just to test, but nope still selects old group...hmmm...iisreset....nope the same. Test with other users, the same!! Just to confirm, its not selecting the first item in the list, its selecting the department of the admin user who deployed the solution, and what it was when they deployed it!!!!! Now that is nuts, go into a standard list, works a treat!! After hours of thrashing, trying to add it directly as a column to the page library and many others i gave up and came up with a far less appealing solution but a solution none the less....so what the feck is going on here???

Its worth noting that i put some trace code in and found that the correct department was being pulled through, and checking what base.DefaultValue was after setting it showed it was what I expected, but on the page was the admin's original group. If anyone else has experienced similar it would be great to here from you, I can post some code if you like, but its pretty simple stuff and like i said, works in standard items.

I did actually take the time this weekend to create a custom field rendering my own drop down list, the value is auto selected as I would expect, but I the value doesn't display in the "View Properties" or "Published Page" mode, fine in "List View"....its metal!

P.S. I have another one to with sub classing the CQWP, that I might post later.

 


I mentioned a while back that I had something I was working on that involved a change in language, actually a pretty radical change. I have been working on vocational project written in VB.net and made heavy use of LINQ to SQL. I wasn't sure of LINQ to SQL for anything else other than RAD and to be honest I'm still not. Anyway, I'm not getting into that debate. Needless to say I went all the way and don't use a single sproc in this project.

Some of you will know I play cricket every Saturday for a local club (nothing special, just for fun!), well for a couple of years I have been thinking of putting a website together for the club, just never got round to it. However the other day I was looking at the starter kits on the asp.net website and came across The ClubSite v2.0, also hosted on codeplex, basically this is built on top of the original ClubSite, it adds functionality and has layered the code. Problem is, its American and the statistics part of the site relates in no way to cricket, which is a pretty statistics intensive sport.

I decided to write the cricket stats engine (that sounds fancy!), and take the opportunity to write some real code in VB.net and LINQ to SQL. I have pretty much completed this project on my train journey to and from work, which is about 40 mins each way. Working on it not every day, but most for the past month.

The original ClubSite makes use of submodal for its AJAX functionality and some modal popups, I am not really a fan of these and found them to work erratically so have replaced a few and plan to do the rest, using the asp.net AJAX control toolkit modal popup. I have also added update panels to make the UI some what slicker! I code is in no way of a work of art, that's not really been the point of the exercise.

I haven't finished the project, apart from very limited testing, I plan on using silverlight (to tick another "must learn more about" box) to create some pie charts etc to better represent the data. I have actually found some open source examples i intend to download soon.

I appreciate that cricket is a pretty captive audience and cricket playing geeks are no doubt even less, but hopefully I will get some downloads and help if finding bugs and enhancing the project. I have actually only found 1 other site that does cricket statistics and that is a national site and every club has a sub-site within the main site. Far to restrictive for my liking.

Go and check the project out here: Cricket Club Starter Kit

It's also worth mentioning that I haven't changed any of the original ClubSite v2.0 code, I have simply added on to it, mainly because I don't to miss out on anything that gets released/fixed with that project. Apart from perhaps a link of two in the menu to point to my new CricketStats folder and the graphic from a football (soccer ball) to a cricket related image. I haven't even fixed bugs that I have come across, that isn't the point of this project. On Codeplex I have checked all the code in, including scripts to create the schema in the db, but not all my test data (yet). I'm not sure if this is the best way to go about it, it might be better to simply check in the new code and some scripts to incorporate it in into the clubsite v2.0. That might over complicate the whole development process though.

A Few screen shots to give you a flavour!

Games in season overview - (Default.aspx)

clip_image001

Game Statistics

clip_image002

Team Statistics for the season

clip_image003

Player Statistics by season

clip_image004

ADDING AND INSERTING DATA

clip_image005

clip_image006

 


Now that is a bad ass title!!

Anyone who has been through the MindSharp training course for SharePoint and any others that have looked at any code Todd Bleeker puts out there will most certainly be aware of using post build scripts in Visual Studio to deploy your sharepoint project.  This knowledge is of course not limited to MindSharp grads, its just that being one I know what they know!

To get them to work in a Windows 2008 and Visual Studio 2008 environment you will need to make some changes.  As pointed out here, GacUtil has moved so the command will change from

this

"%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\GacUtil.exe" /if "$(TargetPath)" /nologo

to this

"%programfiles%\Microsoft SDKs\Windows\v6.0A\bin\GacUtil.exe" /if "$(TargetPath)" /nologo

...and the command to recycle the app pool in IIS7 has changed, if you try the old way you will most likely get a Microsoft.CmdLib error when building from VS.  The required command has changed from

this

"%systemroot%\system32\iisapp.vbs" /a "[YourAppPool]" /r

to this

"%systemroot%\system32\inetsrv\APPCMD" recycle apppools "[App Pool Name]"

This is as much for me as everyone else as I no doubt will come up against this again!

For completeness here is my postbuild script for a custom field project, you might not want to copy the debug pdb file or create a solution (last two commands)

cd "$(ProjectDir)"

"%programfiles%\Microsoft SDKs\Windows\v6.0A\bin\GacUtil.exe" /if "$(TargetPath)" /nologo

"%systemroot%\system32\inetsrv\APPCMD" recycle apppools "App Pool Name"

xcopy "TEMPLATE" "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\" /ys

xcopy "$(TargetDir)*.pdb" "%systemroot%\Assembly\GAC_MSIL\OC.Sharepoint.FieldTypes\1.0.0.0__[token]\" /ys

MakeCab.exe /f FileName.ddf


My first trip to the new Wembley stadium was to watch the Foo Fighters gig on Saturday night, who as far as I am concerned are the best band on the planet right now. They did well to beat Oasis to that accolade, but heh, Oasis haven't done anything for quite a while now!! For those that don't know Wembley is a 90K seater stadium in London and the Foo's sold out in about 15 mins back in December, typical to big show form they promptly announced a second night (which was Friday), and that promptly sold out :)

The show was pretty awesome, I was quite a way back in the stands, but was directly in front of the stage so had a pretty good view. I don't have a great camera or indeed an eye for a good shot, but here are a couple of photo's.

Led Zeppelin came on at the end to play Rock and Roll and Ramble On, Dave Grohl declared it as the best day of his life, I had fun, but not that much!

The Carlsberg one was taken by the missus, a birthday present idea perhaps! ;-)

foo_wembley_1 

foo_wembley_3

foo_wembley_2

Technorati Tags: ,

posted @ Monday, June 09, 2008 7:28 AM | Feedback (0) | Filed Under [ Personal ]


LINQ goes so much further than just SQL and XML.

Something like this is just why I love LINQ, a LINQ query on an ASP.NET ListView controls items.

   1:  Dim items = From lvi In AspNetListViewControl.Items _
   2:              Where CType(lvi.FindControl("DropDownList1"), 
	                DropDownList).SelectedValue = someIntVar _
   3:     Select lvi)

 

Getting a ListViewItem's where the selected value of a DropDownList is set to the value I want.  So simple, yet so powerful.

The observant among you will notice that this is in VB.net, not my native C#!! More on that soon! :)

Technorati Tags: ,

posted @ Wednesday, May 28, 2008 5:01 PM | Feedback (0) | Filed Under [ .NET LINQ ]


image I was just about to blog about this, then I found this post while scanning the asp.net feedGuy Barrette does a great job of summarising it.

 

If your in a rush, the home page is:

http://blogs.msdn.com/sourceanalysis/

and you can download it from here:

http://code.msdn.microsoft.com/sourceanalysis/Release/ProjectReleases.aspx?ReleaseId=1047

 

While in the link mode; I spotted this at the same time on Charlie Calvert's blog a quick list of keyboard shortcuts for VS2008


Although new to all this MOSS stuff I am getting stuck in with the Content Query Web Part (CQWP) and XSL.  They are a pretty powerful combination, but pretty soon I could see how this could become slightly wild and considering ListStyles.xsl is an "out of the box" file, getting crazy with custom files could become more of a problem than simply a huge file. 

Check out these two posts on how to manage custom styles.

1. Liam (Sharepoint MVP here in the UK) posts about editing the ListStyles.xsl, but only to add import statements to your own custom csl files.

2. Brendon Swartz post about how to create a new CQWP instance by exporting the default one, editing the webparts xml definition by adding a statement to reference your custom xsl file.

I guess it comes down to whether you are happy, or even able to edit the ListStyles.xsl file, number 1 is certainly the easiest route and my choice, but I can see value in having a CQWP instance for each style.  I certainly am no fan of big changes in OOTB files, granularity is good :)

 

Technorati Tags: ,,

As errors go I found this one is pretty horrific.

I got the error deploying a windows service written in .net 3.5 from my Vista x86 dev rig, to a 2003 x86 server.  Only having the .NET runtime installed on the server I wrapped the service up in a deployment project.  The service installed fine, however when trying to start the service I got a "The service did not respond in a timely manner" error.  Initially, like you would, I thought there was probably an error with my code in the OnStart method, but alas nothing in my beautifully crafted exception logging framework(!), over to the event viewer and this little beauty!

The complete error is...

EventType clr20r3, P1 <servicename.exe>, P2 1.0.0.0, P3 4816d837, P4 system, P5 2.0.0.0, P6 471ebf0d, P7 36d5, P8 7f, P9 system.argumentexception, P10 NIL.

The error is titled...

.NET 2.0 Runtime error. (Which through me a little, I'm on .net 3.5!!)

After some intense googling I have pretty much "Jack", no clear answer from the MS forums, despite input from MSFT staff.  Something that kept popping up was that I was referencing something in the framework that wasn't installed on the server.  So I checked every reference manually on the server, I even thought there might be a problem because some of the .NET dll's on my machine are in "/ProgramFiles (x86)/...." the server not being x64 didn't have this folder so, I created it! (Not convinced, but worth a shot!) Nope, same error.

Right, most who have seen this error report no problem on their dev machine with VS installed and get it on machines with just the runtime installed.  So, feck it, I installed VS 2008 on the server (clutching right!), I just though perhaps there was something VS installed that I was referencing somewhere...at the very least I would have debug tools installed, speed up the process and could rule it out.  Nope, same error.  Now I can't actually attach a debugger to the process can I, as the service hasn't won't start!

This is mental!  As far as I was concerned I had nowhere else to go.  By the way, somewhere in there I actually tried to run the service on a different x64 2003 server, but still the same error.  I got another service I have been working on, hacked it about so it would build and run (making sure I was referencing the same libraries as original project).  Same drill, wrapped it in an installer, spun it up on the server, started first time!!!  Right, nothing to do with the framework, clearly the issue is local to my project.

I created a new project and copied in any custom classes and basically replicated exactly what the problem service was doing, IT WORKED.  The only thing different, when I created the first project, I deleted the "Service1" that the project template creates.

If you have made it this far down the post in anticipation of the first cause and "concrete" solution for this error, I am sorry to disappoint, but all I have is it to create a new project and start again...VS must be doing/wanting something weird in the background.  After wasting a hours on this I don't have the inclination of patience to look further/deeper.

Perhaps someone has had similar experiences with the error and could enlighten the rest of us?


I would love to hear thoughts on this.  At my new place of work they have a "swear pot" and in this pot goes 20p for every overheard swear words, now I'm not talking about only the good stuff, the rule is apparently if you wouldn't say it in front of an 8 year old, then it counts.

This is going to cost me a fortune, its not that I am a potty mouth, but I am of the opinion that swear words, as they are branded, are a part of the much loved English language and at times, quite simply nothing else will do.  The F word for example is a particular favourite!  Again I must iterate that I am capable enough to exercise common sense and would not shout such "considered" bad language across the office (although would not be offended if someone else did). 

You could say I have answered my own question, if I wouldn't shout it across the room, then should it be said at all?  That's a subjective point and can be compared to many different things, movies for example, hence the age grading system.

So, does "adult language" in the workplace (or anywhere) offend people or like me, do you consider it part of the English language that used correctly is perfectly at home in friendly adult conversation??

 

Technorati Tags: ,

I have been running Google Analytics on my site for while now, cant remember exactly how long!  Its pretty good I guess, I haven't really looked at any others!! What I did find interesting was looking at the number of hits from the US - I get more from the US, which is obvious seeing the GWB is a US based concern and well, it's not exactly a small place!!  The UK is second though! woot woot!! clearly the highest concentration of geeks, I haven't met either of them mind! :)

I almost have a 100% of the states covered...

image

...just Wyoming and a little one on the right, Delaware, I didn't know either of them!!  What's wrong with these two then? Obviously they are Java states!!