I’m sure that, like a lot of people working with EPiServer I have a play area that I use to try things out and start off any proof of concept work that I’m going to be implementing later on in  various projects.  For this, I use the SDK Installation of EPiServer CMS along with an instance of the Visual Studio Web Server when my laptop boots up so that it’s always running.

Today, I wanted to have a play with Composer with a view to knowing enough about it to be able to get sign-off some projects that can use it.  First thing is just install it and see what happens.  There were some pretty good videos on the EPiServer site that give you basic tutorials on what to do once it was installed, but installing it is a minor stumbling block if you’re running the SDK, as your site it not hosted in IIS.  Cunningly, the EPiServer Deployment Center seems to look at sites in IIS and you don’t appear to have the ability to connect to a different web server (please, someone correct me if I am wrong).

You can get past this little ‘glitch’ assuming that you have and instance of IIS installed locally and it’s pretty simple to get around if you follow the steps below:

  1. Crack open the web.config file of your SDK site.  Remove the port from the siteUrl, uiUrl and utilUrl attributes in the siteSettings element. 
    More than likely the value is 6666, but note it down, as you will be putting it back later.
  2. Open up IIS administration and create a new virtual directory with the same name as your SDK site.  Point thin new virtual directory at your SDK site installation folder and ensure that you create an application for it (if not automatically done).
  3. IIS will now be able to server your site, but EPiServer will rightly inform you that you don’t have a license file.  Don’t worry too much about that, because we have no intention of really using IIS to serve the files and will be scurrying back to Visual Studio’s web server before too long.
  4. Your next step is a potential setting change in the web.config again.  Look for the virtualPathMappings element (if there is one already) and make sure that the url attribute starts ‘~/’.  I had a full URL in here, but this could well have been to a previous bungled attempt at doing this.  It’s worth checking and making sure it’s right.  If you cant find it, don’t worry.
  5. From here, you should be able to open the EPiServer Deployment Centre and see your site.  Select the site and install the Composer, and click ‘Next’ a couple of times until the installation  is complete. 
    After you have done this, maybe install the samples too for good measure – chances are you are about to have a play anyway.
  6. Now that we have done that, we can reset the web.config to use the Visual Studio in-built web server by putting the port numbers back in.  You can delete the IIS virtual directory at this point, or leave it there for later use, possibly with other EPiServer extension installations.
  7. If you now look at your website in the Visual Studio solution explorer, click ‘View All Files’ and add the ‘Composer’ and ‘Dropit’ folders to the project.  Also, a reference to each of the DropIt DLLs that now reside in your bin folder:
    • Dropit.ComponentArt.Web.UI.dll
    • Dropit.Extension.dll
    • Dropit.Extension.UI.dll
  8. You should now be able to build your site without any problems, so cross you fingers and hit <CTRL>+<SHIFT>+<B>.
  9. Assuming it all builds, your next step is to go and set up the Dropit.Extension plug-in.  To do this, start your site and go to the Config tab in the Admin section.  Select Plug-in Manager and edit the setting for Dropit.Extension.  If the first property (‘Set the page ID for the root Composer data container’) is not set, click the little button and select the [Extension data Container] page from the root of your site.  This should have been created during the installation of the Composer on your site.

That should be enough to get you running so that you can run through some of the sample videos on the EPiServer site and have a jolly good play.

It’s worth noting that I was running around in circles with a simple error until some nice fellow on twitter told me to check this article that contains logging information for composer (thanks, Mr. Hellstrom).  It’s worth having on at least whilst you are getting to grips with it.

 

This is what i tried, although I suppose it is probably not en exact science, but it certainly should be a stab in the right direction.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Tuesday, June 30 2009 at 05:06 PM by Matt Nield

I'll not be updating this blog anymore.  Instead, you can find my new blog at http://stevehorsfield.wordpress.com.

That blog will include both personal and business entries and is in no way representative of either Business & Decision or Interakting.  However, you will be able to find business, IT and other posts there.

If you've found any of the posts on this blog useful, please update your links to my new blog.  Many thanks.

Regards,

Stephen Horsfield


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Monday, June 22 2009 at 10:53 AM by Stephen Horsfield

Now that I get to use EPiServer CMS v5, I’m having approximately 165.3% more fun that I was with version 4.6.  I can actually find information about 5 easily on the internet, brilliant!  What I do find dismally disappointing though is the state of the SDK.  A great deal of it just lists methods or properties with no description.  In honesty, I can find out more using reflector.net.

While I appreciate that the guys at EPiServer are doing some great work delivering a brilliant set of tools for us to work with, I can’t help but think that someone should be updating the SDK with a little more vigor.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Friday, June 19 2009 at 04:48 PM by Matt Nield

I’ve been working on a couple of things lately in EPiServer that I want to be able to easily re-use on other projects.  From my point of view that means just dropping DLLs in folders and letting EPiServer do as much of the work as possible.  One of my little pieces  of functionality needs to happen when a page has been published.  There are a couple of ways to do this, and previously I have been doing it in globla.ascx.  Today I cam across an blog by Allen Thraen on discussing the subject of how to register DataFactory event handlers in EPiServer which describes in much better detail than I can about the different methods that can be used.

I ended up using the last method he mentions as I find it the cleanest way forward.  I would copy the code in here, but you should go read his blog about it in honesty as its full of interesting stuff as always.  The key point is that any class that inherits from EPiServer.PlugIn.PlugInAttribute and has a void Start() method will be called by EPiServer in the plug-in loading mechanism.

The thing to keep in mind is that (as per Allen’s example code), if you register a PublishedEvent handler, it will happen when any page is published.  That being the case, you’ll need to be inventive with filtering your exact requirements in the event handler making sure that you only do what you want when you want to!  Common sense I suppose. 

I then got to thinking, “Hey, if I can do this then how messy is this potentially going to get if anyone can register and event handler?”.  It would be pretty difficult to get a handle on what is going on.  Luckily, Andres Hattestad has got a solution for this that reports which events are registered, and where.  I’m trying that out just now, but I’m pretty certain it’s going to be awesome and make my life a lot easier over the coming weeks, as I have a lot of plug-ins that I want to build.

I strongly suggest that you going and read Anders’s and Allen’s posts and adorn them with due praise for being clever and of a sharing nature :)


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Thursday, June 18 2009 at 06:04 PM by Matt Nield

Bah, I just found a much quicker and much simpler way of reading RSS while reading Mats Hellström’s blog article about Aggregating Feeds on the EPiServer Blogs.

Mats is talking about taking multiple feeds and adding them together, I’m still really only interested in on.  The key point I took from his blog is the SyndicationFeed class and all of its pals from the System.ServiceModel.Syndication namespace.  This makes most (read that as all) of my previous post on the subject pretty much irrelevant, as this is all nicely handled for us.

The code blow shows how I might do somethign similar to the previous post using nicer code:

using System;
using System.Linq;
using System.ServiceModel.Syndication;
using System.Xml;
 
namespace Using_Syndication_Feed
{
    class Program
    {
        static void Main(string[] args)
        {
            SyndicationFeed rssFeed = SyndicationFeed.Load(
                    XmlReader.Create("http://www.planet-f1.com/rss/0,16039,3213,00.xml")
                    );
 
            Console.WriteLine(
                String.Format(
                    "{0} > {1}",
                    rssFeed.Title.Text,
                    rssFeed.Links[0].Uri.AbsoluteUri
                    )
                );
 
            foreach (SyndicationItem rssItem in rssFeed.Items.Take(10))
            {
                Console.WriteLine(
                    String.Format(
                        "{0} - [{1}]",
                        rssItem.Title.Text,
                        rssItem.PublishDate.ToString("s")
                        )
                    );
            }
 
            Console.ReadLine();
        }
    }
}

Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Friday, June 12 2009 at 04:51 PM by Matt Nield

Having had a glimpse on the BBC this morning, it looks like Microsoft are intending to shift Windows 7 without IE installed in Europe, it is now something users will have to go and download and install for themselves. 

In general, it looks like they’re leaving it up to the hardware vendors to decide what is installed on the machine and what is not, but what happens when user pop out and buy a copy of Windows 7 themselves?  I assume that means that there will just be a link on the desktop to go and download the file, otherwise, I can’t quite see how your average user is going to get on the internet in the first place to go and find a web-browser to download!  On the other hand, I can’t see your average user popping out and buying a copy of Windows.

What seems slightly risible to me is that Microsoft get slapped around by the European Commission for bundling things in to their OS, and Apple later on use the bundling of pre-installed software in the OS as a selling point with iLife.

Related Information:


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Friday, June 12 2009 at 12:28 PM by Matt Nield

I was recently working on an EPiServer solution and the client wanted to include an RSS feed on certain pages of their site.  I though I would write out here how I consumed the feed.  You’ll want to add error handling etc in here, as this is as rough as a tramps beard whilst being enough for you to get the point.

The first thing I had to do was to find out how RSS is structured.  After a little Google search I found an article explaining the structure of RSS in sufficient detail for me to continue.

