SharePoint Automatic prefilling of lookup fields in insert forms using JQuery

By Geert van der Cruijsen at August 16, 2010 20:37
Filed Under: JQuery, SharePoint

At my last project I was working on a SharePoint online solution and one of the requirements is to prefill some values at one of the insert forms for a list. Since this is SharePoint online and the only tool you can use to customize is SharePoint Designer I had to do this with JavaScript.

I’ll explain how to build it by an example. for example you have a list of customers and a list of customer actions. What I wanted to build was a way to make it easier to add a customer action for a specific customer. To do this I added a custom column to the customer list containing a link to the edit form with the customer id as an url variable. Of course the out of the box you can’t create links or any other html with calculated fields so I added more javascript there.

to enable html as output of a calculated field just copy this piece of javascript and put it in a content editor webpart or paste it on your master page.

var theTDs = document.getElementsByTagName("TD"); 
var i=0; 
var TDContent = " "; 
while (i < theTDs.length)
{ 
  try
  { 
    TDContent = theTDs[i].innerText || theTDs[i].textContent; 
    if ((TDContent.indexOf("<DIV") == 0) && (TDContent.indexOf("</DIV>") >= 0))
    { 
      theTDs[i].innerHTML = TDContent; 
    } 
  } 
  catch(err){} 
  i=i+1; 
} 

Thanks Marijn Somers for this piece of code. original source: http://marijnsomers.blogspot.com/2010/01/write-html-code-in-sharepoint-via.html

so now my calculated field was a link in html. what did my calculated field look like?

="<DIV><a href='../../Lists/CustomerActions/NewForm.aspx?Customer="&[Customer ID]&"’>Add Customer Action</a></DIV>"

First a DIV element since the javascript above only replaces elements starting with a <DIV> to html, then just a plain html link to the NewForm.aspx sending the customer id as an url parameter.

 

So now the changes in the customer list are done and we only need to add some more javascript at the NewForm.aspx or again just at your masterpage to get the parameter from the url and selecting the right lookup field value at the form.

I’ve created the following code  using Jquery:

var customer = $.getUrlVar("Customer");
 
if(customer != "")
{
  $("input[title='Customer']").val(customer);
  
  $("select[title='Customer']").children("option").each(function() {
    if($(this).text() == customer)
    {
      $(this).attr('selected', 'selected'); 
    }
  });
}

My customer actions list contained a Customer field which is a lookup to the Customer list by Customer ID. The script above gets the Customer ID from the url parameters first and then tries to set the lookup item. SharePoint renders lookup items in 2 different ways. as a select box when there are less then +/- 25 items and as a auto complete textbox when there are more then 25 items in the lookup list. Because of that I firs try to set the textbox to the right value and after that the select. I’m using the title attribute to locate the right input field because it gets the same name as the field from SharePoint by itself.

Now when I open the newform.aspx?customer=1234 my customer lookup field is automatically prefilled with 1234

 

Geert van der Cruijsen

Using the SPContext in HttpModules in SharePoint

By Geert van der Cruijsen at May 23, 2010 17:20
Filed Under: Asp.net, SharePoint

When you are building custom HttpModules in SharePoint a common thing to do is to use the SPContext object to get acces to your SPSite, SPWeb, SPList or SPListItem. When doing this you have to be careful because the SPContext isn’t available everywhere because HttpModules can run early in the ASP.Net request pipeline so the SPContext object isn't available yet.

if you try to acces the SPContext to early in the pipeline you’ll get a System.InvalidOperationException error.

The earliest you can use the SPContext is in the “PreRequestHandlerExecute” so don’t use it at the BeginRequest event what most people try to use when they want to add code as early in the pipeline as possible

code:

   1: public class RequestHandlingHttpModule : IHttpModule, IRequiresSessionState
   2: {
   3:  
   4:     public void Dispose() {}
   5:  
   6:     public void Init(HttpApplication application)
   7:     {
   8:         application.BeginRequest += application_BeginRequest;
   9:         application.PreRequestHandlerExecute += new EventHandler(application_PreRequestHandlerExecute);
  10:     }
  11:  
  12:     void application_PreRequestHandlerExecute(object sender, EventArgs e)
  13:     {
  14:         string webUrl = SPContext.Current.Web.Url;
  15:     }
  16:  
  17:     void application_BeginRequest(object sender, EventArgs e)
  18:     {
  19:         // do not use SPContext here it will throw a System.InvalidOperationException 
  20:         // this event is fired before PreRequestHandlerExecute so code that doesn't uses SPContext goes here
  21:     }
  22:  
  23: }

Geert van der Cruijsen

Combined power of SharePoint and JQuery part 2: Changing the SharePoint webpart edit menu position

By Geert van der Cruijsen at May 20, 2010 22:55
Filed Under: Asp.net, SharePoint, JQuery

Have you ever had the problem using SharePoint 2007 that when you create small webpart zones that the edit button disappeared because the title of the webpart was to long? I ran into this problem at my current project and instead of shortening down the titles i came up with the idea of changing the position of the edit button to be on the left of the title. when the button is on the left and the title is on the right the title will be trimmed automatically since the webpart zones have a fixed length.

In your server side code it’s really hard to change these kinds of things because this is standard SharePoint functionality and you can’t change it server side. So the solution is to fix it using javascript and to make that easier I’m using JQuery.

first I’ll show you the results below and then how I did it using a small JQuery script.

before:

sharepointjquery1

after:

sharepointjquery2

Below is the JQuery script to change the position of the edit menu to the left. the only thing you have to do is save this code to a js file, include the reference to the js file and a reference to the JQuery library js file on your masterpage and you’re done.

   1: $(document).ready(function() {
   2:     SPEditMenuFix();
   3: });
   4:  
   5: function SPEditMenuFix() {
   6:     $(".ms-WPHeader").each(function() {
   7:         var first = $(this).children("td:first").clone(true);
   8:         var last = $(this).children("td:last").clone(true);
   9:         $(this).children("td:first").replaceWith(last);
  10:         $(this).children("td:last").replaceWith(first);
  11:     });
  12: }

Enjoy!

Geert van der Cruijsen

Updated my weblog to DotNetBlogengine 1.6.1

By Geert van der Cruijsen at May 19, 2010 23:12
Filed Under: General

Just before my vacation to Peru i noticed that i received a lot of spam in my comments on my blog. i was running DotNetBlogEngine 1.4.5 and the spamfilter seemed to be broken. I didn't have time to fix it before my vacation so i disabled comments for a while. now that I'm back I upgraded to 1.6.1 which has build in functionality for Askismet and Recaptcha.

because I had so many spam comments I had to remove all of them so sorry for everyone who posted real comments because they are also gone now.

BlogEngine.Net 1.6.1 (download from codeplex) feels like its a lot more mature then the 1.4.5 version I had before. Lets see how well it will go in the future.

Because of the switch I had to change the theme because the old one didn't work that well with this new version so i downloaded a new theme from http://www.blogenginetheme.com/ and changed a bit to my liking. When i have time i'll change it a bit more.

If you are still using an old version of BlogEngine.Net I would advise you to upgrade to 1.6.1 because it's looking pretty good and upgrading was easy. (costed me 2 hours including deleting of spam Smile )

Enjoy my new weblog

Geert van der Cruijsen

Going to DevDays 2010

By Geert van der Cruijsen at February 25, 2010 02:32
Filed Under: General

Wow first 7 months of no blogging then 2 in 1 week ;)

I’ve been looking through al the sessions on the first day of the DevDays 2010 at the world-forum The Hague, The Netherlands and I’ve picked the ones I’m going to.

devdays-logo 

First off starting with the Keynote of course by Anders Hejlsberg and the keynotes title is: “Trends and Future Directions in Programming Languages”.

After the keynote at 11:05 I’m going to see the session by Scott Hanselman called “ASP.NET MVC 2: Basics, Introduction”. Hopefully there are some new things for me to see although I know quite a bit about the MVC framework already :) If not… Scott is always a cool guy to listen to so i see no problems.

At 13:30 I’ll be going to the session by Alex Thissen called “Secure Coding”. It never hurts to know something about security :)

The next session at 15:05 is by Anders Hejlsberg again. The session is called “C# 4.0 and beyond”. I would really like to know what is beyond.

The last session of the DevDays at 16:40 I’m going to see is by Scott Hanselman. It’s called “ASP.NET MVC 2: Ninja Black Belt Tips”. Since I’m already a ASP.NET MVC ninja i would like to learn from the master how to get my black belt.

In the evening there are a couple of sessions at the “Geeknight”. The Geeknight sessions are sessions for the real geeks and are about programming for fun, home automation, etc.

Sessions at the Geeknight I’m going to are:

Ofcourse starting with the geeknight keynote by Tony Krijnen and Daniel van Soest at 18:30.

after the keynote “I’m going to learn how to make my blog suck less” by Scott Hanselman (wow 3 sessions on 1 day :) )

the last session at 21:00 is the hardest choice. i have to choose between “If the ‘Free Lunch’ is Over, Can we Still Afford to Eat? How to Power Boost your Applications “ or “Microcontrollers for .Net programmers” or “Using .NET to Program your Hobby Web-services”. I really don’t know what to expect from the first session, my interests aren’t with microcontrollers and the last session is about webservices which i do like but it’s a level 100 session and I think there isn’t going to be that much new stuff to be heard there.

so for now my choice is with “If the ‘Free Lunch’ is Over, Can we Still Afford to Eat? How to Power Boost your Applications “ by Rutger van Beusekom.

I really can’t wait for DevDays 2010 to start.

Maybe I'll see you there!

Geert van der Cruijsen

Combined power of SharePoint and JQuery part1: Changing the SharePoint Image Picker

By Geert van der Cruijsen at February 23, 2010 11:12
Filed Under: JQuery, SharePoint

Wow… long time since i blogged. Thank god I'm going to the Dutch DevDays to see Scott Hanselman’s session called “How to make your blog suck less” :)

So here is an update of mine about how to use JQuery in SharePoint to do some fancy tricks. I’ll post some more of these tricks later on and I’ll try to be more active as a blogger again. (In which I’ll probably fail)

