Tuesday, November 24, 2009

SharePoint 2010 - virtual vs non virtual

This has been a very bad week - since the Beta of SharePoint 2010 came out I have been trying to install it and set up a demo environment for developers on my laptop - without much success. Since 2010 requires 64 bit, this ruled out using VPC, and since I don't like using 2008 as the host on my laptop, this meant I had two choices: virtualize with a non-MS solution that allows 64bit clients (virtualbox by sun or vmware) or install sharepoint directly on my windows 7 host - which means I would have Beta software running on my production laptop.

I chose to try virtualbox - and failed twice. First I installed windows 2008r2, and during my presentation to the user group last week it was a disaster - the site kept crashing with unknown error, nothing in the logs and nothing working.

Then I installed a fresh install of windows 2008 with all service packs in the virtual environment - and again installed sharepoint. Again - same symptoms - the site crashes and works SLOWLY.

Finally today I gave up and installed the entire 2010 beta system on my laptop itself - on the windows 7. Apart from the fact that I had to download and install the prerequisites manually (on the server it did it automatically for me) and apart from the fact that I didn't follow the instructions very well (I used 7-zip to extract the .exe file so I can change the config.xml file - which put all files in the one folder - losing the hierarchy. it turns out this gives a "wrong language" error (I forget the exact syntax)) the installation went quickly and easily - so now I have a stand alone windows 7 with sharepoint 2010 and office 2010 and VS2010.

I will keep updating when I have time to play with all of the above...

Modified date stopped working...

So here is the scenario - I had a piece of code in a feature that changed the title of the built-in site column "Date Modified" to...well..."Date Modified". As you can see, the code looks a bit useless, but someone thought it would be useful, so there it was. Next thing I know, the date modified field stopped working in out of the box document libraries. You would edit a document or its properties and the modification date would be the same as the creation date. This would even show in the version history...

Solution - I had to write a small piece of code that would set the SchemaXml property of the site column to the default. It turns out that if you change the field using code (like SPField.Title="Date Modified"; SPField.Update()) then sharepoint removes some very important tags from the schemaxml property of the field - which causes it to break. To fix I just copied over the SchemaXml property from a site column in a brand new site that was not damaged.

Code sample:

try

{

using (SPSite site = new SPSite(txtSite.Text))

{

using (SPWeb web = site.OpenWeb())

{

SPField field = web.Fields.GetField(txtField.Text);

if (field != null)

{

field.SchemaXml = txtSchema.Text;

field.Update(chkUpdateLists.Checked);

MessageBox.Show("Operation completed successfuly");

}

else

{

MessageBox.Show("Field '" + txtField.Text + "' could not be found in the site columns in" + Environment.NewLine+ "'" + txtSite.Text + "'");

}

}

} } catch (Exception ex)

{MessageBox.Show("An error has occured : " + Environment.NewLine + ex.Message);}

Sample schema: <Field ID="{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}" ColName="tp_Modified" RowOrdinal="0" ReadOnly="TRUE" Type="DateTime" Name="Modified" DisplayName="Date Modified" StorageTZ="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Modified" FromBaseType="TRUE"/>

Thursday, November 12, 2009

Event handlers in SharePoint 2010

This is too cool...so many more options - take a look at the visual studio 2010 wizard for creating an event handler - it is more than just list items...

I really like the web events - these will be very useful and will allow creating complex solutions without site definitions.

As soon as the beta is out I will write some samples!

Thursday, October 22, 2009

Closing thoughts from the SharePoint conference

I am sitting in the last session, and I have to admit- I am a little bit afraid of SharePoint 2010. There is just so much more, that it makes the step from SharePoint 2003 to 2007 seem small in comparison. I think we should thank the SharePoint product team for an enormous effort to get all this new stuff in - and give us some very complex stuff to work with.

I am looking forward to doing search solutions, writing visual web parts, developing better event handlers (post synchronous events!), designing in sharepoint designer and then moving the design to visual studio and more and more and more.

If you get access to the presentation videos - make sure you listen to Mike Ammerlaan's presentation titled "Architecture guidance for building applications in SharePoint 2010" - not sure how much of that will be reviewed during the beta period (starting next month) but this was THE best and most important presentation in the conference - giving us thumb rules of what to use when, and some key pointers to making decisions on what to use in different development scenarios. Thanks Mike!

Finally, there are things I am dissapointed with - like a continued lack of support for custom fields in office, and no exciting new field controls. But the good overweighs the bad. I will have a think about what I have seen in the next two weeks, and then start blogging again - from TechEd Europe.