The first thing that I did was create a struck to contain the configuration that I wanted, fairly simple:

    /// <summary>
    /// RSS feed configuration.
    /// </summary>
    [Serializable]
    struct PropertyRssFeedData
    {
        private string feedLocation;
        private bool linkTitle;
        private bool displayRssImage;
        private int numberofItemstoDisplay;
 
        public string FeedLocation { get { return this.feedLocation; } set { this.feedLocation = value; } }
        public bool LinkTitle { get { return this.linkTitle; } set { this.linkTitle = value; } }
        public bool DisplayRssImage { get { return this.displayRssImage; } set { this.displayRssImage = value; } }
        public int NumberofItemstoDisplay { get { return this.numberofItemstoDisplay; } set { this.numberofItemstoDisplay = value; } }
 
        public PropertyRssFeedData(string url, int numItems, bool linkTitle, bool rssIcon)
        {
            this.feedLocation = url;
            this.numberofItemstoDisplay = numItems;
            this.linkTitle = linkTitle;
            this.displayRssImage = rssIcon;
        }
    }

An instance of this will be serialized/deserialized as versions of the page are edited/created in EPiServer.  Essentially I just use it to determine how to render my HTML that I will present to the end-user.  Actually reading the RSS is pretty straight forward (this is really being posted as a reminder for me, but might be useful for others).   The following code creates a simple HTML block to present our feed.

#region render links and things
internalData = DeserializeData((string)PropertyData.Value);
 
// Go get the feed
XmlTextReader rssReader = new XmlTextReader(internalData.FeedLocation);
XmlDocument rssDoc = new XmlDocument();
rssDoc.Load(rssReader);
 
// Look for the <rss> tag
XmlNode nodeRss = rssDoc.SelectSingleNode("//rss");
 
// ensure we have an RSS node before we continue
if (nodeRss != null)
{
    // OK, start creating controls
    StringBuilder htmlResult = new StringBuilder();
    htmlResult.Append("<div id=\"rssFeed\">" + Environment.NewLine);
 
    // Look for the <channel> tag
    XmlNode nodeChannel = nodeRss.SelectSingleNode("//channel");
 
    #region Feed title
    htmlResult.Append("\t<div id=\"rssFeedTitle\">");
 
    if (internalData.LinkTitle)
    {
        htmlResult.AppendFormat(
            "<a href=\"{0}\">{1}</a>",
            nodeChannel["link"].InnerText,
            nodeChannel["title"].InnerText
            ); 
    }
    else
    {
        htmlResult.Append(nodeChannel["title"].InnerText);
    }
    htmlResult.Append("</div>" + Environment.NewLine);
    #endregion
 
    #region items
    // get the kiddies
    if (nodeChannel != null)
    {
        XmlNodeList itemNodes = nodeChannel.SelectNodes("//item");
 
        if (itemNodes.Count > 0)
        {
            htmlResult.Append("\t<ul>" + Environment.NewLine);
 
            // we only want to display the maximum set in the 
            // configuration (otherwise ofc, we coudl use foreach here
            for(int counter = 0; counter < internalData.NumberofItemstoDisplay; counter++)
            {
                htmlResult.Append("\t\t<li>");
 
                // Display the icon or not
                if (internalData.DisplayRssImage)
                {
                    // TODO : find a better way of displaying this
                    htmlResult.AppendFormat(
                        "<a href=\"{0}\">{1}</a>",
                        itemNodes[counter]["link"].InnerText,
                        String.Format(
                            "<img src=\"{0}\">{1}",
                            "/rssIcon.gif",
                            itemNodes[counter]["title"].InnerText
                            )
                        );
                }
                else
                {
                    htmlResult.AppendFormat(
                        "<a href=\"{0}\">{1}</a>",
                        itemNodes[counter]["link"].InnerText,
                        itemNodes[counter]["title"].InnerText
                        );
                }
 
                htmlResult.Append("\t\t</li>");
            }
 
            htmlResult.Append("\t</ul>");
        }
    }
    #endregion
 
    Literal output = new Literal();
    output.Text = htmlResult.ToString();
    this.Controls.Add(output);
}
else
{
    // NO RSS TAG
}
#endregion
 

While I could write about creating the property in EPiServer and wrapping it up all nicely.  I’ll be honest, it’s just a PropertyString, so not worth worrying about.  Ye sits rough and not very good at the error handling (as I eluded to above), but this is the easy bit.  I now have to go and port this back to EPiServer CMS 4.6!


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Tuesday, June 09 2009 at 01:50 PM by Matt Nield

I often get asked to provide a handy starting guide to new people joining the company/team.  It's pretty straight forward to find on the EPiServer World site if you look under the Get Started tab.

Just follow the link to Start Developing with EPiServer CMS 5 R2 for some articles explaining the basics and video presentations too.

I would also recommend having a look at Relate+, which is a great addition to EPiServer CMS for building community-themed web sites.  Again, there is some useful documentation about this in the Get Started tab under Start Developing with Relate+.

Enjoy!


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Friday, March 27 2009 at 08:52 AM by Matt Nield

I'm still fairly new to EPiServer, so I'm going through the process of a great many rookie errors whilst taking over a site from someone with vastly more knowledge of the product than me.

One issue I had recently was when I was creating a new stage server for a client so that they could test things out.  I went through a cobbled route of copying their live DB and live code and slapping them on to of a clean EPiServer install and hacking about in the web.config file to get it all working.  The in itself was a piece of cake.

I started getting problems when the AD users could not connect tot he site.  I checked and rechecked the LDAP settings in the web.config and they were all correct.  After a quick look on EPiServer World, I found an FAQ explaining the problem, though I could not manage to get the workarounds to provide the goods.

The problem is not caused by EPiServer, it is how the .Net framework deals with AD when it is not connected to the domain.  Now that I knew a little more about what the cause of the problem might be, I hit Google to try and find a resolution.  Eventually a came across this forum entry which gave a possible solution.  The long story short is that bay changing the Local Policy on the server and rebooting.

To make the change, follow the steps below:

  1. Go to 'Local Security Policy' on the server through the Administrative Tools.
  2. Expand 'Local Policies' and then click on 'Security Options' to see the list of security policies.
  3. Select the 'Interactive Logon: Number of previous logons to cache' policy.
  4. In the properties, set the cache value to 0.

This stops the OS for caching user details between logins, forcing the server to connect to the domain.  After quick reboot, this fixes the problem.

Related Links

http://world.episerver.com/en/FAQ/Items/The-trust-relationship-between-the-primary-domain-and-the-trusted-domain-failed/

http://www.techsupportforum.com/microsoft-support/windows-nt-2000-2003-server-2008-server/169618-disconnecting-domain.html


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Wednesday, March 25 2009 at 10:07 AM by Matt Nield

When you are first playing with table adapters you might get to see.  When you create your typed data set, Visual Studio will create an element in the generated XSD that contains the connection string that you were using.  This will more than likely not be the connection string that you want to use in your production environment.  So how do you go about changing it?  Well, if you start using the intellisense in Visual Studio, you will soon find that there is a 'Connection' property on the table adapter once you have created it. 

Great!  Lets set the connection string on that and well be done.  Ah, not so easy.  This will compile just fine, but as Connection is in fact an internal member, it is only available within the same assembly.  So if you are trying to access your data set from another assembly (which is often the case) you won't be able to set it.

I've seen a number of people asking for a way to resolve this, and luckily the solution is simple and can be resolved by taking the following steps:

  1. In the design view of the dataset, select the table adapter that you want to change the connection for.
    TableAdapter
  2. Open the properties of the Adapter (<F4> in Visual Studio) and change the Connection Modifier property to public.
    Properties

That should do it, you should then be able to use something like the following to change your connection:

string myNewConnectionString = "Data Source=(local);Initial Catalog=MyStore;Integrated Security=True";
TestDataSetTableAdapters.OrderTableAdapter ta = new DataSetTests.TestDataSetTableAdapters.OrderTableAdapter();
ta.Connection.ConnectionString = myNewConnectionString;

Job done.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Tuesday, March 17 2009 at 09:14 PM by Matt Nield

This was not the first time I've seen this error message in a web application.  Usually it happens on the development box and a quick re-compile gets rid of it quite easily.

I had it today an a staging box, so re-compile is not an option.  Looking at the fairly obviously generated file name, it's clear that this file is part of the ASP.Net compilation process, so that was the general area to look for a solution.

After a brief read about the Compilation Element in the web.config file on the MSDN library, I made a brief edit to my web.config so that the batch attribute is set to FALSE.  This makes ASP.Net compile stuff as and when it needs it, rather than trying to compile everything when the application starts.  So now my web.config contains the following:

<configuration>
  <system.web>
    <compilation defaultLanguage="c#" debug="false" batch="false">
      ...
    </compilation>
    ...
  </system.web>
  ...
</configuration>

It looks like for some reason the compiler was getting confused while trying to compile the entire site.  Changing this setting makes it compile things when theya re first required and seems to get rid of the error.

I've not managed to find a better solution or explanation from Microsoft about the issue, but it's gone away and that makes me happy.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Tuesday, March 17 2009 at 11:05 AM by Matt Nield

I've seen several posts today after an ex-colleague mentioned on their blog it not being easy to get the Management Studio for SQL 2008 Express once you've installed the engine only option of SQL Express.