Have you ever tried to change some of SharePoint's default controls like the image picker?

Well I have. My customer wanted a image picker that worked exactly like the normal one except for 1 change. It shouldn’t show the selected image as an image but it should only show the URL of the selected image. I tried to change this at server side first by inheriting from the default SharePoint image picker control. This was a rather annoying job as i didn’t seem to get the right result this way. you cannot extend the rich image picker from sharepoint but only the default image picker that doesn’t have the image library function behind it.

When i was looking at the html that was rendered by SharePoint i thought it would be easier to change the html with jquery as with serverside code and this is the result. just save this source to a .js file and include it into your masterpage or aspx page and all selected images in the image picker will be changed to only show the url of the image.

///<reference path="jquery-1.3.2.min-vsdoc.js" />
 
$(document).ready(function() {
    HideImages();
});
 
function HideImages() {
    $("span[id $= '_RichImageField_ImageFieldDisplay']").each(function() {
        var url = $(this).find("img").attr("src");
        $(this).find("a").hide();
        $(this).append("<span class='imgurl'>" + url + "</span>");
        $(this).find("a").each(function() {
            $(this).find("img").each(function() {
                $(this).load(function() {
                    $(this).parent().hide();
                    var imgurl = $(this).attr("src");
                    $(this).parent().parent().find(".imgurl").text(imgurl);
                });
            });
        });
    });
}

It’s as easy as that.

More JQuery fun to post in the future.

Geert van der Cruijsen

Creating an MVC based website with reusable widgets

By Geert van der Cruijsen at July 12, 2009 10:46
Filed Under: Asp.net, Geert's Projects, MVC

After the Asp.net MVC Framework was released i was pretty impressed of how it worked but one of my main problems was how to handle the data on the page that is not the main goal of the specific page.

In ASP.NET MVC every page has its specific controller and views that can handle the data for the page that is requested. for example when you’re building a web shop you’ll probably have a ProductController that handles everything that has to do with the Products in your shop. But when you are browsing a web shop product page you would also like to see other data that has nothing to do with products, for example your shopping basket, current login state etc. Should you add this logic to the ProductController? imo you shouldn’t since the Products controller only responsibility should be the products. So how should we handle this in the MVC framework?

My first idea that came to mind to solve this problem was doing an Ajax request to for example, the shopping basket controller on your view when you would like a shopping basket added to your page. This can be in some situations the best way to do it but in some cases you might not want to use Ajax since then this content can’t be indexed by search engines for example.

An example how to use Ajax widgets is found here: http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=310

My main goal was to be able to add widgets to a page without the controller of that page knowing about these widgets. I found some solutions to this called partial requests found here: http://blog.codeville.net/2008/10/14/partial-requests-in-aspnet-mvc/

These partial requests weren’t my favorites also since i didn’t want to put this logic in the view so i developed my own CMS like solution for this problem.

My idea was that a page can have several page zones and page zones contain widgets. widgets and complete page zones should be reusable by other pages so i stored these in my CMS database. how my database is build up you can see in the image below

image

A widget should be able to render itself so i made an abstract BaseWidget class that has a Render Method. A widget can also be a call to a different controller so i made a SubController class that inherits from BaseWidget. The SubController Widget has an Controller, Action and ID so it can call the controller it belongs to.

   1: public abstract class SubControllerWidget : BaseWidget
   2: {
   3:     public string Controller { get;  set; }
   4:     public string Action { get;  set; }
   5:     public object ID { get; set; }
   6:  
   7:     public SubControllerWidget(string Controller, string Action) : base()
   8:     {
   9:         this.Controller = Controller;
  10:         this.Action = Action;
  11:         this.ID = null;
  12:     }
  13:  
  14:     public SubControllerWidget(string Controller, string Action, object ID)
  15:         : base()
  16:     {
  17:         this.Controller = Controller;
  18:         this.Action = Action;
  19:         this.ID = ID;
  20:     }
  21:  
  22:     public override void Render(System.Web.Mvc.ViewContext vc)
  23:     {
  24:         vc.RouteData.Values["controller"] = Controller;
  25:         vc.RouteData.Values["action"] = Action;
  26:         vc.RouteData.Values["id"] = ID;
  27:         IHttpHandler handler = new MvcHandler(vc.RequestContext);
  28:         handler.ProcessRequest(System.Web.HttpContext.Current);
  29:     }
  30:  
  31:     public abstract void SetSettings(WidgetSettings settings);
  32: }

To build a specific widget just inherit a widget from SubControllerWidget and you are ready to go. Set the Controller, Action and ID to call and that specific controller will be called.

To add these page zones and widgets to the pages dynamically i’ve created a CMSController that overrides the OnActionExecuted method so it can insert the page zones and widgets to the model that’s been send to the View.

   1: protected override void OnActionExecuted(ActionExecutedContext filterContext)
   2: {
   3:     if (ViewData.Model == null)
   4:     {
   5:         ViewData.Model = new CMSViewModel();
   6:     }
   7:     string controller = filterContext.RequestContext.RouteData.Values["controller"] != null ? filterContext.RequestContext.RouteData.Values["controller"].ToString() : "";
   8:     string controllerAction = filterContext.RequestContext.RouteData.Values["action"] != null ? filterContext.RequestContext.RouteData.Values["action"].ToString() : "";
   9:     string controllerActionid = filterContext.RequestContext.RouteData.Values["id"] != null ? filterContext.RequestContext.RouteData.Values["id"].ToString() : "";
  10:     IList<PageZone> zones = _cmsRep.GetPageZonesForPage(controller, controllerAction, controllerActionid);
  11:  
  12:     CMSViewModel page = (CMSViewModel)ViewData.Model;
  13:     if (page.PageZones == null)
  14:     {
  15:         page.PageZones = zones;
  16:     }
  17:     else
  18:     {
  19:         foreach (PageZone zone in zones)
  20:         {
  21:             page.PageZones.Add(zone);
  22:         }
  23:     }
  24:  
  25:  
  26:     base.OnActionExecuted(filterContext);
  27: }

 

So now all widgets beloning to a page will be retrieved from the CMSRepository and are added to the CMSViewModel so now it’s the View’s turn to render all widgets.

In my master page I’ve added the following line that is responsible for rendering all widgets:

<% Html.RenderPageZones(Model); %>

For that to work I’ve created a few html extension methods to render the page zones.

   1: public static class HtmlCMSExtensions
   2: {
   3:     public static void RenderPageZones(this HtmlHelper html, CMSViewModel page)
   4:     {
   5:         if (page != null && page.PageZones != null)
   6:         {
   7:             foreach (PageZone zone in page.PageZones)
   8:             {
   9:                 html.RenderPartial("PageZone", zone);
  10:             }
  11:         }
  12:     }
  13:  
  14:     public static void RenderWidgetsInZone(this HtmlHelper html, PageZone zone)
  15:     {
  16:         if (zone != null && zone.Widgets != null)
  17:         {
  18:             foreach (IWidget widget in zone.Widgets)
  19:             {
  20:                 widget.Render(html.ViewContext);
  21:             }
  22:         }
  23:     }
  24: }

In my PageZone view i’ve added the other html extension method called RenderWidgetsInZone so all widgets are rendered by itself.

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<VanDerCruijsen.MVC.CMS.Model.PageZone>" %>
<div id="<%= Html.Encode(Model.Name) %>">
name:<%
   1: = Html.Encode(Model.Name) 
%>
<%
   1:  Html.RenderWidgetsInZone(Model); 
%>
</div>

This is the way I use to create widgets on my ASP.NET MVC pages. If you have any recommendations or better ways how to do it please let me know.

When I have the time I’m going to build an admin controller to be able to add widgets and pagezones via the webinterface since now the only option is to add them in the database by hand.

My sources aren’t really cleaned up so if you want a working source/solution please send me mail or leave a comment.

Geert van der Cruijsen

My article about the ASP.NET MVC Framework published in the Dutch .Net Magazine

By Geert van der Cruijsen at June 05, 2009 13:47
Filed Under: Asp.net, MVC, dotnetmag

Hello everyone,