For now - I am going to see the grand canyon, visit Munich, and have a week's vacation in Israel with my family. Be patient, and more posts will come in tow to three weeks. If you are coming to TechED and want to chat - see you in Berlin in the Ask The Experts booth!

Wednesday, October 21, 2009

What I like and dont like about the new BDC (the BCS)

To get one thing clear - when BDC came in MOSS2007 I was very excited about it. I really thought it was great...until I had to do a real life project with it.

No, I am not talking about the pains I went through to create an application definition (this was before the BDC metaman or the tool that Microsoft released a bit later) - I am talking about how the BDC integration to sharepoint was so limited.

Every single customer who had a problem that I wanted to solve using BDC had the exact same requirements that I couldnt give them using BDC:

  1. We want it to work in office
  2. We want it to be a multiple item selection

There is no way in MOSS2007 to achieve both in BDC. You can develop a custom field type that will allow multiple selections from BDC information, but you cannot use a custom field type in Office. And the built in BDC column type only allows single selection.

That makes me sad.

In 2010, the "BCS" is much improved. It makes me even more excited about what I can do with it. It has "external lists" - which are fancy web parts that make the BDC data appear to be as if it is in a sharepoint list- including filtering, adding items, editing items and so on (not full functionality of a list though). There are two designers for the applications - no more XML! just use sharepoint designer or visual studio and create application definitions easily. Heck, in VS2010 you can create the connector to the LOB system in the same project as the application definition model - and refactor stuff later. This is EXCITING and GREAT stuff. Not to mention the object model, the (much) better support for item level security and so on.

But it still does not solve the problem I described above - the BCS column type is still a single lookup.

I was hoping that Microsoft would introduce better support for custom field types in Office 2010, but that is not happening either, so there is no oppertunity for me to develop a custom code to do that.

This makes me even sadder.

Can everyone please join me in asking Microsoft to

  1. Release a better BCS field type before RTM of as part of SP1 and make BCS perfect
  2. Redesign how custom fields are supported in office applications for SharePoint 15

Meanwhile, I will enjoy the cool new features.

Tuesday, October 20, 2009

Joke of the day from SharePoint conference 2009

quote: "if I don't need to dispose objects in the client object model, and it can do whatever you can do in the server object model, I am going to use it on the server!"

Ishai comments: good joke - do not take seriously please...

Update: it turns out you do need to dispose of them (when using them in .Net applications)

Upgrading custom developed solutions to SharePoint 2010

I am sitting in the presentation by KwizCom who are telling about their expirience with upgrading their products and web parts to SharePoint 2010. This is exactly the kind of session I came here to hear - get real life expirience from real life senarios.

Shai Petel is a huge expert in SharePoint development - his presenation is focused on what you need to do Today to make your current projects be ready for the upgrade.

He suggests to train the developers to use Ajax, JSON, silverlight, visual user controls (which I have to admit - it has been ages since I developed a web interface with a designer!).

He also suggests that if you want your solution to be hosted in the cloud, try to limit the solution scope to a site collection level. He did not explain, but I am guessing this is because of sandboxing restrictions.

Shai also encourages you to make sure you use the ASP.NET web part class for your web parts. He explains that the WSS web part class is supported for backward compatability, but does not recommend it.

Shai also recommends working on windows 2008 R2 and running hyper-v machines as your development environment. I don't agree - windows 7 is a (almost) perfect operating system, you can run moss on it, and using Sun VirtualBox (free, and open source) you can create 64bit virtual machines - and from my expirience on my laptop - win2008 just doesnt run as fast.

Now to upgrading a solution. Shai stresses that you should use the same namespacec and assembly evidence - this will allow sharepoint to recognise your solution during the upgrade.

Shai talked about upgrading his "sharepoint list forms extensions" - he showed how the solution looked like in 2007 - both in the screen (new links in list settings and in list forms) and in the code - showing a solution (connected to source safe? who uses source safe these days? or maybe I misread what I was looking at?). He then showed what he added in the 2010 version for the same solution - explaining how in 2007 they couldnt use WSP packages for the solution (due to limitations of the WSP infrastructure) and how now they are using WSP (due to improvements - mostly around version management - see further information below).

Shai opened a new empty VS2010 project, and built the structure for the project that you want, and then migrated his old code into the new project. Then, using a designer in visual studio, defined what features (from the old solution) should be deployed by the solution. He suggested it takes up to 4 hours to do that on a big and complex project.

He then showed how he added new code (or, rather, XML definitions) to replace old custom actions with new ones that would put the custom actions he had in the tool bars into the ribbon instead.