There is a method of upgrade that Dan details to change the SQL 2008 Express version, but you can also download the Management Studio from Microsoft directly without upgrading your instance.  You will need Windows Installer Version 4.5 though :)

http://www.microsoft.com/downloads/details.aspx?FamilyID=08e52ac2-1d62-45f6-9a4a-4b76a8564a2b&displaylang=en


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Friday, March 13 2009 at 04:05 PM by Matt Nield

Many year ago I built an e-commerce solution where I was receiving the international currency code (I.e. GBP or USD) and had to use this to determine the currency symbol to display.  This was during the dirty days of ASP.Classic so I just slapped in a 'nice' little switch statement and that was that.

That is neither elegant or good, and now faced with a similar issue I decided to look in to the problem and get a nicer solution.

The Problem

I'm receiving ISO 4217 currency codes in my application and that application in itself is running under a current culture of en-US. 

Using this code, I need to determine the region or culture based information in order to display currencies to the end user.

The Solution

After a bit of looking about on the MSDN site at RegionInfo and CultureInfo I came up with the following LINQ query to return the RegionInfo:

string currencyCode = "PLN";
 
System.Globalization.RegionInfo regionInfo = (
    from culture in System.Globalization.CultureInfo.GetCultures(
        System.Globalization.CultureTypes.InstalledWin32Cultures
        )
    let region = new System.Globalization.RegionInfo(culture.LCID)
    where String.Equals(
        region.ISOCurrencySymbol, 
        currencyCode, 
        StringComparison.InvariantCultureIgnoreCase
        )
    select region).First();
 
Console.WriteLine(regionInfo.CurrencySymbol);

Alternatively, we can return the CultureInfo itself and use String.Format to do the work for us.

string currencyCode = "BRL";
decimal value = 19.99M;
 
System.Globalization.CultureInfo cultureInfo = (
    from culture in System.Globalization.CultureInfo.GetCultures(
        System.Globalization.CultureTypes.InstalledWin32Cultures
        )
    let region = new System.Globalization.RegionInfo(culture.LCID)
    where String.Equals(
        region.ISOCurrencySymbol, 
        currencyCode, 
        StringComparison.InvariantCultureIgnoreCase
        )
    select culture).First();
 
Console.WriteLine(
    String.Format(
        cultureInfo,
        "{0:C}",
        value
        )
    );

Job done.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Friday, March 13 2009 at 12:02 PM by Matt Nield

My time at Interakting / Business & Decision has come to an end and I am emigrating to South Africa in order to work with the EPiServer office in Cape Town. I'll make sure that all my blog posts here are kept up as long as possible, and be assured that once I've got myself sorted over there I'll carry on blogging directly on the EPiServer Labs site.

Until then - thanks for reading and, for the moment, this is me signing out!


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Monday, February 09 2009 at 11:44 AM by Dan Matthews

I was asked today how to go about downloading a file as a response to a server request.  I think last time I had to do that was in that days of ASP.Classic.

Anyhow, incase you are interested, the following code will allow you to download content through the browser and should bring up the browser save dialogue.

// Load a lovely file (yep - I'm not too concerned about permissions here) and
// read it into a buffer
FileStream fs = new FileStream(@"C:\TestXMLFile.xml", FileMode.Open);
long fileSize = fs.Length;
byte[] fileBuffer = new byte[Convert.ToInt32(fileSize)];
fs.Read(fileBuffer, 0, (int)fileSize);
fs.Close();
 
// Change the response headers
Response.ContentType = "text/xml";
Response.AddHeader("content-disposition", "attachment; filename=myXmlFile.xml");
 
// Write out the buffer
Response.BinaryWrite(fileBuffer);

The key part here is that we're changing the content type and the disposition header telling the client browser what it's expecting and what to do.  You can find more information on the Microsoft support site knowledge base: HOWTO: Raise a "File Download" Dialog Box for a Known MIME Type.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Friday, January 30 2009 at 04:52 PM by Matt Nield

I was recently working with a client to deploy an EPiServer site and we came across a rather strange problem. The EPiServer Manager installed fine, but when I tried to set up a web site (with a database or not it doesn't matter) we were getting the following error reported:

System.InvalidOperationException: The installation failed, and the rollback has been performed. ---> System.IO.DirectoryNotFoundException: The system cannot find the path specified. (Exception from HRESULT: 0x80070003)

   at System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.PutEx(Int32 lnControlCode, String bstrName, Object vProp)

   at System.DirectoryServices.PropertyValueCollection.OnClearComplete()

   at System.Collections.CollectionBase.Clear()

   at EPiServer.Install.IIS6.DirectoryEntryExtension.SetValue(DirectoryEntry entry, String propertyName, String value)

   at EPiServer.Install.IIS6.DirectoryEntryExtension.CreateSite(String siteName)

   at EPiServer.Install.IIS6.Installers.NewWebAppInstaller.Install(IDictionary stateSaver)

   at System.Configuration.Install.Installer.Install(IDictionary stateSaver)

   at System.Configuration.Install.TransactedInstaller.Install(IDictionary savedState)

   --- End of inner exception stack trace ---

   at System.Configuration.Install.TransactedInstaller.Install(IDictionary savedState)

   at EPiServer.Install.InstallationManager.DoInstall()Error - System.Management.Automation.CmdletInvocationException: The system cannot find the path specified. (Exception from HRESULT: 0x80070003) ---> System.IO.DirectoryNotFoundException: The system cannot find the path specified. (Exception from HRESULT: 0x80070003)

   at EPiServer.Install.InstallationManager.DoInstall()

   at EPiServer.Install.InstallationManager.CommitBulkInstall()

   at EPiServer.Install.Common.Cmdlets.CommitBulkInstallCmdlet.ProcessRecord()

   at System.Management.Automation.Cmdlet.DoProcessRecord()

   at System.Management.Automation.CommandProcessor.ProcessRecord()

   --- End of inner exception stack trace ---

   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input, Hashtable errorResults, Boolean enumerate)

   at System.Management.Automation.Parser.PipelineNode.Execute(Array input, Pipe outputPipe, ArrayList& resultList)

   at System.Management.Automation.Parser.StatementListNode.Execute(Array input, Pipe outputPipe, ArrayList& resultList)

The last line that had worked before the error was thrown was 'Copied connectionStrings.config' and after some digging around it became apparent that the error was being thrown after the EPiServer Manager had finished copying files to the web site folder and when it was trying to create the actual web site in IIS. It was an extremely frustrating problem to track down and we tried security permissions and all sorts with no luck. There is a fair bit on the web about this error (default site missing in IIS and similar things like that) but nothing was helping.

I was pretty sure it was not EPiServer itself at fault so I dug in the EPiServer and System.DirectoryServices assemblies with Reflector and figured out what was going on, then built a small test app in .Net. This also failed with exactly the same error... when .Net tried to access the IIS Metabase it was failing.

Turns out that System.DirectoryServices uses COM Interop to clear and set values within the IIS Metabase. This is what was breaking. There is a way of manipulating them using AD-style classes and that seemed to work fine, so that meant it must be something up with the way .Net was talking to IIS via COM.

The client helped out here because one of their technical guys on the server team had the brainwave of reinstalling Component Services. Hey presto, it worked - thanks Jeremy :) So if you have a similar problem, I suggest you try reinstalling COM and IIS first before getting serious with permissions and things.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Friday, January 30 2009 at 12:12 PM by Dan Matthews

I've been thinking a bit about why EPiServer hits the 'sweet spot' for companies so nicely, and I think maybe the answer lies in its balance of feature coverage and market position. It knows where its strong point is - Content Management - but doesn't ignore the other areas. It also aims at the mid-market but is capable of scaling up or down, which is a sadly neglected approach. So many companies are being forced to choose between an self-declared 'Enterprise' solution or a self-confessed 'Entry Level' solution. Problem is, the Enterprise solutions are over-specified and over-priced for their needs, and the Entry Level solutions might meet the budget but don't meet the requirements. This can be summed up in this diagram:

The_EPiServer_Triangle

What do you think? Do you think this is a good summary or do you entirely disagree?


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Friday, January 16 2009 at 11:23 AM by Dan Matthews

Having recently been subject to a number of rounding issues in an application, we've had to take a closer look at how rounding works in the .Net framework.

It seams that when using Math.Round(), there is an overload that allows us to specify the type of rounding that is used in the form of the MidpointRounding enumeration.

 

As the Microsoft documentation will tell you, there are two possible values we can choose from:

  • ToEven: Round to the nearest even number.
  • AwayFromZero: Round to the nearest number away from zero.

This proves to be quite interesting when you start thinking about it in a little more detail.  I was generally taught at school that you usually round up to the nearest number so that 0.5 becomes 1, -4.5 becomes for and so on.  This is not the case in .Net it would seem and I find it a little surprising that it has taken me this long to notice.

If you write a little console application in Visual Studio, you can take a look at how this works:

            Console.WriteLine(
                "Value   Default   Even   FromZero"
                );
            for (decimal myValue = -2.0M; myValue < 2.0M; myValue += 0.1M)
            {
                Console.WriteLine(String.Empty.PadLeft(35,'-'));
                Console.WriteLine(
                    "{0}   {1}   {2}   {3}",
                    myValue.ToString("0.0").PadLeft(5),
                    Math.Round(myValue, 0).ToString("00").PadLeft(7),
                    Math.Round(myValue, 0, MidpointRounding.AwayFromZero).ToString("00").PadLeft(4),
                    Math.Round(myValue, 0, MidpointRounding.ToEven).ToString("00").PadLeft(8)
                    );
            }