It’s been a while since my last post (again :( ) but I've been quite busy testing out the new ASP.NET MVC Framework. I have to say i really like it. Currently I'm building my own little CMS framework on top of the MVC framework so it becomes easier to use widgets or other non main data items on your pages. As soon as it’s in a show able form I'll  post it on my blog.

I’ve also written an article about the ASP.NET MVC framework for the Dutch .Net Magazine (in Dutch) so if you are a reader of the magazine check out page 22 of the June 2009 release (#25) :)

The Title of my article is: “Volledige controle over je webapplicatie met het ASP.NET MVC Framework” (“Total control over your web app using the ASP.NET MVC Framework”)

The article will also come online sometime but the official site (also used to sign up for the free magazine) www.dotnetmag.nl is still showing #23 as the newest one.

When the pdf is put online I’ll add the link to this post.

I’ve focused on writing about how to build an ASP.NET MVC application using TDD because I think this is one of the major advantages over the “old” way of building web applications in ASP.NET.

If you have any feedback or comments about the article please let me know!

Geert van der Cruijsen

ASP.NET MVC framework 1.0 released

By Geert van der Cruijsen at March 18, 2009 15:23
Filed Under: Asp.net
After the announcement of silverlight 3.0 i was chatting with a colleague about how cool it would be if asp.net MVC framework would also be released at mix.

My colleague started searching and came up with this link:

http://www.microsoft.com/downloads/details.aspx?FamilyID=53289097-73ce-43bf-b6a6-35e00103cb4b&displaylang=en

Pretty cool huh? I haven’t seen any official press releases from Microsoft but since you can download it it seems that it has been released! 

My guess is that it will be announced on MIX today or tomorrow but I couldn’t wait to share it with you already J 

Geert van der Cruijsen  

MIX 09 Keynote: Introducing Silverlight 3.0 (Beta available NOW!!!)

By Geert van der Cruijsen at March 18, 2009 14:03
Filed Under: Silverlight

When I came home about an hour ago I turned on my mediacenter pc to listen to some mp3's when I thought.. Hey wasn't MIX 09 starting today? Maybe I can check out some video's already like I could with the pdc.

When I browsed to http://live.visitmix.com/ the Keynote was played LIVE in silverlight :) Scott Guthrie was already talking about StackOverflow.com and after that he started talking about Silverlight 3.0

Silverlight 3.0 is going to bring us some pretty cool stuff like Hardware 3d acceleration and multitouch support. These functions ofcourse are pretty cool but are they really usefull? one of the most important things Scott also announced was SEO optimization for Silverlight 3.0.

In Silverlight 3.0 you will be able to store points in your applications from where you can browse from and to by using your forward / back buttons but you're also able to create a bookmark and ofcourse the most important part is that it can be indexed by search websites so they can link to specific locations in the silverlight 3.0 app.

Another cool thing in Silverlight 3.0 is that if you build an application using some external libraries that the libraries can and will be downloaded only when they are used. and when you use the same library in a different silverlight app it will use your already downloaded version instead of pulling it from the server again saving bandwidth.

Sketchflow is a new feature build in Blend 3.0 which will enable you to create sketches of your design rapidly by dragging and dropping wiggely controls (pencil drawn looking controls) on a screen. You can also create a flow of the application fluently by creating several screens and connecting them together. After this you can add functionality to some navigation buttons (without writing code) to navigate from 1 screen to another. After this you can change your sketches to real working code and you’re done!

Multi Tier Data is another new feature which is working like a proxy representation of your data on the server inside your silverlight app. You can databind your controls to the proxy data and if you update the data it will automatically be synced with the server. It’s also possible for the server to push changes in the data to the client so you don’t have to poll the server anymore.

Scott rounded up his presentation telling that the current silverlight 3.0 package is smaller than the current silverlight 2.0 package and the beta 1 is released today! You can download it at:
http://silverlight.net/getstarted/silverlight3/default.aspx

Scott didn’t say anything about a final release date but he did mention later this year (so probably q4)

I really like the changes and can’t wait to start playing with SL 3.0

Geert van der Cruijsen

 

Silverlight Design Pattern: the Model View ViewModel (MVVM)

By Geert van der Cruijsen at March 09, 2009 17:20
Filed Under: Silverlight

Hi There,

The Customer where I'm currently working at asked me if i could build him a Silverlight 2 app. I've been playing around with Silverilght quite a bit but i haven't really used any design patterns so i came to the idea to search the web if there are any specific Silverlight design patterns.

The only really big pattern i found was the MVVM Model View Viewmodel pattern. This isn't a completly new design pattern (Martin fowler calls it the Presentation Model Pattern)

If you know the MVC pattern which you probably do know this is somewhat alike. The model is your layer which connects to the data and the view is ofcourse xaml based in silverlight. So what does the ViewModel do? The viemodel is used to build specific models for each view in your silverlight app so you can have full advantage of the strong databinding in Silverlight.

There are quite some resources about this pattern which i'll link down here:

I'll be using this pattern at my current assignment and afterwards i'll blog about the results :)

Geert van der Cruijsen

Set file level permissions in SharePoint using Workflow Foundation

By Geert van der Cruijsen at February 18, 2009 15:23
Filed Under: SharePoint

Hello Everyone, 

On my current project we are building a customer facing SharePoint application which has to store files. These files are uploaded with biztalk so we have to set the permissions manually so only the user who the file belongs to has rights to open te file.

We are storing the username of the owner of the file in the metadata of the sharepoint item and we are going to use this to set the permissions after the file is uploaded to sharepoint by Biztalk.

After adding the file we've set up a SharePoint Workflow to move the files to a specific location and we've come up with the idea to also change the permissions in this workflow. How we did this? here's the code to change the permissions of a SharePoint SPItem in the workflow:

   1:  workflowProperties.Item.BreakRoleInheritance(false);
   2:   
   3:  workflowProperties.Item.File.MoveTo(currentFolder + "/" + workflowProperties.Item.File.Name);
   4:   
   5:  SPRoleDefinitionCollection rolecollection = web.RoleDefinitions;
   6:  SPRoleAssignmentCollection roleAssignments = workflowProperties.Item.RoleAssignments;
   7:   
   8:  SPUser user = web.EnsureUser("aspnetsqlmembershipprovider:"+workflowProperties.Item.Properties["Username"].ToString());
   9:  SPRoleAssignment roleAssignment = new SPRoleAssignment(user as SPPrincipal);
  10:  SPRoleDefinitionBindingCollection roleDefBindings = roleAssignment.RoleDefinitionBindings;
  11:  roleDefBindings.Add(rolecollection.GetByType(SPRoleType.Reader));
  12:  roleAssignments.Add(roleAssignment);

 

We are using an aspnetsqlmembershipprovider to store the external users so thats why we add this to the sharepoint username.

Geert van der Cruijsen

Moved to new Hosting: Digitalibiz.com

By Geert van der Cruijsen at February 18, 2009 14:11
Filed Under: General

Hi All,

Long time since i've written my last post... well here's my excuse: Ofcourse december is filled with the holidays etc but i also went on vacation back to Thailand again in January for 3 weeks. I had a great time there but nothing techie to write about around there :)

After i came back i wanted to switch hosting providers because my old one (www.sohosted.com) didn't support mssql and for some things I'm working on i want to do with mssql and Linq. I've been experimenting with the asp.net mvc framework again and i have to say i really like it. (I hope i have time to write more on that subject soon on this blog)

My new hosting provider is Digitalibiz (www.digitalibiz.com) and the main reason i went to them is because 1 they are cheap and 2 they have mssql support and 3 they allow multiple domains on 1 account.

When you are reading this message the dns is finally changed to my new hosting so i can get rid of the old one. Tnx people at Sohosted for the good hosting i had there for multiple years but it was time to move on. I hope Digitalibiz will be as good as they were.

Geert van der Cruijsen

Silverlight 2 and Flash 10 put to the test

By Geert van der Cruijsen at November 02, 2008 13:03
Filed Under: Silverlight

Today a colleague of mine send me a link of a very cool site: http://www.shinedraw.com/

The guy who build the site is a webdeveloper with 6 years experience in building flash apps and 1 year of Silverlight experience. On his blog are a lot of apps build both in Flash and Silverlight. Some examples are: loading a big external image into the silverlight / flash app and a fps stress test.

http://www.shinedraw.com/data-handling/flash-vs-silverlight-loading-external-image/

http://www.shinedraw.com/mathematics/flash-vs-silverlight-fps-meter-stress-test/

It's very cool to see that the output of both platforms is almost equal, though in most test Silverlight is performing a bit better then Flash 10.

Also if you look at the code that is used in both examples you have to say that programming in Silverlight is a more pleasant experience.

Both platforms have strengths and weaknesses. Microsoft has visual studio which is far out the best IDE out there. Adobe on the other had has the best tools for designers.

The battle for best rich internet platform rages on!

 

Geert van der Cruijsen

Silverlight 2 Control Toolkit ready for download

By Geert van der Cruijsen at October 29, 2008 21:02
Filed Under: Silverlight

Yesterday Microsoft released the first version of the Silverlight Extended controls suite on Codeplex.

This control suite contains a number of special controls that are now available for the public to download and use in their own projects.

an example of what kind of controls are included in the toolkit:

  • TreeView
  • Charts
  • Expander
  • AutoComplete
  • NumericUpDown

On the codeplex site there are online demos of all controls which are included in the toolkit and the controls are also documented in the wiki on the page.

 Example of how the Treeview looks and how you use it:

 

Example of the AutoCompleteBox and how to use it in your xaml code: 

 

You can check out the online demos at codeplex: Controls demo and the Charting Demo

I really think Microsoft did a great job at offering these controls to the community and it will make developing in silverlight easier for everyone.

I liked the Charting part the most and i really look forward in using that in my projects in the future. Just look at how nice these controls look and how easy you can fit them into your project:

Geert van der Cruijsen

Silverlight 2 Release Candidate Available

By Geert van der Cruijsen at September 27, 2008 11:41
Filed Under: Silverlight

Last night Microsoft released the first release candidate for Silverlight 2.0.

 

There are a few new controls added in this release: the Combobox, passwordbox and the progressbar.

you can download the new silverlight release candidate at: http://silverlight.net/GetStarted/sl2rc0.aspx

on Scott Guthries weblog there is a nice explanation on how these new controls work.

New Silverlight controls

the new silverlight Controls (Combobox, passwordbox and the progressbar)

 

note that only the developer tools and runtime are released and not regular silverlight runtime. This is done so developers have time to upgrade their applications before silverlight 2.0 RC1 is actually released to the public.

Happy coding!

Geert van der Cruijsen

Add documents from a Base64Binary xml element to SharePoint with Biztalk 2006

By Geert van der Cruijsen at August 07, 2008 22:03
Filed Under: Biztalk 2006, SharePoint

On my current project we wanted to add documents which come in as attachment through a webservice to a sharepoint document library to store them.

We used Biztalk 2006 to receive the file, get the different files from the xml and then send them to SharePoint. In this blogpost I’ll explain how to do this with a small POC I made.

First off we started with a receive port which is able to receive the xml message (the binary port on the picture) we receive this message into a BinaryMessage message which is linked to the following schema