At this point Shai's Virtual machine crashed (working on pre-beta version - this is happening to many speakers here I guess. this is the second presentation in a row that I see this happening to) so he continued with his powerpoint and concluded that with a project that DIDNT use VSEwss (visual studio extensions for wss3) is pretty simple - create new project in VS2010, import existing files, set up the features (using a designer) and add what ever you need.

With projects that were created using VSeWSS need to be opened using a tool that comes with visual studio 2010.

To upgrade an existing WSP package - there is an import wizard in VS2010 that allows you to select which part of the solution you want to import, and it imports it into a new VS2010 project - all except the code. So it does give you the feautres and images and so on, and puts them in the new project structure that VS2010 needs.

About versioning support in packaged solutions - Shai explained that this was missing in 2007 - and is now available. I had many headaches with WSP packages versioning - it is very hard to mark a version number in a package - you have to keep updating a web.config file to make sure sharepoint uses the new version if you change the version of the dll. Shai suggested the same method I have been using - store the version number on a file that is deployed with the package instead. An "about" page can show the user what version is deployed on the server.

Shai then explained that he recommends deploying solution resources into a folder marked with the version number - for example : "_layouts/mysolution2.0.0.1" - this will make sure the solution can be hosted - and then upgraded just for one customer that uses the server, while other customers use the old version - the resource files were not overwritten (remember the assembly in such scenarios is sandboxed - so not in the GAC but rather in SQL and is unique per site collection - which allows this kind of trick).

The new user interface for managing solutions in a site collection (sandbox) will show you if there is an upgrade available for a solution. Us developers can specify that a solution can be updated, and then sharepoint will show that to the users. I expected something more sophisticated - something like how most applications today do upgrades, but I need to get my hands on this feature before I can comment on it fully.

To summarize - good presenation (if a bit rushed and mis-titled) and exciting things ahead!

SharePoint 2010 Web Parts and WiKi pages

Wiki web parts - are new and do not have web part zones. You can add the web part in the text. This will allow us to give an option for the end users to create a page without an underlying page layout.

This works with hidden zones - which is where the web parts are actually stored but the location of the web part is marked in the wiki content using place holders. During rendering the webpart contents are moved to the in line location after rendering. Maurice just showed what happens if you retract a solution that had the web part that was added to a wiki page. The page was then refreshed - and no crash - the web part just disappeared from the page. however, when you go to the maintnance page (add a "?contents=1" to the page url) you can see there is an "error web part" on the page. It still doesnt tell you what that web part used to be - which is something I expected Microsoft to improve from 2007.

Also, Maurice showed a bug that is with the current version and he is not sure if it is going to be fixed - when you delete an error web part, the div with the web part ID remains in the content of the wiki page - not visible, but it is making the page heavier, and messier.

To add a web part to wiki pages using code, you add the web part as usual (using the web part manager) and then you change the text for the wiki to include a div that links to the GUID of the web part.

SharePoint 2010 - No more reasons for WSS web parts

I am now in the session presented by Maurice Prather - a web part guru who used to be in Microsoft working on sharepoint in the past. He is now discussing my favorite topic- how to develop and deploy web parts in sharepoint 2010. News - WSS web part are phassed out. How is this different than 2007? they already said that in the past - the framework still gives the wss web part the same benefits - caching, better communication options and WSPC.

How is it possible to stop using the WSS web part class? the answer is that in asp.net web parts will now have more functionality available to them such as:

  1. Versioning of web parts in pages - if you make a change in a web part in a page - and then revert the page to old version of the page, the web part will be versioned with the page.
  2. Ajax
  3. Client object model
  4. Cross site scripting safeguards
  5. sandboxed solutions (I wrote about that yesterday)

So I don't see a solution for caching - you should implement the native ASP.NET cache.

WPSC will still exist for WSS web parts - so you can still do client side collections with it. But - now that you can do it with ajax, there is no reason why to use a WSS web part.

Monday, October 19, 2009

Training SharePoint 2010 Developers

And my friend Shay Petel is asking a serious question - when doing sharepoint training - do you start with sandboxed solutions so that you can use them during the course, or do you only get to them after teaching people how to develop web parts and other solutions using the standard WSP deployment mechanism? This is a big question that us trainers need to tackle. This whole developer training for sharepoint is going to blow out of proportion for us in the next year - from being a 5 day course for sharepoint 2007, I think we are going to need a 10 day course in 2010, and that may not be enough.
That said, I think that things like visual web part development significantly reduce the training time required - since asp.net developers will not have a problem with the learning curve any more...