The following table give you an idea of how these work for some values.

Value Round to Even Round Away from Zero
0.4 0 0
0.5 0 1
1.4 1 1
1.5 2 2

 

The interesting point is that the default value for Math.Round when not specified is ToEven which is not really what I would have expected.  I was also a little intrigued to find that there is not provision of a TowardsZero value.  Having a look at Wikipedia, there are numerous methods of rounding and they give a handy list of which languages make which preference.  .Net favors what Wikipedia calls 'Round-half-even', which is MidpointRounding.RoundToEven.  It's sometimes refereed to as Banker's Rounding.

This clearly is not a massive revelation, but when you start to deal with systems that need to perform calculations and correlate the results of those calculations with other, less-precise systems you should take note of how you will be rounding as checking this out early can prevent headaches later.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Wednesday, December 17 2008 at 12:41 PM by Matt Nield

I am currently working on a project where it was necessary to conditionally inject some content into certain properties on some pages. Dynamic Content didn't really help me because what I wanted to do was replace entire properties with content from a property on another page and do it in a nice way for the editor. Linking the page with a shortcut to another page didn't help me because it needed to be only a partial replace and also conditional.

Here's an example - and I know there are better ways to do this but I want an example that won't compromise the Intellectual Property of what I am actually doing :)

Lets say you have a news article at http://myepisite/News/SomeArticle. The article has a nice big image on it and you want to be able to swap the image out with a different one (lets forget the fact that you'd probably just do this with two properties). You have a sub-page storing the smaller image in a property at http://myepisite/News/SomeArticle/LowImagery, which is hidden from the site. The way that you trigger the load of the low image is by URL QueryString, e.g. http://myepisite/News/SomeArticle?bandwidth=lo. (If you want some more tips on achieving this URL neatly, see my posts or other posts on URL rewriting.) Anyway, you could write a custom property type etc. to do this, but that's a fair whack of work and you'll need to create a new custom property for every content type that you might want to replace.

So how do I achieve this in a neat, generic way? EPiServer provides a nice way, but it's not the most well documented route and neither do they really recommend it. Still, I think it can work well if properly implemented. The way I implemented to achieve this was using a custom Property Get Handler.

When EPiServer asks for a page, it builds a PropertyDataCollection of all the properties on that page, along with their values. This PropertyDataCollection contains all the user-defined properties along with some that EPiServer add in as well such as PageLink, PageLanguageBranch and others. These are absolute lifesavers, although they are not well documented. The PropertyDataCollection has a default indexer which, when called, calls to a helper method to get the actual PropertyData for a property. The default helper method is a static method called 'DefaultPropertyHandler' on EPiServer.Core.PropertyGetHandler. This helper method looks for the the actual property data in four stages:

  1. It looks at the property on the current page and the current language
  2. If that is empty, it checks to see whether the property is language specific and, if it is, whether the current language is the master language. If not, then it grabs the master language page and returns the value from that property.
  3. If language isn't an issue, then it tries to get the property value from the linked page, if any.
  4. If there is not data on a linked page, then it tries to return a dynamic property value with that property name.

This works well and is the default that probably fits 99% of EPiServer installations. However, EPiServer kindly allow us to replace this default Property Get Handler. All you need to do is write your own method that matches the delegate for the handler, and then set an EPiServer property like so:

EPiServer.Core.PropertyDataCollection.GetHandler = new GetPropertyDelegate(Test.BandwidthPropertyGetHandler.BandwidthPropertyHandler);

I'm sure you can set this in most places where you need it, but I just put it into the Application_Start of Global.asax.cs. So we can see how easy it is to override the property handling, but what does our custom method actually look like? The following code is incomplete, untested and partially commented out, but it should give the idea. The two parameters coming in are the property name being queried for data and the property data collection for the current page/language. Notice that rather than use the default indexer for properties, when asking for a property data value I am explicitly calling the 'Get' method - this prevents nasty infinite loops where my custom handler keeps calling itself.