An example message is looking like this: (where the <document> should have the attachments as a base64binary string.

After receiving the message we want to loop through all the messages in the document so I created a foreach to read all the document elements from the xml.

The code to build the loop is the following:

InitializeLoop :

iteration = 1;

documentCount = xpath(BinaryFile,"count(/*[local-name()='BinaryFileToSharePointTest' and namespace-uri()='']/*[local-name()='Document' and namespace-uri()=''])");

first I set the iteration variable to 1 and I set the documentCount to the amount of document elements that are in the incoming xml file.

Message assignment

BinaryFileWithMetadata = BinaryFile;

binaryMessageCreator = new BinaryToSharePoint.Helper.BinaryMessageCreator();

selectXpath = "string(/*[local-name()='BinaryFileToSharePointTest' and namespace-uri()='']/*[local-name()='Document' and namespace-uri()='']["+ System.Convert.ToString(iteration)+"]/text())";

base64String = xpath(BinaryFile,selectXpath);

binaryMessageCreator.CreateBinaryMessage(BinaryFileWithMetadata,base64String);

configProperties = new VdCruijsenNet.Utilities.Sharepoint.ConfigPropertiesXML();

configProperties.AddProperty("Title","test");

BinaryFileWithMetadata(WSS.ConfigPropertiesXml) = configProperties.ToString();

BinaryFileWithMetadata(WSS.Filename) = "bestandsnaamTest "+System.Convert.ToString(iteration)+".pdf";

In the message assignment we first Create the new outgoing message for each of the documents in the incoming xml file. Then we select the base64binary string with an xpath expression and send it to the binaryMessageCreator.

The binaryMessageCreator creates a new System.Xml.Document (which isn’t a xml file but biztalk doesn’t know that :) from the base64binary string. For the source of the BinaryStreamFactory see below:

After creating the new Message of the type System.Xml.Document, which is actually a byte[] containing the file we add a filename and some metadata which can be stored in SharePoint we send the message with the send shape to sharepoint.

The SendPort is a “Windows SharePoint service” sendport which can automatically add the file to a sharepoint document library.

 

Sendport

Receiveport

As you can see it’s pretty easy to get the binary files from an xml file in Biztalk after you know how you can do it.

Happy Coding

Geert van der Cruijsen

Upgraded my weblog to Blogengine.net 1.4.5

By Geert van der Cruijsen at August 06, 2008 23:00
Filed Under: General

4 days ago Blogengine.net 1.4.5 was released. A good time for me to upgrade to the newest version since i wanted to split my weblog up to a part to store my messages about my private life and my posts about software development.

Upgrading to 1.4.5 was pretty easy except 1 error i ran into. I'm using blogengine.net together with mysql since my provider doesn't have mssql and I didn't really like the xml based blogging. After setting everything up i kept on running into System.Threading.SemaphoreFullExceptions. After posting this on the Blogengine.net codeplex site some people mentioned this was a bug in the mysql.data.dll version 5.1.6 and if you upgrade to 5.2.2 everything should work fine again. So i did and you can see the results now.

I've also upgraded the layout of my weblog and added a http://life.vdcruijsen.net section to store my weblog about my life when I'm not developing software but am going out on vacation, trips or have something else to blog about.

Tnx to the Blogengine.net team for this great piece of software!

Geert van der Cruijsen

 

Comparison of Microsoft Silverlight 2 and Adobe Flex by an Adobe Evangelist

By Geert van der Cruijsen at July 26, 2008 00:07
Filed Under: Silverlight

I've found a nice read on a comparison between Microsoft's Silverlight and Adobe Flex by an Adobe Evangelist who took a 3 day Silverlight 2 training.

The weblog post starts of with summarizing the good and bad things of Silverlight but it's also nice to read the comments where a big discussion starts between Microsoft employees, Adobe employees and other developers/designers that have to choose between these 2 technologies.

Things he likes about Silverlight:

  • “The first thing I really like is the concept of threading. Being able to spawn off complex tasks without choking the main thread is pretty cool. You could, for example, show a really smooth animation when you are loading a bunch of data in a separate thread.”
  • “A Silverlight application can directly communicate with the HTML document it is hosted on by simply setting a parameter.”
  • “Being able to code in either C# or VB.NET is also a great feature. Especially since these two languages are pretty familiar to people developing for the Windows platform. I’m not one of them, but I found that C# is similar to ActionScript. Next to those languages you also have XAML, which does more or less the same things as MXML.”
  •  

    after that he tells us the things he doesn't like about Silverlight:

  • Code in XAML and C# is really verbose.”
  • “Styling controls is an absolute nightmare! I honestly think that this is going to be Silverlight’s Achilles’ heel!”
  • “Another thing that I really couldn’t grasp is the lack of HTML tag support in text fields.”
  • “I know the Expression tools are still in beta, but it has to be said that all the tools (including Visual Studio, which is no longer in beta) felt extremely buggy and incomplete.”
  • “Over these three days, I got a strong feeling that Silverlight was created by people who don’t know anything about designers.”
  •  

    In my opinion Silverlight and Adobe Air/Flex can both be big and good in their own things and eventually they will start growing towards each other as .Net and Java are also doing. Adobe has its huge designers userbase while Microsoft has a very big developers userbase. I think Adobe will stay the best thing to use for really nice fancy looking webtools while Silverlight will focus itself on the real rich internet Applications instead of websites which will stay the big focus of Adobe.

    I do agree with him that styling can be pretty hard for designers which aren't used to set all those properties and maybe Silverlight is a bit TOO extensible for them. As an example he shows how to change the rotation of an object in Silverlight and Flex:

    Microsoft Silverlight Adobe Flex

    <Button>
    <Button.RenderTransform>
    <RotateTransform Angle="45"/>
    </Button.RenderTransform>
    </Button>

    <Button rotation="45"/>

    I can see a designer will like the simple rotation property but Microsoft gives us (developers) the option to do all kinds of transformation on the object which is more extensible then the way it's done in Flex.

    About the point where he is complaining about how buggy everything is, I think this changed in a good way from Silverlight 2 Beta 1 to Beta 2 and I'm sure that everything will be really stable at the final release. (of course Visual studio isn't in beta... but the Silverlight developer tools are so that's why Visual studio isn't always that stable while building Silverlight applications at the moment)

    I do think Microsoft will have a hard time to get designers to change to Silverlight from their loved environment which they already know but only time will tell.

    http://www.webkitchen.be/2008/07/17/silverlight-the-good-the-bad-and-the-ugly/

    Geert van der Cruijsen

    Last.Fm Radio Stream Player Gadget 0.5 Released!

    By Geert van der Cruijsen at July 25, 2008 22:36
    Filed Under: Cool Stuff, Geert's Projects

    Update 08-06-2010: the last.fm gadget does not work anymore. Last.fm changed their client server protocols and therefore the gadget is not working anymore. I'm not using Last.fm anymore so i'm not planning on updating the gadget in the future

     

     

    Last week my mailbox was flooded by mails of people who were telling me my Windows Vista Sidebar gadget to play Last.fm radio was broken.

    I tested it myself and concluded that this was indeed the case. Last.fm changed their website last week and my guess is that they also changed their streaming service.

    After a full night of debugging I found out what was the problem and I fixed it in a new version which can be now downloaded from the download area.

    If you are interested in what was changed read on. The change was fairly simple, the protocol uses 2 handshakes to connect to the service. The first handshake is to connect to the scrobbling service. The second handshake is used to connect to the streaming service. Before last week requesting the mp3 stream was done by sending the sessionid of the first handshake. Now... it seems you have to send the sessionid you get with the second handshake. It took some time to figure this out but now everything seems to work fine again.

    Protocol example:

    Handshake 1 request:

    http://ws.audioscrobbler.com/radio/handshake.php?version=1.4.2.58376&platform=win32&platformversion=Windows%20Vista&username=geertvdcruijsen&passwordmd5=
    4d9309866b98863c3c3336e50392831b&language=en&player=winamp

    Handshake 1 response from last.fm:

    session=bbe5e763d1e1deb988595cecf1c21e9d stream_url=http://87.117.229.85:80/last.mp3?Session=bbe5e763d1e1deb988595cecf1c21e9d subscriber=0 framehack=0base_url=ws.audioscrobbler.com base_path=/radio info_message= fingerprint_upload_url=http://ws.audioscrobbler.com/fingerprint/upload.php permit_bootstrap=0

    Handshake 2 request:

    http://post.audioscrobbler.com/?hs=true&p=1.2&c=tst&v=1.3.1.1&u=geertvdcruijsen
    &t=1217017120&a=2a060e72c7aae132e8fad06b741be806

    Handshake 2 response from last.fm:

    OK 7e5b82460d2a45e382b81c437ae6a87a http://post.audioscrobbler.com:80/np_1.2 http://87.117.229.205:80/protocol_1.2

    Tune to the right radio channel:

    http://ws.audioscrobbler.com/radio/adjust.php?session=bbe5e763d1e1deb988595cecf1c21e9d&url=lastfm://artist/muse

    Response to channel change request from last.fm:

    response=OK url=lastfm://artist/muse stationname= Muse’s Similar Artists discovery=true

    Request metadata of stream:

    http://ws.audioscrobbler.com/radio/xspf.php?sk=bbe5e763d1e1deb988595cecf1c21e9d
    &discovery=0&desktop=1.3.1.1&time=1217017120321

    I was happy to receive the mails of complaints because this is proof people are actually using my gadget :) Hopefully all problems are fixed now so happy listening!

    Geert van der Cruijsen

    MOSS workflow wont start because 'The requested workflow task content type was not found on the SPWeb'

    By Geert van der Cruijsen at July 02, 2008 22:02
    Filed Under: SharePoint

    The last 2 days my MOSS environment was driving me crazy because an already existing workflow didn't want to start in a new document library in a new subsite. I made this workflow in Visual Studio 2005 and deployed it as a feature to my SharePoint Site. I connected the workflow to a content type and told it to run on new items of this type or whenever an item changes. This workflow worked fine for 2 months in this particular document library.

    After 2 months my client asked for a new subsite with a new document library where this workflow should also run. I installed this workflow here and expected everything would go as planned. When I tried to test the workflow I didn't see anything happen so I tried creating new items, changing them, even manually starting the workflow. Nothing happened. The metadata field which contains the workflow status was staying empty. When checking the log files I didn't see anything either.

    I tried to reinstall the workflow. Deleted and recreated the site nothing seemed to help. During all this the workflow still worked fine in the other subsite and document library. When I recreated the workflow and checked the logfile again I finally found an error. (it seems Sharepoint only logs this error the first time you start the workflow and after that it doesn't do anything)

    The error message in the logfile was the following:

    Workflow Infrastructure        72fv Unexpected AutoStart Workflow: System.ArgumentException: De aangevraagde werkstroomtaakinhoudstype is niet gevonden op SPWeb.     at Microsoft.SharePoint.SPList.PrepForWorkflowTemplate(SPWorkflowTemplate wt)     at Microsoft.SharePoint.Workflow.SPWorkflowManager.StartWorkflowElev(SPListItem item, SPFile file, SPWorkflowAssociation association, SPWorkflowEvent startEvent, Boolean bAutoStart, Boolean bCreateOnly)     at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange, AssocType atyp)

    this Dutch error (I really hate Dutch errors. you can't look them up on Google/MSDN:( )translated in English is 'The requested workflow task content type was not found on the SPWeb'. I found the exact translation because I was lucky and when I had the English error this gave me new hope to find a weblog with the answer (since weblogs seem the primary documentation for SharePoint 2007 ;) )

    I searched for the error and everything I could find was reinstalling the OffWFCommon feature. I tried this with the following commands but nothing changed. I also tried to uninstall and reinstall but this didn't help either

    stsadm -o installfeature -filename OffWFCommon\feature.xml
    stsadm -o activatefeature -filename OffWFCommon\feature.xml -url http://localhost/

    This weblog told me the exact thing that was going on. the TaskListContentType wasn't installed on my tasks documentlibrary when I checked it by enabling content types chaning in the advanced settings of the tasks list. The ID of this content type is 0x01080100C9C9515DE4E24001905074F980F93160 which is the same as the OffWFCommon feature so it definitely had something to do with it. When I checked the content types of my task doclib that was working I noticed it had 2 content types attached. 1 called "Task" and 1 called "Workflow task content type" my Tasks library that wasn't working had a content type called "Tasks". I couldn't find any way how to add these content types because these are system content types and thus hidden.

    Solution/Workaround:

    Since I already wasted 1 and a half day on this problem my next try was to save the Tasks documentlibrary of the workflow that was working as a template. After that I deleted the workflow in the new document library and also deleted the Tasks list there. I added a new Tasks list by using the template I made and installed the workflow again for this documentlibrary. I tested it and guess what.. everything seemed to work fine. The solution isn't that pretty but I was glad it finally worked!

    Hopefully someone with the same problem reads this before they waste to much time on this really awful problem. Also if you know  a better solution please let me know because I would really like to know how to really solve this problem.

    Geert van der Cruijsen

    DevDays 2008 Amsterdam

    By Geert van der Cruijsen at May 22, 2008 21:22
    Filed Under: General

    I just came home from Amsterdam after a long day of listening to presentations on the DevDays 2008 in Amsterdam. It was a long day since I live "below the rivers" as people in Holland like to call it and its a pretty long drive to Amsterdam so I had to get up early.

     

    I stepped into my car at 6:00 in the morning to be in Amsterdam at 9:00. In the Netherlands traffic is such a joke that it isn't possible for me to be in Amsterdam at 9:00 because when i leave at 6:00 i'm there at 8:00 and when i go a bit later i'm already late for the first session because of all the traffic jams. So around 8 o'clock I entered the Rai and helped a bit at the Avanade stand to help kill the time before the first session.

    At 9:00 the keynote started and David Platt told us Why software sucks. To wrap his story up he told us that developers write software that doesn't function well because it doesn't do it's job like it is supposed to. We build to many "cool" features that nobody uses etc. His principle of software development is: KNOW THY USER FOR HE IS NOT THEE. All in all it was a interesting presentation about something everybody already knows or should know but still a lots of developers keep doing a bad job at it. If you want to know more about this subject check out David's website or read his book called "Why Software Sucks"

    The Second session I visited was an "Introduction to Silverlight 2" by Daniel Moth. He gave us a good overview of what silverlight 2 is going to do at release and what it can already do know. Since I already played around with the silverlight 2 beta I already knew some stuff he told and showed us in the demo's but it was nice to see all aspects of what silverlight 2 is capable off. The demo's he showed us were a Hello World example, a XAML introduction, The bridge between html/javascript and Silverlight 2, Networking capabilities in Silverlight and at the end he showed us how to acces the local file system. On Daniel's blog is a nice summary of his presentation at DevDays so if you are interested in what Silverlight 2 can do check it out at http://www.danielmoth.com/Blog/2008/05/my-silverlight-session.html

    After enjoying a nice lunch in the sun I visited a presentation about "Building Rich Internet Applications for WSS 3.0 and MOSS 2007". This presentation was done by Patrick Tisseghem. Patrick is a SharePoint MVP and showed us to possibilities of using Silverlight in SharePoint. Before I went to the presentation I thought that this could be very useful because in my daily work I have to code against/in SharePoint quite a bit. The Silverlight support Patrick showed us didn't came as anything new to me since Daniel Moth already showed us in his presentation that in Silverlight 2.0 you can acces webservices via the client side code. Patrick showed us how to use the standard webservices that SharePoint exposes and explained to us that we can build our own services to communicate with SharePoint. Since on my projects I already build several webservices on SharePoint this didn't feel like anything new to me and it was mostly more of an introduction to Silverlight 2.0 that that it had something to do with SharePoint. Patrick also showed us what it takes to use Silverlight in SharePoint  but the steps you should take were a bit to specific in my opinion and you'll have to look them up anyway as soon as you want to try it out yourself :)

    The next session was by Ingo Rammer and was about "Combining WCF and WF in the 3.5 framework to build durable services". I really liked this presentation since I work with WCF quite a lot on my projects and it was nice to see how to build workflow services using WF and WCF. Ingo showed us that in the 3.0 framework it wasn't possible to build durable services and if you use duplex services things can go wrong when one of your services restart for some reason. He build a durable service that was serialized when the service shuts down and when it starts again it can be deserialized again so the service that is sending a response wont get any errors because the service has restarted.

    The last session of the day was by Peter Himschoot and was about how to use REST and JSON in WCF. Peter showed us that it is really easy to use REST instead of soap to communicate to WCF services but I still don't think that I'm going to use this very often since REST is specially build to be reached by everyone and most services I build require security and that something that's lacking in REST. Rest isn't supposed to be used for those services and Peter had a nice line for this: REST = REACH. meaning that if you have to communicate with software that's build using older languages you probably use REST because most languages support the HTTP protocol.

    All in all it was a nice day and I enjoyed myself and learned lots of new stuff. People who are going again tomorrow enjoy! I won't be going tomorrow since I have to work on my project half a day before I go away for the weekend to Terschelling with my colleagues of Avanade Netherlands to have fun and drink some beers.

    Geert van der Cruijsen

    Display Picture Metadata in your Silverlight 2.0 Deepzoom Application

    By Geert van der Cruijsen at April 30, 2008 17:11
    Filed Under: Cool Stuff, Geert's Projects, Silverlight

    As i promised 2 days ago here's my post about how to display metadata of sub images in your Silverlight Deepzoom Application. I already typed this post yesterday but because of a stupid mistake i lost my post and now I have to type it again :( (but I think I'll make it a bit shorter)

    To start building your Silverlight 2.0 deepzoom application download Deepzoom Composer from Microsoft here. This tool works quite easy. just add some images in the "import" mode then drag them on your screen in the "compose" mode and then export your deepzoom Project.

    If you want to be able to identify the different sub images in your Multiscaleimage object check the "Create Collection" checkbox.

    deepzoomComposerCollection

    After exporting this will be the result:

    deepzoomexport

    Now to load up this collection of pictures into your own project take a look at this weblog, there is a really good explanation on which steps to take and after you did all those steps i'll explain how to show metada of the different subimages in the deepzoom application.

    So if you are at this point you should have your own working deepzoom application and you want to add picture metadata to your project. If not go back to this weblog or try one of these.

    The only way of identifying the different sub images in the big multiscaleimage is by the Z-Order of the different images. So how do you know which image has what Z-Order you ask? thats where the generated SparseImageSceneGraph.xml comes in which was generated by the Deepzoom Composer.

    <SceneNode

      <FileName> P1000558.JPG</FileName

      <x>0,235460826165879</x>

      <y>0,00108692916410255</y

      <Width>0,218281177677285</Width>

      <Height>0,144923888547009</Height

      <ZOrder>2</ZOrder>

      <Description>Uitzicht van hotelkamer</Description>

    </SceneNode>

     

    As you can see i added my own Description element to every SceneNode in the generated xml so we can use it in our project. We'll use this xml file to query the ZOrder of the subimage and get the description as a result with the use of Linq.

    To do this we'll first have to open the xml file in our code behind page from the page.xaml.cs.

    deepZoomObject.Loaded += delegate(object sender, RoutedEventArgs e)

    {

        _xmlImageMetadata = XDocument.Load("SparseImageSceneGraph.xml");

    };

     

    After that we'll add code to display the metadata when the mouse moves over a sub image in the multiscaleimage.

    deepZoomObject.MouseMove += delegate(object sender, MouseEventArgs e)

    {

        if (mouseButtonPressed) 

        {

            mouseIsDragging = true

        }

        else 

        {

            ImageName.Text = GetMetadata(e.GetPosition(deepZoomObject)); 

        }

        lastMousePos = e.GetPosition(deepZoomObject);

    };

     

    Then we add the function GetMetadata which queries the xml file and gets the description from it.

    private string GetMetadata(Point point)

    {

        Point p = deepZoomObject.ElementToLogicalPoint(point); 

        int subImageIndex = SubImageHitTest(p);

        if (subImageIndex >= 0) 

        {

            var q = from c in _xmlImageMetadata.Elements("SceneGraph").Elements("SceneNode"

            where ((string)c.Element("ZOrder")) == (subImageIndex + 1).ToString()

            select (string)c.Element("Description"); 

            if (q != null)

           

                return q.Single();

           

            else

                return ""

        }

        else 

            return "";

    }

     

    This function uses the function SubImageHitTest which I copied from this weblog:

    int SubImageHitTest(Point p)

    {

        for (int i = 0; i < deepZoomObject.SubImages.Count; i++) 

        {

            Rect subImageRect = GetSubImageRect(i); 

            if (subImageRect.Contains(p))           

                return i; 

        } return -1;

    }

     

    Rect GetSubImageRect(int indexSubImage)

    {

        if (indexSubImage < 0 || indexSubImage >= deepZoomObject.SubImages.Count)        

            return Rect.Empty;

        MultiScaleSubImage subImage = deepZoomObject.SubImages[indexSubImage]; 

        double scaleBy = 1 / subImage.ViewportWidth;

        return new Rect(-subImage.ViewportOrigin.X * scaleBy, -subImage.ViewportOrigin.Y * scaleBy, 1 * scaleBy, (1 / subImage.AspectRatio) * scaleBy);

    }

     

    if you build and start your application now you should be able to see your added metadata when you mouseover a sub image in the MultiscaleImage.

    My working example can be found here: http://www.vdcruijsen.net/projects/SilverlightDeepzoom/test.html

    sourcecode can be downloaded here:

    (you'll have to add your own deepzoom object since i removed that from the zip file)

     

    Happy Coding!

     

    Geert van der Cruijsen

    kick it on DotNetKicks.com

    Build your own Silverlight 2.0 Deepzoom application and host it with "Silverlight Streaming"

    By Geert van der Cruijsen at April 28, 2008 22:40
    Filed Under: Silverlight

    A few weeks back on MIX'08 Microsoft showed us a stunning demo including new technologies like Seadragon and Silverlight 2.0.

    This demo showed us the collection of memorabilia at Hardrock Cafe. The demo can be found at http://memorabilia.hardrock.com/

    This demo really got my attention and after some searching on the internet i found out i wasn't the only one. There are hundreds of blogposts by people showing how you can build this for yourself and guess what: it's really easy!

    I've spend some days in the weekend and this evening building my own version of a Silverlight Deepzoom Application. Most of my code is "borrowed" or copied from other blog posts which i'll list at the bottom of this post. My goal was to also be able to show metadata at the pictures and after some research it wasn't to hard to do this either. Since i didn't find any other blog posts who explained how to show metadata with your pictures i'll make a seperate blogpost about this tomorrow.

    I've put some of my last vacation photo's online in my own deepzoom test application at: http://www.vdcruijsen.net/projects/SilverlightDeepzoom/test.html (source also linked on that page)

    Download Source: 

    As i said before i won't go explaining the code in this post because i'm gonna do that tomorrow in a separate post where i'll explain how to add metadata to your deepzoom application. if you want more information about Silverlight and Deepzoom check out the following links:

    how it works: http://blogs.msdn.com/jaimer/archive/2008/03/31/a-deepzoom-primer-explained-and-coded.aspx

    lots of how-to's: http://projectsilverlight.blogspot.com/

    more info on silverlight 2.0 http://weblogs.asp.net/scottgu/archive/2008/02/22/first-look-at-silverlight-2.aspx

    Another cool thing i found out is that Microsoft is offering is a hosted environment for your silverlight applications. You can get up to 10GB of free space at Silverlight Streaming: http://silverlight.live.com/

    You can upload your Silverlight manifest files + other resource files like video's to Silverlight Streaming and you can link your silverlight object on your own page. The silverlight object in my own example is also hosted at Silverlight Streaming.

    If you have any questions or recommendations about this subject please dont hesitate to send me a mail about it.

    Geert van der Cruijsen

    kick it on DotNetKicks.com

     

    SharePoint Workflow running in a different context as the host sharepoint site

    By Geert van der Cruijsen at April 21, 2008 22:30
    Filed Under: SharePoint

    On my current project I ran into a problem with a custom SharePoint workflow because the workflow sometimes failed to run and sometimes it worked like a charm. When I cancelled a workflow which gave an error and restarted it by hand it finished without any problems.

    When I looked in the SharePoint logfiles what was causing my workflows to crash it showed that the workflow couldn’t find values for some settings in the web.config. I couldn’t think off any reason why the workflow couldn’t read these settings about 50% of the times a workflow was started.

    The workflow I created is automatically started after the change of an item in a specific document library. After some testing I found out that all workflows that I started by changing the item with the sharepoint webinterface worked fine but the items that were changed by an external source (a custom webservice I created but also the biztalk SharePoint Adapter webservice) crashed with the error that they couldn’t read the web.config.

    The webservices that are causing the workflow to crash are in a different sharepoint webapplication and thus use a different web.config. When I added my settings in the web.config of this webapplication the workflows stopped crashing.

    So it seems that the WF workflows are running in the process which changed the item in the sharepoint list which caused the workflow to start instead of the standard w3p process of SharePoint which I thought always was the case.

    Happy coding!

    Volta or Silverlight 2.0

    By Geert van der Cruijsen at April 21, 2008 22:19
    Filed Under: Silverlight

    Last Wednesday evening we had a presentation at the Avanade Netherlands office about Volta and what Volta could do for us in the future. The demo in the presentation showed us the possibilities that Volta can bring to software developing on the web. After this presentation we had a cool discussion about the question if Volta will really make it to the daily life of web based software development.

    In my opinion with my current knowledge about Volta is that a lot of pro’s of Volta are also taken away by using Silverlight 2.0 on the client instead of html/javascript. I’ll sum up most pro’s of using Volta and then compare then to the use of Silverlight 2.0. Ofcourse most things said in this post are just my current ideas and opinions on the 2 projects which are far from complete products today.

     

     

     

    Some pro’s on volta are: Dynamic/easy switching of the place where code is being executed. You can add a single line of code in a class and make it completely run on the client instead of on the server. If you want your code to run on the client Volta will generate javascript from your .net code after it’s compiled to the IL.

    This power of volta makes it easy to just generate all your javascript instead of writing it all by yourself. Everyone knows writing/debugging loads of javascript can be a pain in the ass so of course it’s nice to program in C# or any other .net language you like. You can even set breakpoints on the c# code which you created and step through this when you are actually running generated javascript at that time.

    Volta can also generate javascript which is compatible with the browser which is doing the current request so you don’t have to think about cross browser compatibility anymore.

    All in all at the time Volta will be a fully grown product you can write your whole web application in 1 language instead of also having to write javascript to get your fancy web 2.0 look and feel on your web app.

    After seeing the presentation about Volta I thought the only big feature Volta can bring is the possibility to dynamically change parts of code to run on the client or server. The other nice features are also brought to us with Silverlight 2.0 which makes it possible to write C# for the client side instead of javascript. In my opinion Silverlight even has more and better options to do this because  you have more powerfull tools in the Silverlight runtime which make it possible to make even fancier tools then you can in Javascript. One big example of something Silverlight can do which javascript will never do is that you can make real statefull apps instead of the stateless pages you’ll keep building in Javascript. Opening sockets to the server will never been done by javascript while it is easy to do in Silverlight 2.0

     

    So if javascript is going away in both cases what does Volta bring that silverlight can’t handle? The only big thing that is left is changing your code to run on the server/client by adding a line of code to your class. Ofcourse this can be a really powerfull thing but in my opinion this wont be used that often and especially not in enterprise applications where my focus on my job is at.

    In my opinion Silverlight 2.0 can become a really big revolution on the web IF and only IF Microsoft does everything it can to get the silverlight plugin on ALL pc’s as soon as possible (ofcourse after Silverlight 2.0 is released) The plugin has to be available for every browser no matter what OS. No matter what type of computer. Desktop or mobile. Everyone with Linux and Firefox or Windows and IE will have to get this plugin which has same functionality. So in my opinion Microsoft should develop the plugin for all browsers instead of only for windows+IE and let the moonlight project reverse engineer this plugin for a plugin that runs on linux. Volta instead of Silverlight doesn’t have this problem because the javascript code that’s being generated already runs on all sort’s of browsers on all OS’es.

    We’ll have to see what the future brings but my money is on Silverlight being installed on 95% of all pc’s in a year or 2 so we don’t have to generate Javascript but can just make flashy c# code on the client.

    Another option can also be that Volta will be generating Silverlight code instead of javascript so we get the best of both worlds :)

    Do you have a different opinion? Please let me know in a comment!

    Small things that make life easier: attach Visual studio debugger to multiple processes

    By Geert van der Cruijsen at March 31, 2008 21:48
    Filed Under: Asp.net, General

    Hello again.

    Today a really small post from me about a really simple thing i found out today. Ofcourse a lot of people know this but i also know lots of people dont know this while you are using it quite often. When you are developing for SharePoint for example you'll have to debug by attaching your debugger to the right w3wp.exe process. When i did this i always selected 1 and hoped it was the right one. Today i was debugging together with a collegue and then he selected more processes at once and i was like *DOH*!!!

    This discovery can save a lot of time if you always pick the wrong w3wp.exe process like i did :)

    so for everyone who didnt know this use this option from now on. I will do it for sure!

     

    Geert van der Cruijsen

    Microsoft releases beta versions of IE8 and Silverlight 2.0 at MIX 08

    By Geert van der Cruijsen at March 06, 2008 22:44
    Filed Under: General, Silverlight

    Today Microsoft launched the public beta of Internet Explorer 8 at MIX'08. As i posted in a blogposting yesterday the big change in Internet Explorer 8 is the render engine which is running in "super standard mode" instead of quirks mode that IE7 uses. You can download the public beta here: http://www.microsoft.com/windows/products/winfamily/ie/ie8/default.mspx

    One thing microsoft learned about the release of IE7 was that after the first Beta release of IE7 there were so many reactions, complaints and idea's send by people that it was almost undoable to do something with all the input. With this release of IE8 Microsoft opened up there bug database to the public so everyone can see the known bugs and people can even help prioritize these bugs.

    One of the new feature in IE8 apart from the render engine is the use of "webslices" (http://www.microsoft.com/windows/products/winfamily/ie/ie8/webslices.mspx) these webslices look like a sort of rss technology where you can subscribe yourself to a part of a website instead of an rss feed and the webslice technology will let you know when the data changed.

    Microsoft also released the beta of Silverlight 2.0. Scott Guthrie made a nice post about that on his blog: http://weblogs.asp.net/scottgu/archive/2008/02/22/first-look-at-silverlight-2.aspx

    There are also some nice video's on the website of MIX 08. These video's and part of the website are made with silverlight 1.0 so check it out:

    mix website: http://visitmix.com/2008/default.aspx

    mix videos: http://sessions.visitmix.com/

    Geert van der Cruijsen

    Changing the "object reference not set to an instance of an object" Exception in BizUnit 2.3 for Biztalk 2006

    By Geert van der Cruijsen at March 04, 2008 20:49
    Filed Under: Biztalk 2006

    Lately I’ve been working with BizUnit 2.3 to create Unit tests for the Orchestrations we’ve build in BizTalk 2006 at our current customer.

    BizUnit 2.3 is an opensource project on CodePlex (http://www.codeplex.com/bizunit ) to help you make the testing of these orchestrations easier. I’ve noticed that when you create a validation step and try to do a check with an xpath query you can get weird errors when the element you are looking for doesn’t exists.The Exception you’ll receive will be: 

     

    "object reference not set to an instance of an object"

    This Error doesn’t really say what is going wrong in your test report and that’s because the application isn’t throwing an ApplicationException but the code right in front of it will go wrong because checknode is null and BizUnit is trying to compare the checknode.InnerText.What I did was change the code in the XmlValidationStep.cs so it will give a nice ApplicationException when the element you are trying to check doesn’t exist in the xml file you are checking.The changes I made to the code are written down here and should be inserted into XmlValidationStep.cs in the BizUnit 2.3 project

     

    string xpathExp = xpath.SelectSingleNode("@query").Value;
    XmlNode valNode = xpath.SelectSingleNode(".");
    string nodeValue = valNode.InnerText;
    context.LogInfo("XmlValidationStep evaluting XPath {0} equals \"{1}\"", xpathExp, nodeValue );
    XmlNode checkNode = null;

    try
    {
      checkNode = doc.SelectSingleNode(xpathExp);
    }
    catch
    { }
    if
    (checkNode != null)
    {

      if
    (0 != nodeValue.CompareTo(checkNode.InnerText))
      {
        throw new ApplicationException(string.Format("XmlValidationStep failed, compare {0} != {1}, xpath query used: {2}", nodeValue, checkNode.InnerText, xpathExp));
      }
    }
    else

    {
      throw new ApplicationException(string.Format("XmlValidationStep failed, no element found, xpath query used: {0}", xpathExp));
    } 

    Hope this will help you understand the errors you get while testing with BizUnit on your project! 

    Geert van der Cruijsen

     

     

    Internet Explorer 8 will render with 'super standard mode'

    By Geert van der Cruijsen at March 04, 2008 20:04
    Filed Under: Asp.net, General

    Today Microsoft promised Internet Explorer 8 will use the 'super standard mode'  rendering mode by standard instead of the IE7 version 'Quirks mode' that was planned earier.

    Because of this People will be forced using the W3C standards OR add a special tag so the browser knows it should render the page in IE7 mode. Hopefully this will help to have 1 standard html which every browser will show the same way. More information about this: http://blogs.msdn.com/ie/archive/2008/03/03/microsoft-s-interoperability-principles-and-ie8.aspx 

    With this change IE8 will be able to pass the ACID2 test but guess what the "Web Standards Project" released the ACID3 test today which is supposed to test Ajax and other dynamic content in browsers. IE7 get's a score of 5 out of 100 while FireFox is getting the current best score with 50/100. Still a long way to go for every browser to pass this test. You can find the test and more information here: http://www.webstandards.org/action/acid3/

     

    Geert van der Cruijsen

    SharePoint BDC listview error: "An unhandled exception has occurred: There was an error in the callback"

    By Geert van der Cruijsen at February 21, 2008 23:29
    Filed Under: SharePoint

    So after my first month off having my own development blog I already start to slack on making new posts. Not a good sign ;) Well here’s an update again about a weird error I came across in SharePoint today. I'll try to make more posts in the near future but lately I didn't see any cool things to blog about. I also spend most of my free time to study for my MCPD exam next week.

    I was working on a SharePoint Solution using the Business Data Catalog to retrieve data from a mssql database and to show this data in a BDC list view. On my development machine everything was working fine so I uploaded it to my test environment and what happened.

    The following error came up: "An unhandled exception has occurred: There was an error in the callback"


    I checked the trace log and the event viewer. Both didn’t show anything about any error involving the Business data catalog. Google didn’t result in anything useful either so I asked around at some colleagues. Finally one of them gave me the following link:

    http://discuss.joelonsoftware.com/default.asp?dotnet.12.506335.2

    The people at this page have a slightly different problem but I didn’t have any other solutions so I thought I might give it a try. And after I tried it I was stunned. The Data List view actually worked.

    So what was the solution? Adding a Search box web part to the page containing the BDC data list view did the trick. You can set the search box to invisible if you don’t want it visible on your page.

    I haven’t looked why this search box webpart is connected to the data list view yet but I would really like to know why. It took quite some time to figure this one out so in the end I was happy it worked.

    For anyone of you who encounter the same problem as I did I hope you find this post faster as I found my answer today.

    Enjoy!

    Geert van der Cruijsen

    Searching Custom columns in SharePoint

    By Geert van der Cruijsen at January 16, 2008 22:33
    Filed Under: SharePoint

    The SharePoint Keywordquery and Fulltextsearch are good ways to search metadata programmatically. This option is only available for MOSS 2007 because you don’t have a server context object in WSS 3.0.


    When you Create a keyword query instance the metadata properties that will be returned will only be the basic SharePoint metadata fields like name, title etc. When you want to get your own created columns in the results you’ll have to add the property names to the to the SelectProperties object from the keywordquery.

    // Set result properties
    kwq.SelectProperties.Add("ProductID");

    To search custom SharePoint properties you’ll have to set these properties as Managed Metadata first. After you’ve done this it’s pretty easy. You can just put “propertyname:value” as QueryText and then the search will search the property “propertyname” which contain “value”. You’ll have to put quotes around the search value because otherwise the search will also show results where the value is only a part of the property value.

    Below is a full example how to create a KeywordQuery in code for in example your custom webparts.

    string SSP = ConfigurationManager.AppSettings["SSP"].ToString(); 
    ServerContext context = ServerContext.GetContext(SSP);
    KeywordQuery kwq = new KeywordQuery(context);

    // Set properties for the query before executing
    kwq.ResultTypes = ResultType.RelevantResults;
    kwq.EnableStemming = true;
    kwq.TrimDuplicates = true;

    // Set result properties
    kwq.SelectProperties.Add("ProductID"); 

    kwq.QueryText = column + ":" + value;
    // Fetch data
    ResultTableCollection results = kwq.Execute();
    ResultTable resultTable = results[ResultType.RelevantResults];

    // Load data into a DataTable
    DataTable tbl = new DataTable();
    tbl.Load(resultTable, LoadOption.OverwriteChanges);

    return tbl;

    Hope this will help you building your own custom search webparts in MOSS 2007

    Geert van der Cruijsen

    Geert's Vista Sidebar Gadget: Last.fm stream player version 0.1 released

    By Geert van der Cruijsen at January 06, 2008 13:07
    Filed Under: Cool Stuff, Geert's Projects

    I've been spending all my spare time this weekend to this project but now the player is ready for release 0.1 beta ;)

    You can download the gadget here:

    Last.fm Stream Player gadget Download

     

    Information about how it's made 

    I've used wireshark to learn how the official client was using the last.fm protocol to get a mp3 stream since this wasnt documentated on the last.fm development documentation.

    The different states in the protocol are:

    • handshake 1 (for streaming)
    • handshake 2 (for scrobbling)
    • tuning into a channel
    • get metadata of current song
    • send "now playing" information
    • at the end of song submit the scrobbled song
    • go to step 1

    Since vista sidebar gadgets are html/javascript only the gadget is using an windows media player activex object to play the actual stream. All the handshake and other http requests are done by ajax calls to the audioscrobbler server. You can download the source on the download page also.

    Have fun!

    Geert van der Cruijsen

    Creating a Microsoft Windows Vista Sidebar Gadget: Last.fm stream player - part 1

    By Geert van der Cruijsen at January 04, 2008 21:47
    Filed Under: Cool Stuff, Geert's Projects

    I’ve been using Windows Vista for 1 year now and I never used the sidebar before. I turned it off in the first week and never turned it back on again. Last week I decided to give it a try again and after filling it with some handy gadgets I thought it was time to build my own.

    I didn’t know how to build a gadget so I looked it up on MSDN. There are some samples there but basically sidebar gadgets are small “web parts” totally build in HTML and JavaScript.

    My first gadget I’m going to build is a Last.FM music player that can play a music stream from the Last.fm site with peoples favorite artists or with music matching a tag. Like you can do on the Last.fm site yourself.I went searching how I could get this stream to run in my gadget and I found out that Last.fm is using a fairly simple http based protocol which is described at http://www.audioscrobbler.net/development/protocol/I first started out with the 1.1 protocol because I didn’t read that there already was a 1.2 version. The 1.2 protocol has 3 states (handshake, now playing and submission) at the moment I’m writing this the only thing I have made is the handshake part and other functions to get metadata from the track.

    I didnt make a nice user interface for my gadget yet and i didnt make anything to save your settings in. This will all be done in the upcoming days. If someone is really good in making a nice little interface (max 60 pixels wide) and feel like helping me out at this give me a call!. I'm not that good at grapic design.

    btw. Coding Javascript in Visual Studio 2008 is really really nice. The intellisense really works great and it helps you write code a lot quicker.

    I didnt put the sourcecode online yet since it's all in the debugging phase right now and everything is still hard coded (user,password, radio channel etc). When everything is done i'll post the full sourcecode here.

    The functions that I’ve build now are shown in the following picture

    The javascript code for these functions is shown below. (I will put it all on my site as a gadget when the whole thing is done).

    This is all i could do in my spare time the last 2 days. I hope to get a lot further tomorrow and i'll post the results again.

    function Play()

    {

    duration = 0;

    document.WindowsMediaPlayer.Stop();

     

    GetMetaData();

    currentlyPlaying = true;

     

    setTimeout("UpdateTimer()", 1000);

     

    }

    function stop()

    {

    currentlyPlaying = false;

    document.WindowsMediaPlayer.Stop();

    }

    function UpdateTimer()

    {

    if (currentlyPlaying)

    {

    if((document.WindowsMediaPlayer.CurrentPosition < duration) || (duration == 0))

    {

    document.getElementById("counter").innerHTML = ConvertSecondsToTime(document.WindowsMediaPlayer.CurrentPosition);setTimeout("UpdateTimer()", 950);

     

    }

    else

    {

    //alert("restart");

    document.WindowsMediaPlayer.Stop();

    SendHandshake();

    }

    }

    else

    {

    stop();

    }

    }

    function ConvertSecondsToTime(seconds)

    {

    var date = new Date(seconds * 1000);

    var timeString = date.getMinutes() + ":" + date.getSeconds();

    return timeString;

    }

    function makeRequest(url) { http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...

    http_request = new XMLHttpRequest();

    if (http_request.overrideMimeType) {http_request.overrideMimeType(

    'text/xml');

    }

    } else if (window.ActiveXObject) { // IE

    try {

    http_request = new ActiveXObject("Msxml2.XMLHTTP");}

    catch (e) {

    try {http_request =

    new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {alert("error");}

    }

    }

    if (!http_request) {

    alert('Giving up :( Cannot create an XMLHTTP instance');

    return false;

    }

    http_request.onreadystatechange = alertContents;

    http_request.open('GET', url, true); http_request.send(null);

    }

    function alertContents()

    {

    if (http_request.readyState == 4)

    {

    if (http_request.status == 200)

    {

     

    document.getElementById("debug").innerHTML = http_request.responseText;

     

    switch(functionCall)

    {

    case "SendHandshake" :

    GetHandshakeResponse(http_request.responseText);

    break;case "TuneIn" :

    GetTuneInResponse(http_request.responseText);

    break;

    case "GetMetaData" :

    GetMetaDataResponse(http_request.responseText);

    break;default:

    alert(functionCall);

    }

    }

    else

    {

    alert('There was a problem with the request.' + http_request.status);

    }

    }

    }

    function SendHandshake()

    {

    var now = new Date();

    now.setHours(now.getUTCHours(),now.getUTCMinutes(),now.getUTCSeconds(),now.getUTCMilliseconds());

    var time = parseInt(now.getTime()/1000.0)

     

    functionCall = "SendHandshake";

    url = "http://post.audioscrobbler.com/?hs=true&p=1.2&c=tst&v=1.3.1.1&u="

    url += "geertvdcruijsen";url += "&t=";

    url += time;

    url += "&a=";

    var md5String = MD5("password");

    md5String += (time);

    url += MD5(md5String);

    makeRequest(url);

     

    }

    function GetHandshakeResponse(response)

    {

    arr_response = response.split("\n");

    //stream_url = arr_response[1].split("stream_url=")[1];

    session = arr_response[0].split("session=")[1];document.getElementById("session").innerHTML =response;

    TuneIn();

     

    }

    function TuneIn()

    {

    functionCall = "TuneIn";url = "http://ws.audioscrobbler.com/radio/adjust.php?session=";

    url += session;

    url += "&url="

    url += "lastfm://artist/Chemical+Brothers/similarartists";url += "&debug=0";

    makeRequest(url);

    }

    function GetTuneInResponse(response)

    {

    Play();

    }

    function GetMetaData()

    {

    var now = new Date();

    functionCall = "GetMetaData";url =

    "http://ws.audioscrobbler.com/radio/xspf.php?sk=";

    url += session;

    url += "&discovery=0&desktop=1.3.1.1&time="

    url += now.getTime();

    makeRequest(url);

     

     

    }

    function GetMetaDataResponse(response)

    {

    arr_location = response.split("<location>");stream_url = arr_location[1].split("</location>")[0];

     

    arr_duration = response.split("<duration>");duration = arr_duration[1].split(

    "</duration>")[0];

     

    duration = (parseInt(duration,0)/1000) -3;

    document.getElementById("metadata").innerHTML = ConvertSecondsToTime(duration);

     

    document.WindowsMediaPlayer.fileName = stream_url;

    document.WindowsMediaPlayer.Play();

    }

    <object id="wmp" standby="standby" type="application/x-oleobject"> <embed type="application/x-mplayer2" id="WindowsMediaPlayer" name="WindowsMediaPlayer" showstatusbar="-1"></embed>

    </object>

    Volta, Seadragon and Photosynth. Cool stuff from Microsoft Live labs

    By Geert van der Cruijsen at December 30, 2007 13:37
    Filed Under: Cool Stuff, General

    Almost 1 month ago Microsoft showed us their first technology preview of Volta. Volta is a new technology by Microsoft which makes it possible to change code to run on the server or client by only changing 1 line of code.

    Imagine the possibilities on proof of concept projects where you don’t know where the bottlenecks will be. With this technology you can just build a test application and when you’re finished you can change pieces of code to run on the client or server to increase performance. Go and download the Volta technology preview on the live labs site now.

    Another thing I wanted to show you is Seadragon. Seadragon is another technology by Live Labs from Microsoft. Seadragon is a technology where really high resolution pictures are stored on a server and you can zoom into them on the client. This makes it really easy to watch really high resolution images without having them on the client location. The Server application only sends the information that the client can see to the client application. These generated images are far less big in size as the original images are on the server.

    Photosynth is another technology made by Live Labs and it is using the Seadragon technology to stream the images to the client. Photosynth is a tool to view a collection of images based on the location of where the images are taken. Photosynth can scan through a big collection of images of for example a big building and make up a 3d model of this building by using the images in the collection. You can view the building by selecting the angle of a specific image and the application will load that image with the Seadragon technology. From this new angle on the building you can zoom or select another image and you can take a virtual tour around the building like that.

    You can test Photosynth on the live labs website with a few collections off famous buildings/objects like the NASA space shuttle Endeavour or Piazza San marco in Venice.

    I found a really nice video about Seadragon and Photosynth on Youtube. If you want to see what is possible with these new technologies you really have to check it out.

     

    I really think these technologies can grow big if you combine it for example with sites as Flickr so you can get a really new experience browsing through pictures.

    Geert van der Cruijsen

     

    Using the Flickr.net Api on a medium trust server

    By Geert van der Cruijsen at December 29, 2007 19:37
    Filed Under: Asp.net

    The photo sharing site Flickr has a nice api which you can use in your own applications. On codeplex is a .net version of this api Flickr.net.

    I had to make a little script for a friends project so she could view random flickr photo's on her site. I made a aspx page using the Flickr.Net dll and it worked perfectly on my own machine. after uploading it to my hosted webserver i ran into trouble. the following error came up when browsing to the aspx page

    Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    After some research i came to the conclusion that it had something to do with my site running in a medium trust. The Flickr.Net api uses a caching function standard which doesnt has the right permission on a hosted envoirment.

    The real solution was easy after i found out what the real problem was. The only thing i had to do was disable the caching:

    Flickr.CacheDisabled = true;

     

    After doing this the script was running perfectly. during the search for the solution to this problem i came across a lot of people who had the same problem when deploying their Flickr.net enabled scripts so i thought it was handy to post this simple solution.

    Have fun with your Flickr.Net enabled Scripts!

    Geert van der Cruijsen

    403 Forbidden error when deploying custom features in SharePoint

    By Geert van der Cruijsen at December 22, 2007 18:22
    Filed Under: SharePoint

    This week i ran into a problem after deploying a feature in SharePoint. I ran the stdadm command to install and activate a feature, the command returned without any errors so i thought everything was ok. When i tried to open up SharePoint in the browser all the pages gave a "403 forbidden" error

    My first thoughts where that there was something wrong with the feature but this couldn't be the case because this feature was installed on multiple envoirments and they were all working ok.

    After some research i found out that SharePoint didnt have enough rights in the feature directory in "program files\common files\microsoft shared\web server extensions\12\templates\features\$feature name dir"

    This error can occur when you manually create a directory in the "features" directory of SharePoint. You can easily fix it by right clicking the folder, click properties, security and then Advanced. On the permissions tab delete the "Uninhereted permissions from the folder". Another option is to manually give the right users the rights to the directory.

    Geert van der Cruijsen

    Creating a multitouch User interface in C# using the WiiMote

    By Geert van der Cruijsen at December 22, 2007 18:03
    Filed Under: Cool Stuff, General

    I think most people heard about Microsoft Surface. (If not check http://www.microsoft.com/surface/) This machine will cost around 5000 to 10000 dollars but hey it's a really cool device. Now on my daily journey surfing the internet I came across a really cool project that everyone can try at home if you have knowledge about .net and own a Nintendo Wii to create your own multi touch user interface!

    Since the Wii remote is using a Bluetooth connection towards it’s remote it’s also possible to connect it to your own pc. The Wii remote has an infra red sensor which can sense multiple infra red light sources at the same time.

    How this all works is explained at http://www.cs.cmu.edu/~johnny/projects/wii/

    There is also a C# sample code how to connect your pc to your Wii remote and how you’re able to do cool stuff with it. If I have enough time in the coming weeks I’ll try to test it myself if I can get my hands on some infra red LED’s.

    Have fun!

    Geert van der Cruijsen

    Hello World!

    By Geert van der Cruijsen at December 22, 2007 17:19
    Filed Under: General

    Hi everyone,


    Welcome to my first blog. The reason I’m starting to blog is that I’ve recently started working for Avanade and I’m coming across a lot of new things in the Microsoft world and i would like to share those things with you.


    I’m trying to keep up with all the new things Microsoft is throwing at us and I’ll post some experiences when I try them out.


    About myself: my name is Geert van der Cruijsen and me and my girlfriend live together in Uden, The Netherlands. I started to work for Avanade the first of September this year and I’m going to work on my MCPD-EA certification this year. From the Microsoft technology my experience lies in SharePoint 2007, C#, asp.net and Webservices.


    Thanks for reading my first post and enjoy!