Saturday, March 22, 2008

Orlando Code Camp - another great community event

Three central Florida .net user groups pulled together an awesome event today. Great sessions, good and healthy food, excellent facilities, price tag -- zero!

I would like to thank all of the attendees that came to my sessions. Follow the link at the end of the post to download the presentation slide deck and the sample code.

Slide deck 1

Slide deck 2

Code Sample

Dovizhdane!

Friday, March 21, 2008

Excellent introduction to Silverlight

This is an excellent book for developers starting to get more involved in Silverlight. I already had some exposure to Silverlight from presentations, demos and screen casts, and this book helped me get the bigger picture of Silverlight by describing from A-Z the essential components and techniques of this RIA platform. Even though it is dedicated to Silverlight 1.0 IMO about 80% of the book is applicable to the second beta of the platform. The XAML chapters worked for me on Silverlight 2 Beta and with some patience I was able to translate most of the JavaScript code samples to it's C# equivalent.

The book contains detailed information about all moving parts in Silverlight. Without being a boring reference book the content is presented in clean technical language with good examples. The code can be downloaded from the site of the publisher, but for the XAML part I preferred to type it myself using IntelliSense, so I can play with different options.

I particularly like how the author presents functionally similar components, such as transformations, brushes or animations, starting with the simplest variation and building up to the most complex. This not only shows the logical gradation in their functionality, but helps the developer to find optimal control for a given task.

The author frequently points out the difference between WPF, Silverlight 1 and 2, which helps to distinguish between seemingly similar features in all of these three presentation foundation flavors.

The color print was a pleasant surprise and certainly makes the content easier to comprehend. The color also helps to better demonstrate some of the more compelling visual effects in Silverlight.

Since the author, Adam Nathan, is a Microsoft developer on the Silverlight team, I really hope that he'll write a second edition of this book updated for Silverlight 2.

Dovizhdane!

ISBN: 0672330075
ISBN-13: 9780672330070

Thursday, March 20, 2008

MOSSMOSIS - Orlando

This Month: Intro to SharePoint Designer

When / Where?
Wednesday, April 2, 2007   - 6:30 PM EST

Orlando Public Schools Administrative Offices
445 West Amelia Street
Orlando, FL 32801 – 1129

How to sign up?
http://www.clicktoattend.com/?id=126847

Who Should Attend?

Developers, designers, power users, architects,
administrators.

What will be covered?
In this session we will dive into SharePoint Designer. 

Who will be speaking?
Scott Schwarze

Disappearing web.config entries

How many times have you experienced a chilling moment when something goes terribly wrong with the system you just touched and you don't have any clue what would've caused it?

In a SharePoint installation with multiple web applications and several custom solutions there may be a lot of action going on in web.config files. Even the slightest validation error in these files will bring the web application to a halt. This and the fact that the SPWebConfigModification class has a will on its own make the task of coordinating web.config modifications a very touchy business.

Recently one of my colleagues reported that after installing one of the SharePoint solutions, entries installed by another solution were disappearing, leaving the web application in chaos. Logically I started poking the features in the SharePoint solution, which was "causing" the issue, but this lead me to no where.  I only learned that when you call:

webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();

The web.config files for all web applications get rewritten, regardless of which web application is being updated. But this turned out to be a "feature" of SharePoint. Then I started investigating what other web.config modifications are being created by the rest of the solutions on this server. Luckily most of these belong to our company, so I was able to pull up the code. All features worked correctly when executed separately, but still in a particular sequence some of the web.config modifications were disappearing. And there it was ... one of the features was adding the modifications correctly:

SPWebConfigModification modification = new SPWebConfigModification();
modification.Path = "...some path..."
modification.Name = "Example"
modification.Value = value;
modification.Owner = "Owner"
modification.Sequence = 0;
modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
webApp.WebConfigModifications.Add(modification);

then applying the changes to update the web.config:

webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();

But there was no webApp.Update() to persist the changes in the SP database!

It turns out it is very easy to omit this part, because when you develop or debug such feature all will work fine until something does not flush the application pool thus disposing off the newly created SPWebConfigModification. The next solution or feature that calls ApplyWebConfigModifications will force reapply all modifications pulling them from the SharePoint database. For some features this actually might be a welcome side effect, but unless this is not the case you need to call webApp.Update() to permanently save the modifications to the SharePoint database.

One mystery solved. Next, please!

Dovizhdane!

Orlando Code Camp - Sold Out!

Just noticed that the Orlando Code Camp is sold out. This is going to be another super-charged and totally free event organized by our friends at ONETUG.org. I signed up as a speaker with my two sessions from South Florida Code Camp. They were very well received in South Florida, so after some adjustments I decided to give them one more run. Come with your experience and ideas and lets talk about how we can avoid some common frustrations in SharePoint development.

I'll be carpooling with some Brevard developers, so if you need a ride or you want to save on gas contact me today or tomorrow to give you the details.

For details: http://www.orlandocodecamp.com/

Dovizhdane!

Tuesday, March 04, 2008

Unable to add selected web part(s).

Every once in a while when you create a web part or upgrade web part, or do some of things developers do when developing web parts, there comes the chilling moment, when you see an error message such as the one below:

So the question is what do we do in this case? Before you hit the discussion boards, or worse, start pulling your hair, here are couple of tips you can use to troubleshoot the issue:

  1. Make sure the control is registered as safe in the web.config (duh...actually the error says what it means, right)
  2. Make sure the assembly is accessible and in the [port]bin folder. (obvious, but worth mentioning)
  3. Make sure the assembly name in the *.webpart definition file, matches the assembly name in the safe control element in web.config
  4. Make sure you don't have more than one *.webpart file for the same web part in the web part catalog. This may happen if you changed the name of the *.webpart file.
  5. Restart IIS to start clean. Attach the debugger to the w3wp.exe process and try to load the page with the rogue web part. This way you can determine the exact location of the assembly you are loading.
  6. Check if the web part class exists by opening the assembly with reflector. This might sound funny, but in a bigger team, when different versions of assemblies are flying around it is very easy to overlook something and to use the wrong version, which so happens does not contain the web part class at all.
  7. If you have other tips or suggestions, please add them as comments.

Phew, I think I dodged that one... It turned out I got an older version of the assembly and my web part class was not even there.

Dovizhdane!

Unable to add selected webpart(s). A Web Part or Web Form Control on this page cannot be displayed or imported. The type could not be found or it is not registered as safe.