namespace Test
{
    public static class BandwidthPropertyGetHandler
    {
        // Methods
        public static PropertyData BandwidthPropertyHandler(string name, 
PropertyDataCollection properties) { // check querystring to see if we need to replace property (where possible) HttpRequest Request = System.Web.HttpContext.Current.Request; if (Request.QueryString["bandwidth"] == "lo") { // we need to swap low bandwidth if it's the right property name // you could drive this any way you like - don't hardcode it in production :) if (name == "ArticleImage") { // lets reach out and grab the data from the sub-page PageReference ThisPageReference = (PageReference)properties.
Get("PageLink").Value; PageDataCollection ChildPages = EPiServer.DataFactory.Instance.
GetChildren(ThisPageReference, LanguageSelector.MasterLanguage()); foreach (PageData ChildPage in ChildPages) { // find an article subpage if (ChildPage.PageTypeName.ToLower() == "article subpage") { // grab our property and return it return ChildPage.Property.Get("ArticleImageLow"); } } } } // just return the default handler return PropertyGetHandler.DefaultPropertyHandler(name, properties); } } }

In my actual implementation I handle languages properly, error handling, null property values and all sorts of other things, but it should be fairly obvious how that would work. In essence, this is a very simple way of customising properties to make them do fairly clever things without customising property types themselves. In fact, this would be a nice way to retro-fit a feature such as bandwidth tailoring or other targeted content to an existing type. Just remember that if it's not a special case you should be handling, call the default handler to do it's stuff with that property! Also, it might be best to try to keep your injected property types the same as the property type on the owner page. Not sure what would happen if you messed with that.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Tuesday, December 09 2008 at 12:42 PM by Dan Matthews

I needed to throw together a quick geolocalisation demo for EPiServer v5 R2 the other day and to do that it was necessary to override some of the default URL rewriting behaviour of EPiServer. I knew it could be done, but I'd never actually had to write a custom URL provider before, so Ted Nyberg's blog post on rewriting in EPiServer gave me a good kick-start.

My geolocalisation changes worked a treat (maybe I'll blog about that another time) but I did come across one really nasty 'feature' in EPiServer. I did find a workaround though, so I'll share it with you. Some background first though.

As you may know, EPiServer has the nice ability to add a file extension on to pages. Before you rush off and try this out on your live site, be aware that it does change the default behaviour a little, for example it stops trailing slashes from working on the URL, e.g. this works:

http://myepisite/SomePage/

...but this does not...

http://myepisite/SomePage.htm/

In fact, I like this feature because when using an external cache provider (such as Akamai), page extensions are A Good Thing as it knows how to treat them, and it also reduces the number of a URL 'possibilities' for a single page, so reducing the cache usage. As a bonus, it can also help with security as it slightly abstracts the page engine from the URL. Why not use the extension 'cfm' and then watch and laugh as all the ColdFusion-specific attacks roll in :)

So I set an extension on my geolocalisation demo of '.htm' (done in the urlRewriteExtension property of the site settings element in Web.Config, make sure you put the dot in the extension as well otherwise you'll get SomePagehtm). So far, so good, and the out-the-box demo templates site appeared to run fine. But then I noticed a weird quirk. On the menu across the top, the various links made sense, for the most part:

News -> http://myepisite/en/News.htm

Events -> http://myepisite/en/Events.htm

and so on... but the Start link was all messed up:

Start -> http://myepisite/en.htm

What was strangest of all though was that this link actually worked! This made no sense on any level, and it was obvious that some internal fudge in the default URL rewriter was catching this as a special case. This was confirmed when I found this post from EPiServer support. They'd obviously found this 404'ing so built a special case for it.

So why do I care? Because this breaks the URL model and breaks my geolocalisation scheme quite badly. That link should 404 or else I have an issue. Ideally, I want to actually write out the proper link. So I started digging. It turns out that you get a link like this when you have an EPiServer Start Page and ask for the LinkURL for it. The default URL rewriter seems to munge it up and spit out this crazy short URL rather than a nicely formatted link. This is the same for any language, for example the Swedish start page gives sv.htm. Ideally though, I would want it to write out something like this (the page is actually called Public in the English version):

http://myepisite/en/Public.htm

I mean OK, it looks like any other page rather than a start page but surely that's better than en.htm! So... how do we go about getting the right page link rendered out and bypassing EPiServer's little 'fix'? Well, we can do it with the URL rewriter. I'll let Ted's post explain how to actually create the URL rewrite provider, but once you have the rewrite provider ready, you can override the ConvertToExternalInternal method as follows:

protected override bool ConvertToExternalInternal(UrlBuilder url, object internalObject, Encoding toEncoding)
{
    // apply default rewriting first
    bool bRewriteSuccess = base.ConvertToExternalInternal(url, internalObject, toEncoding);

    if (bRewriteSuccess)
    {
        string[] urlSplit = url.Path.Split('/');
        
        if (urlSplit.Length == 2)
        {
            // default page

            string DestinationCountryCode = urlSplit[1].Substring(0, 2);

            EPiServer.Core.PageData StartPage;

            try
            {
                StartPage = EPiServer.DataFactory.Instance.GetPage(
new EPiServer.Core.PageReference(EPiServer.Configuration.Settings.Instance.PageStartId),
new LanguageSelector(DestinationCountryCode)); } catch { // no page with that language, just grab the link anyway and it will
still work just with the current language name
StartPage = EPiServer.DataFactory.Instance.GetPage(
new EPiServer.Core.PageReference(EPiServer.Configuration.Settings.Instance.PageStartId)); } url.Path = "/" + DestinationCountryCode + "/" + StartPage.URLSegment +
EPiServer.Configuration.Settings.Instance.UrlRewriteExtension; } } return bRewriteSuccess; }
This is not a fully-tested solution and it might need more work, but it shows that it is possible to fix this troublesome default behaviour. My geolocalisation demo then wrote out links as I would expect, and seemed to work perfectly across languages too. Hope this is of some use to anyone with similar issues even if it only gets you started on a fix!

Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Friday, December 05 2008 at 11:53 AM by Dan Matthews
A friend working at Graphico of my recently sent me some SQL that purposed to look for missing indexes in you databases.  It pretty much sat in my inbox for a while until I had time to look at it (which I have just done).

It was a great little script and proved very useful in identifying performance improving indexes that we could include in the database that we're developing.  I asked my friend where the SQL was from and he pointed me to the article in question on the MSDN site, which you can find here:

http://msdn.microsoft.com/en-us/magazine/cc135978.aspx

It really is worth a read and has some very interesting stuff in it.  Cheers for that, Paul - most useful!

Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Tuesday, December 02 2008 at 09:53 AM by Matt Nield

I've found a bug with IE8 Beta 2 (in both IE7 and IE8 browser modes) where list boxes that, although disabled but containing selected items, do not show the selected items. Here is an example of what should be displayed

For those of you who are not using IE8 Beta 2, here is what it appears like:

I have logged the bug on their forums at http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.internetexplorer.beta&tid=55a9ace5-380d-408c-aa54-2d997de1f245&cat=〈&cr=&sloc=&p=1 so read and vote if you've found this to be a problem too!


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Thursday, November 27 2008 at 12:01 PM by Dominic

I've just managed to get the .NET 3.5 style of WCF Web Programming Model services to work inside an EPiServer 5 R2 site on IIS 7 and Windows 2008.  I had a few difficulties finding out how to integrate the new model into IIS/ASP.NET and then further problems getting it working in EPiServer.  Here, I outline the solution.

Context

I'm currently designing a site that will be using the Akamai Edge Suite of technologies (www.akamai.com) and so I desire that all client access is through the caching layer.  Additionally, I'm motivated towards a REST model for web services to support a greater degree of caching.

The new WCF Web Programming Model is ideal for this purpose as I can wrap service parameters directly into the URL and reduce the coding effort considerably.  I had been concerned about the integration of services into the same website as EPiServer because of how the URL mapping works in the Web Programming Model.

Solution

The solution is really easy once you realise that the typical EPiServer installation changes the default ASP.NET configuration.  Specifically, you may need the following:

  • Create a new folder to host your services
  • Create a small web.config in this folder (or use location tags in the main web.config file) and add service handlers
  • Create a ".svc" file for the service
  • Create the supporting .NET service code

Create a new folder to host your services

This is necessary to allow a separate application configuration.  You can change the main application configuration at your own risk, however :)

For the purposes of this post, I'll use "~/services/".

Create a small web.config for this folder and add service handlers

You'll need to add the following:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="svc-ISAPI" path="*.svc" verb="*" modules="IsapiModule" 
           scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll"
           resourceType="Unspecified" 
           preCondition="classicMode,runtimeVersionv2.0,bitness32" />
      <add name="ServiceHost" path="*.svc" verb="*"
           type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel,
                 Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
           resourceType="Unspecified" preCondition="integratedMode" />
    </handlers>
  </system.webServer>
</configuration>

Now I took this from a cleanly created website with no configuration (using the IIS management console) and I recommend that you do the same.

Create a ".svc" file for the service

This file is created in the service folder and forms part of the URL so name it accordingly.  I'll just use "service.svc" for illustration:

<%@ ServiceHost Language="C#" Service="Service" CodeBehind="~/App_Code/service.cs"
    Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>

You should name your services more appropriately, of course.

Create the supporting .NET service code

So, you need to create the classes.  Here, I'm using a simple file in the App_Code folder, but you might prefer to use a separate code project and assembly.  Here's a simple example:

using System.ServiceModel;
using System.ServiceModel.Web;

[ServiceContract]
public interface IService
{
  [OperationContract]
  [WebGet(UriTemplate = "test?s={s}")]
  string test(string s);
}

public class Service : IService
{
  public string test(string s)
  {
    return "test: " + s;
  }
}

So, this is a very basic service with a single HTTP GET method that returns some data dependent on a single query string parameter.  A perfect REST example as the result is defined by the input, there is no change of state (so two identical GET requests result in the same value) and so the response is suitable for caching.

Using the service

So now, you can access the service as http://your_episerver_site/services/service.svc/test?s=YourTestString.  ASP.NET integration (and IIS) requires the use of a service extension, in this case ".svc", however this article may help you to remove this issue: http://blogs.msdn.com/bags/archive/2008/08/22/rest-in-wcf-part-ix-controlling-the-uri.aspx but don't forget that EPiServer already does some URL rewriting and so you'll have to make sure they don't conflict!

Metadata


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Thursday, November 20 2008 at 05:10 PM by Stephen Horsfield

One of IE8's new features is a that when closing a window or tab, it can remember the session ID and therefore maintain the session with a website. This is an advantage if you accidentally close a window or tab, but there is a problem.

For example, if you have several logins for a site, each login giving totally separate functionality of the site (e.g customer and administrator), then you may close your browser and login as someone else. What you may find is that when you open a new window, you are already logged in as the other person. Why does this happen?

IE8 seems to use the first window a storage mechanism for sites visited in this browsing session. When visiting a site, the unique Session ID is generated and then stored in this host process. When opening new tabs and windows the new process checks the host process to see if the website has been visited and if so returns the existing session ID.

So to re-iterate, if you have at least 1 browser window open, all subsequent tabs and windows pointing to a specific site will all generate the same session ID.

In order to get around this "problem", you should close all instances of IE8. The session information seems to be stored in memory rather than on disk, so by closing all of these instances, the problem goes away.

This serves as a warning to both developers and kiosk/Internet café users. Developers should provide the ability to log out of a site so that the Session is cleaned up after a user logs out. Kiosk/Internet Café users should close ALL Internet browser sessions down before leaving!


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Thursday, November 20 2008 at 09:15 AM by Dominic

The 3 types of connections Silverlight can make are:

  • Connections to web services and WCF services
  • HTTP requests (via HttpWebRequest and WebClient)
  • Raw data transfers

When building one of your early applications, you may choose to try out one of these classes to get back a really simple piece of HTML, purely to test the connection. For example:

protected void Button_Click(object sender, EventArgs e)
{
    WebClient wc = new WebClient("http://www.google.com");    
    wc.DownloadStringAsyncCompleted += new EventHandler<DownloadStringEventArgs>(wc_DownloadStringCompleted);    
    wc.DownloadStringAsync();
}

protected void wc_DownloadStringCompleted(object sender, DownloadStringEventArgs e)
{
    if(e.Error == null && e.Cancelled == false)  
    {        
        Debug.WriteLine("Data downloaded = " + e.Result);    
    }
}

(N.B I apologise if this doesn't compile, I've just typed this by hand.)

If you run this, you'll find it generates a SecurityException, but why?

To improve security, the only connections you can make without any security implications is your own website. If you want to call another website, Silverlight needs to check a few things. Firstly, it looks for a policy file called "clientaccesspolicy.xml", which is a file used by Adobe Flash to find out if it allows connections from Flash applications. If this file is missing, it then looks for "crossdomain.xml", which is a Silverlight version of this file.

  • If one of these exists AND the policy file allows connections, then the application will be allowed to connect.
  • If neither exists, or the policy in an existing file denies access to the requested virtual directory, then a SecurityException will be thrown by the application.

To overcome this problem, you have 2 options

  1. Check the website has an API to use the capabilities you are after. Google and Digg have service APIs in order to allow applications to do this.
  2. Write a web service (or WCF service), that does the enquiry for you.

If you need to see the contents of these files, I have found Fiddler an excellent tool for this purpose.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Monday, November 17 2008 at 12:48 PM by Dominic

EPiServer Norway are associated with an EPiServer community project called EPiCode which had its annual awards on the 12th of November as part of the Christmas Tech Forum. I was really pleased to see the Module of the Year award went to my pals over at NetworkedPlanet for their EasySearch module. Unlike some of the other modules on EPiCode, it isn't free to use commercially - but it is free to download and try out and fills a nice gap in the EPiServer search space.

A bunch of other 'active contributors' were lucky enough to get an iPod Shuffle in the awards - including me for contributing CloudCuckoo and HyperThumbnail on behalf of Interakting. Thank you EPiServer Norway!

You can read more here.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Monday, November 17 2008 at 12:35 PM by Dan Matthews

I put my VPC's on my external hard disk and run them off there, as the hard drive can run independently of Windows.

I've noticed over the past few months, that randomly, my external USB 2.0 hard drive (Freecom 400GB) disconnects for no reason and I get a balloon in the system tray with the title "Delayed Write Problem" , then something to do with G:\$MFT or G:\$Bitmap.

Yesterday, I was defragmenting my external hard disk and noticed it kept happening. I turned it off and on again, started defragmenting and the same problem happened.

I thought it might be the writing caching, which helps improve performance, so when viewing the properties of the drive (My Computer -> [External Hard Disk] -> Right-click Properties -> Hardware -> Properties -> "Enable write caching on the disk"), I turned this option off.

Another defragmentation session and the same problem happened again and again.

What I finally realised was that I was using some software (DAEMON Tools Lite) for mounting ISO's to a CD drive. Although the software wasn't running, I still had the CD drive present in my drive listing. I loaded up DAEMON Tools Lite and turned off the emulated CD drive (which I wasn't using anyway) and HEY PRESTO! it was working.

I defragmented half the drive and then turned write caching back on and it was fine!

Hope this helps someone, as when a hard drive disconnects and a VPC is running off it, you are in trouble!


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Wednesday, November 12 2008 at 09:23 AM by Dominic

Introduction

Interakting use both Open Source and proprietary products to deliver solutions for many companies. We always try to select the best tool for the job, and when it comes to Content Management it is no different. We have a range of tools we consider using including various Open Source tools (e.g. Nuxeo, DotNetNuke) and also our proprietary offerings (EPiServer, ADXSTUDIO). In the context of many projects it would certainly be possible to deliver a ‘successful’ project in either a proprietary or an Open Source solution. However, when we consider budgetary, functionality, deadline, support and longevity constraints, all of these areas are problematic in the Open Source arena, whereas proprietary systems such as EPiServer can provide an arguably better and more cost-effective solution. This article discusses some of the reasons for this. The majority of 'pure CMS' sites we deliver are on the EPiServer platform and so this will form the basis of our discussion. Interakting is an EPiServer Solution Partner.

Budgetary

With a proprietary CMS such as EPiServer, the main costs are ‘up front’. The client would be buying a licence to use EPiServer CMS, and the cost of this covers the effort and time taken by the vendor to develop and support the product. This means that the vendor does not need to find other ways to recoup their costs beyond the licence fee and an optional small annual support fee. The client can therefore budget for the outright licence as a clearly transparent and defined cost.

Open Source costs are far less clear, as companies who ‘own’ an Open Source initiative may give the software away ‘free’ but then seek to recoup their costs, even if only running costs. This is usually done by support contracts, consulting or selling additional ‘modules’. It is easy to be trapped into a ‘free’ product and then find that the actual cost is far higher.

Functionality

As proprietary systems are designed to be sold as widely as possible to reach the maximum number of customers, functionality in proprietary systems is usually excellent and if additional functionality would assist their sales then the company owning the product will often update their core product or provide value-add modules at low or no cost. This is very much the case with EPiServer, who have grown rapidly due to their responsiveness to customer demands and now have many thousands of seats worldwide. The CMS is particularly user-friendly and intutitive and can be used by novice users without the need for costly training.

In the Open Source arena this becomes more complex. The popular view is that the community ‘works together’ to build a product for the good of the community. This works well, to a point, but ultimately people are not entirely altruistic. Sooner or later (and sometimes always) they only contribute to things that benefit themselves. This means that the ‘out of the box’ product is often minimal functionality, and even if it is fairly well featured then those features are often not very flexible and designed for the use of the company that commissioned them with specific needs. It is unlikely the community will help add or update functionality and therefore it is left to the project team to do so, which can be fairly hard and time consuming. User training is likely to be required, particularly post deplyoment when users change jobs and new users need to work with the CMS.

Deadline

As a general rule, any proprietary systems must be designed to provide a very rapid solution as this is a key selling point since the market is very competitive and unforgiving. In this regard EPiServer stands up very well which is one of the many reasons that Interakting has selected this tool. The well-featured out of the box nature of EPiServer, together with the well-documented and supported APIs, mean that a robust solution can be built rapidly and efficiently. The tools are built with the clients business needs clearly in mind as much as the developers.

In an Open Source project, it has generally built by developers with a very code-centric approach. There is an expectation that the basic product will be customised by developers as needed, and the out-of-the-box functionality capability is usually minimal. Even with ‘starter’ kits for a particular tool, there is often a large amount of code and customisation to be done. Agencies promoting open source solutions capitalise on this aspect as it is very lucrative to develop the added functionality needed for more complex reqirements such as multi-lingual non-Latin support

Support

With EPiserver, as part of the licence agreement, the vendor undertakes to provide support and their reputation relies on this support being accessible and effective. The support is also usually rapid and efficient to respond with managed Help Desks staffed by knowledgeble individuals. They are able to respond with authority on support issues as they designed, wrote, maintain and own the codebase.

For an Open Source tool, the support is either an expensive add-on from the company providing the tool or is community based. If a company is supporting a tool this is often not so much of a problem, although there is an issue that they are supporting code that they quite possibly did not write. From our experience (remember that we also work with Open Source solutions when we feel it appropriate), support from the community is often slow and inadequate for projects that have a critical path.

Longevity

EPiServer is committed to the products they sell and even if they discontinue a product will generally provide migration or upgrade paths. Generally speaking, it will also be clear in advance whether a product will be passing out of support and therefore a proper exit or migration strategy can be planned well in advance. EPiServer is also helpful in that, in the event of it ceasing to trade, it has made its code available to its licensees through an escrow arrangement at a nominal annual cost (although this is optional).

Open Source projects are often left unfinished or unsupported once the community using them has moved onto something different. As a general rule, Open Source projects have a limited time in which they are actively updated and maintained and once a critical inactivity threshold is reached then they effectively become ‘legacy’, are taken into closed source or amalgamated into something larger. It can also be harder to plan an exit strategy as the ‘lifetime’ of a product is usually unclear.

Summary

In summary, we believe that for the many projects, the unknowns and variables involved in taking the Open Source route will result in a slightly higher initial cost of development and deployment and a significantly higher cost of ownership over a two year period following the initial go-live.

By choosing to use a well-proven CMS which uses the .NET framework, a project is grounded on a solid, well defined and tightly costed product and the real cost of deployment and support over a 2-5 year lifetime can be estimated with a far higher degree of accuracy. Ongoing maintenance, functional enhancements and support will also be easier to define and budget. Finally, a large pool of .NET developers able to work with EPiServer and are readily available at competitive day rates meaning the client has total flexibility and would not be locked into any single supplier in the future.

If you're looking for a CMS solution for your web site, shouldn't we be talking?


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Tuesday, November 11 2008 at 10:58 AM by Dan Matthews

Last night I was at a BCS Young Professionals Group meeting at the BCS offices in Southampton Street, London. The meeting was part of a 'SkillCentre' series being run with the help of a consultant called Anthony Rees facilitating, and the subject last night was 'Negotiation Skills'.

The session itself was excellent, culminating in groups coming up with a simple mnemonic to remember some basic concepts for negotiating. The group I was in came up with the mnemonic 'winwin':

What do you want

Investigate feasibility

Note it down

Walk in their shoes

Identify tactics

Negotiate!

Another group came up with the 'winning' mnemonic of 'KPMG', which raised a chuckle. I'm not sure I can remember it exactly, but it went something like:

Know

Prepare

Maximum (& minimum)

Goals

Personally, I found it memorable but less useful. But that's probably just me being biased. Following the main session there was a chance to network over wine and nibbles which was just as valuable as the session itself. And kudos to the BCS for putting on a nice Chilean Merlot :)


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Thursday, October 16 2008 at 10:36 AM by Dan Matthews

After various conversations on both internal and external projects, I’ve noticed that some of our web projects were being developed using a Session state called InProc.

InProc means In-Process, so IIS is hosting all of the

Session[“Dom”] = “Idiot!”; 

variables. Now, if the web application eats up too much memory, IIS 6 and above can be configured to recycle the Application pool – a contained unit of web sites, in order to free up memory. This is good for IIS but baaaad news for your website, as everything in the Session is lost – that could be shopping basket, current order status, user details! InProc is a bit of a quick and nasty method of developing as it just does its job, assuming that you are not going to host this to a larger audience (over about 5 users).

As I found out with any large project, nothing goes to plan, so, the best thing to do is to use StateServer and not InProc – but WHY?

StateServer is a totally out-of-process service that runs on either the same web server or a different server entirely. Session data is saved to this service so if the AppPool recycles, you have no problems whatsoever. Also, the data needs to serialize properly in order for it to be saved to the service.

Whats the point I hear you ask? Well, the point is that if you use InProc and your application gets load balanced (often without your knowledge), the website won’t work properly. Remember, load balancing is decided, by either the hardware or the software, to help manage the network traffic to a destination server. So 1 request to go to Server1 and another or Server2, or even ServerX! Youch! So your site’s Session could be stored on another machine.

StateServer works because all of the web.config’s point to the same machine, so they all work off that one service.

The other option is SQLServer, which stores it in SQL Server, which is more for web farms (multiple physical PCs), rather than web gardens (multiple virtualized PCs). Or you can use Custom for a custom implementation (e.g ODBC or XML), or Off to turn it off completely.

Therefore, a good recommendation is to always change your web.config to say:

<sessionState mode=”StateServer” … />

And start the ASP.NET State Service on your machine. This way to can always revert to InProc if you need to, but you are still ready for the switch over.

Believe me, it’s a lot easier to start out this way, rather than have to work backwards.

It is always a worthwhile exercise!


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Thursday, October 09 2008 at 03:35 PM by Dominic

When working on a project recently, the data saved back to the database was huge. We are talking well over 100 properties. After talking to my Java buddy, he said that one way is to create an IsDirty method that returns if the object has changed state.

The IsDirty() method is used to query the state of an object - if it has been modified or not. The implementation is up to the developer, but ultimately it's use can save you a trip to the data source.

I have split this example into 3 stages:

  1. First attempt
  2. Refactored
  3. Event Handled

N.B. This article helps someone in (archaic) .NET 2.0 - but if you've looking to develop for .NET 3.5, it might be worth looking into DependencyProperty's, which caters for this sort of problem.

First Attempt

The problem I found when prototyping this is that it can be quite impractical at first glance:

class Customer
{
    private string firstName, surname;
    public Customer(string firstName, string surname)
    {
        this.firstName = firstName;
        this.surname = surname;
    }

    public string FirstName
    {
        get { return firstName; }
        set 
        { 
            if( firstName != value )
            {
                IsDirty = true;
                firstName = value;
            }
        }
    }
    public string Surname
    {
        get { return surname; }
        set 
        { 
            if( surname != value )
            {
                IsDirty = true;
                surname = value;
            }
        }
    }

    public bool IsDirty { get; private set; }
}

 

This is a bit bloated. Also, it relies on every property having to check for itself whether it is equal or not, setting the IsDirty property and also assigning the value.

After writing this and implementing a few more properties I found this to be a bit too impractical. Instead, I realised that they are all basically doing 3 steps:

  1. Checking the previous value to the new value.
  2. Setting IsDirty.
  3. Assigning the new value.

This example needs simplifying - or refactoring to be more precise.

Refactoring

Instead, I decided to implement this behaviour in a method called SetValue<T>() , which would raise events when a property has changed. This allows the IsDirty property to be changed centrally and debugging to be centralized.

Firsty I created the method:

private void SetValue<T>(ref T varName, T value)
{
    if (varName.Equals(value))
        return;
    
    IsDirty = true;
    varName = value;
}

 

Now, we can change our properties to:

public string FirstName
{
    get {return firstName; }
    set
    {
        SetValue<string>(ref firstName,value);
    }
}

public string Surname
{
    get {return surname; }
    set
    {
        SetValue<string>(ref surname,value);
    }
}

This is one implementation of it, but I decided to extend it to event handling as well, so that even the outside world can be notified about what is changing.

Event Handling

I decided to also implement this is in a typical Microsoft fashion: OnPropertyChanging and OnPropertyChanged.

In order to turn this into an event driven model I need to do a few things:

  1. Create some event arguments describing what is being changed.
  2. Add some event handlers to trigger a notification that they have been changed.
  3. Trigger the events from within your code
  4. (Optionally) wire up the events.
  5. Trigger the events from within your code

Create event arguments

Since I am using events, I want to create event arguments detailing what has changed. I have implemented this in 2 identical classes (and 1 base class). Here I have implemented a base class, and 2 classes which improve the clarity of the base class. I have chosen clarity over code bloat:

//Base class implementation
public abstract class PropertyChangeEventArgs : EventArgs
{
    public string PropertyName { get; protected set; }
    protected object Value { get; set; }

    public PropertyChangeEventArgs(string propertyName, object before)
    {
        this.PropertyName = propertyName;
        this.Value = before;
    }
}

//Holds arguments before the proerty has changed
public class PropertyChangingEventArgs : PropertyChangeEventArgs
{
    public object ValueBeforeChange
    {
        get
        {
            return this.Value;
        }
    }

    public PropertyChangingEventArgs(string propertyName, object before) 
        : base(propertyName,before)
    {
    }
}

//Holds arguments after the proerty has changed
public class PropertyChangedEventArgs : PropertyChangeEventArgs
{
    public object ValueAfterChange
    { 
        get 
        { 
            return this.Value; 
        } 
    }

    public PropertyChangedEventArgs(string propertyName, object after) 
        : base(propertyName, after)
    {
    }
}

Create event handlers

Now implement some event handlers:

public event PropertyChangingEventHandler PropertyChanging;
public delegate void PropertyChangingEventHandler(object o, PropertyChangingEventArgs e);

public event PropertyChangedEventHandler PropertyChanged;
public delegate void PropertyChangedEventHandler(object o,PropertyChangedEventArgs e);

Trigger the events from within your code

Now I need to trigger these events from the SetValue<T>() method. I will also need to find out what property was called by this SetValue<T>() method.

private void SetValue<T>(T varName, T value)
{
       if (varName.Equals(value))
           return;

       //TODO: Find the property's name that is calling this method
       string propertyName = "MyProperty";

       if (PropertyChanging != null)
           OnPropertyChanging(this, new PropertyChangingEventArgs(propertyName, varName));

       varName = value;

       if (PropertyChanged != null)
           OnPropertyChanged(this, new PropertyChangedEventArgs(propertyName, varName));
   }

The last thing to do is to find the property that is calling this method. This can be done using Reflection, by looking up the call stack. By getting the previous "frame", we can deduce where this is being called from. In our case, this is called "set_FirstName". Remove the "set_" and we have our property name:

StackTrace st = new StackTrace();
StackFrame current = st.GetFrame(1);
string propertyName = current.GetMethod().Name.Replace("set_", "");

(Optionally) wire up the events

I want to subscribe to the OnPropertyChanged event, so that I can set the IsDirty property within it. I have done this within a private constructor:

private Customer()
{
   PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);
}

public Customer(string firstName, string surname) : this()
{
   this.firstName = firstName;
   this.surname = surname;
}

(Optionally) trigger the events from within your code

Now, I want to move the IsDirty assignment out of the SetValue() method because although overkill, it is not related to the setting of the value. It is related to the event but not the assignment. It also means that you have just wasted 15 minutes reading this article! :-) :

private void OnPropertyChanged(object sender, PropertyChangedEventArgs ea)
{
   IsDirty = true;
}

Summary

So what have we done? We've looked at ways in which we can implement notification within a class, so that we can save a database access. When getting to a large number of properties, we can bypass each save and also allow the outside world to be notified of its changes.

In the first example,we saw a cheap and nasty way of doing it, but impractical for larger classes. In the second example we saw a better implementation and in the third example we added event handling to extend the functionality further.

I hope this article helps someone - but if you've looking to develop for .NET 3.5, it might be worth looking into DependencyProperty's, which caters for this sort of problem.

Here is the full source code to have a play with:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Customer c = new Customer("Dominic", "Zukiewicz");
            c.FirstName = "Dommy dom dom";

            Console.WriteLine("Customer.IsDirty = " + c.IsDirty);

            Customer c2 = new Customer("Dominic", "Zukiewicz");
            c.Surname = "Zukiewicz";

            Console.WriteLine("Customer2.IsDirty = " + c2.IsDirty);
        }
    }

    class Customer
    {
        private string firstName;
        private string surname;

        private Customer()
        {
            PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);
        }

        public Customer(string firstName, string surname) : this()
        {
            this.firstName = firstName;
            this.surname = surname;
        }

        public string FirstName
        {
            get
            {
                return firstName;
            }
            set
            {
                SetValue(ref firstName, value);
            }
        }

        public string Surname
        {
            get 
            { 
                return surname; 
            }
            set
            {
                SetValue(ref surname,value);
            }
        }

        public bool IsDirty { get; private set; }


        private void SetValue(T varName, T value)
        {
            if (varName.Equals(value))
                return;

            StackTrace st = new StackTrace();
            StackFrame current = st.GetFrame(1);
            string propertyName = current.GetMethod().Name.Replace("set_", "");

            if (PropertyChanging != null)
                OnPropertyChanging(this, new PropertyChangingEventArgs(propertyName, varName));

            varName = value;

            if (PropertyChanged != null)
                OnPropertyChanged(this, new PropertyChangedEventArgs(propertyName, varName));
        }

        public event PropertyChangingEventHandler PropertyChanging;
        public delegate void PropertyChangingEventHandler(object o, PropertyChangingEventArgs e);

        public event PropertyChangedEventHandler PropertyChanged;
        public delegate void PropertyChangedEventHandler(object o,PropertyChangedEventArgs e);

        private void OnPropertyChanged(object sender, PropertyChangedEventArgs ea)
        {
            Debug.Print("Property: {0}, After: {1}", ea.PropertyName, ea.ValueAfterChange);
            IsDirty = true;
        }

        private void OnPropertyChanging(object sender, PropertyChangingEventArgs ea)
        {
            Debug.Print("Property: {0}, Before: {1}", ea.PropertyName, ea.ValueBeforeChange);
        }
        
    }

    //Base class implementation
    public abstract class PropertyChangeEventArgs : EventArgs
    {
        public string PropertyName { get; protected set; }
        protected object Value { get; set; }

        public PropertyChangeEventArgs(string propertyName, object before)
        {
            this.PropertyName = propertyName;
            this.Value = before;
        }
    }

    //Holds arguments before the proerty has changed
    public class PropertyChangingEventArgs : PropertyChangeEventArgs
    {
        public object ValueBeforeChange
        {
            get
            {
                return this.Value;
            }
        }

        public PropertyChangingEventArgs(string propertyName, object before) 
            : base(propertyName,before)
        {
        }
    }

    //Holds arguments after the proerty has changed
    public class PropertyChangedEventArgs : PropertyChangeEventArgs
    {
        public object ValueAfterChange
        { 
            get 
            { 
                return this.Value; 
            } 
        }

        public PropertyChangedEventArgs(string propertyName, object after) 
            : base(propertyName, after)
        {
        }
    }
}

Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Thursday, October 09 2008 at 11:57 AM by Dominic

When writing stored procedures or views, I always create them in Visual Studio (2005/2008) and then run them on a specified database. When using "SELECT *", it is compact, but obviously does not help you find the columns of the table or view.

When using the IDE, I added a new SQL Script for Stored Procedures, and then I typed:

SELECT *
FROM Customers

and a blue box surrounded the statement. I right-clicked -> Design SQL Block.

The designer then listed all of the column names for me, and when clicking OK, instantly put them back into the SQL script I was creating!

SELECT  CustomerID, CompanyName, ContactName, ContactTitle, 
Address, City, Region, PostalCode, Country, Phone, Fax
FROM Customers

For the table I was using, this list over 60 columns for me!

So if you want a quick way of listing all of the column names for table of view:

  1. Add a database project to your site (if you haven't already done so)
  2. Right click Queries -> Add SQL Script
  3. Choose Stored Procedure Script
  4. Type your SELECT * From XYZ statement
  5. Right click -> Design SQL Block
  6. Click OK.

The designer will be updated with the new query.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Wednesday, October 08 2008 at 04:13 PM by Dominic

Just a little note here that we noticed testing something (how it had not occurred before, I do not know).  We have a function that we were referencing from a referenced assembly that would format values to the slightly odd format being used by the ERP that we were talking too.  In  most cases it seamed to work OK, but for smaller values it didn't quite product the result we expected.

It turns out that the result of the Division functiod in BizTalk Server 2006 is a double.  The mapper being the way it is converts this to a string (assumably using .ToString()).  At least this is how it looks when I point ildasm.exe at Microsoft.BizTalk.BaseFunctoids.dll.

Now, rather simply put, I was being a fool and trying to convert this to a decimal and wondering what was going on.  I was passing what I though was a value of "0.00002" to my referenced method and expecting it to be formatted properly.  When we looked deeper in to the issue, we noticed that the value coming out was in fact "2E-05", which is how a float or a double would represent the value 0.00002.

 

Quick use of the double.TryParse() fixes this issue and off we trundle.


Worth keeping in mind, and also worth having a look at the base functoids using ildasm.exe when relying on their output.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Wednesday, October 01 2008 at 03:49 PM by Matt Nield

My XP laptop had ground to a halt - 6 months without a rebuild and it had got so clogged that it literally took 5 minutes just to boot. I needed to wipe it and start again but the head of our technical team offered me a fresh laptop with a clean Vista Business build. Deciding that being a guinea pig was a nice idea, I accepted it. The 4 gig of ram (up from 2 gig) was the sweetener that made up my mind for sure :)

As I was setting it up just how I wanted it, one of the things I needed to do was sync my two mobile phones with it. I have both an HTC 4350 (Herald) from work and my own personal HTC TyTN II. On my XP laptop I used ActiveSync to sync up my calendar, tasks and contacts.

Knowing that ActiveSync has been replaced on Vista, I was hoping for an easy experience. After plugging in my TyTN II, Vista offered to sync my media files. Fine, but I wanted to sync with Outlook so I cancelled the dialog and started my hunt. In Control Panel I found 'Sync Centre' which offered to sync my media files again. This was getting annoying. Contacts and/or Outlook were mentioned nowhere.

Maybe the 'Windows Mobile Device Centre' in Control Panel was my best bet? Nope. That just had settings on whether I wanted to connect via USB and Bluetooth or not. Nothing about syncing. Googling didn't help me that much. There doesn't seem to be much info about this. Is it that obvious? Am I missing something?

Actually, I was missing something. The latest download of Windows Mobile Device Centre (currently 6.1 as I write). This is basically what ActiveSync used to be, and syncs up all the bits and pieces you'd expect with Outlook. In fact, it's very smart and clean and appears to be a nice improvement on ActiveSync.

I thought it worth blogging this for two reasons. Firstly, hopefully this will get indexed so that it can be a quick help to others who were in the same boat as me. Secondly, is this part of the problem with Vista? It's not exactly intuitive that you have to install an updated version of a Control Panel applet to be able to sync (although behind the scenes it's more than that, of course). It almost seems that the out-the-box install is half baked. And the help isn't much help.

It's possible that I still missed a trick, of course, and if I have done then please feel free to comment here and set me straight!


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Wednesday, October 01 2008 at 10:37 AM by Dan Matthews

When trying to access remote content in Silverlight, you need to add a clientaccespolicy.xml file to the root of the web server that you are trying to access.  I did this, my file looked like this:

<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
    <cross-domain-access>
        <policy>
            <allow-from http-request-headers="*">
                <domain uri="*"/>
            </allow-from>
            <grant-to>
                <resource include-subpaths="true" path="/"/>
            </grant-to>
        </policy>
    </cross-domain-access>
</access-policy>

So essentially, anyone can access this.

I wrote my code to retrieve the information in a C# console app, just to test it out the WebClient as follows:

using System;
using System.IO;
using System.Net;
using System.Linq;
using System.Xml;
using System.Xml.Linq;

namespace GetBlogContentTest
{
    class Program
    {
        static void Main(string[] args)
        {
            WebClient w = new WebClient();

            string result = w.DownloadString(new Uri("http://blogs.interakting.co.uk/MainFeed.aspx"));
            
            if (!String.IsNullOrEmpty(result))
            {
                XDocument xDoc = XDocument.Parse(result, LoadOptions.SetBaseUri);

                var blogItems = from item in xDoc.Descendants("item")
                                select new ChannelItem
                                {
                                    Title = (string)item.Element("title"),
                                    Link = (string)item.Element("link"),
                                    PubDate = (DateTime)item.Element("pubDate"),
                                    SourceUrl = (string)item.Element("source").Attribute("url"),
                                    Description = (string)item.Element("description"),
                                    Author = (string)item.Element(XName.Get("creator","http://purl.org/dc/elements/1.1/"))
                                };

                foreach (ChannelItem item in blogItems)
                {
                    Console.WriteLine("Title: {0}", item.Title);
                    Console.WriteLine("Link : {0}", item.Link);
                    Console.WriteLine("SUrl : {0}", item.SourceUrl);
                    Console.WriteLine("Auth : {0}", item.Author);
                    Console.WriteLine("Date : {0}", item.PubDate);
                    Console.WriteLine("Content Length: {0}{1}", item.Description.Length, Environment.NewLine);
                }

            }
            else
            {
                Console.WriteLine("No Results Retrieved");
            }

            Console.ReadLine();
        }
    }
}

This also, worked fine.  However, when I put the same code in to my shiny new Silverlight application and run it through debug I get myself a nice little error.  The error message itself is a little bit on the ambiguous as we sometimes come to expect from technologies in their infancy.  Essentially the error I got was "Security error".  Gee, thanks for that?!

Digging a  little deeper in tot eh actual exception, we get the stack etc and the actual error (sort of):

SecurityException

at MS.Internal.InternalWebRequest.Send()
at System.Net.BrowserHttpWebRequest.BeginGetResponseImplementation()
at System.Net.BrowserHttpWebRequest.InternalBeginGetResponse(AsyncCallback callback, Object state)
at System.Net.AsyncHelper.BeginOnUI(BeginMethod beginMethod, AsyncCallback callback, Object state)
at System.Net.BrowserHttpWebRequest.BeginGetResponse(AsyncCallback callback, Object state)
at InteraktingMainFeed.Page.GetMainFeed()
at InteraktingMainFeed.Page..ctor()
at InteraktingMainFeed.App.Application_Startup(Object sender, StartupEventArgs e)
at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

I was trying everything to fix this until I hit upon the idea of taking Casini (Visual Studio's web server) out of the question (just in case) and setting up a virtual directory on my local IIS to server the Silverlight web app.

That actually fixes it.  I don't know why this effects the way the Silverlight app works, but it does.  It's highly frustrating and in my opinion completely under-tested.  As developers, we generally need to be able to debug our applications but there is now a nice hurdle in the way and you can't just use F5.  Basically, I'm going to have to attach to the web process to debug.  It's not the end of the world, but it would be nice if I could just debug the lazy way.

I can see that picking up Silverlight is going to have some nice little challenges along the way.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Friday, September 19 2008 at 04:47 PM by Matt Nield
Interakting Blogs