Error after porting from Visual Studio 2008 to Visual Studio 2010 Beta

Topics: Prism v2 - WPF 3.5
Sep 18, 2009 at 8:25 PM

Hi,

I'm getting an error message after moving a project from Visual Studio 2008 to Visual Studio 2010 Beta 1.  The error may have to do with the move to VS 2010, and it may not.  Also, could someone let me know how to get the proper formatting when copying and pasting from Visual Studio into the forums here. 

The error message is as follows:

Cannot create object of type 'Prism.Rocky.Shell.Views.ShellView'. CreateInstance failed, which can be caused by not having a public default constructor for 'Prism.Rocky.Shell.Views.ShellView'.  Error in markup file 'Prism.Rocky.Shell;component/Views/ShellView.xaml' Line 1 Position 9

Here is some XAML from ShellView.xaml :

<

<font face="Consolas" size="2" color="#0000ff"><font face="Consolas" size="2" color="#0000ff"><font face="Consolas" size="2" color="#0000ff">

 

</font></font></font><font face="Consolas" size="2" color="#0000ff"><font face="Consolas" size="2" color="#0000ff">

 

</font></font><font face="Consolas" size="2" color="#0000ff">

 

</font>

 

Window x:Class="Prism.Rocky.Shell.Views.ShellView"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <font face="Consolas" size="2"><font face="Consolas" size="2">

 

</font></font><font face="Consolas" size="2">

 

</font>

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" <font face="Consolas" size="2"><font face="Consolas" size="2">

 

</font></font><font face="Consolas" size="2">

 

</font>

xmlns:d="http://schemas.microsoft.com/expression/blend/2008" <font face="Consolas" size="2"><font face="Consolas" size="2">

 

</font></font><font face="Consolas" size="2">

 

</font>

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" <font face="Consolas" size="2"><font face="Consolas" size="2">

 

</font></font><font face="Consolas" size="2">

 

</font>

xmlns:prismcmd="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation" <font face="Consolas" size="2"><font face="Consolas" size="2">

 

</font></font><font face="Consolas" size="2">

 

</font>

xmlns:prismrgn="clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation" <font face="Consolas" size="2"><font face="Consolas" size="2">

 

</font></font><font face="Consolas" size="2">

 

</font>

Title="Prism Prism.Rocky.Shell" WindowStartupLocation="CenterScreen" Height="1080" Width="1920" <font face="Consolas" size="2"><font face="Consolas" size="2">

 

</font></font><font face="Consolas" size="2">

 

</font>

Icon="../Images/PnPIcon.ico" <font face="Consolas" size="2"><font face="Consolas" size="2">

 

</font></font><font face="Consolas" size="2">

 

</font>

mc:Ignorable="d" d:DesignHeight="1080" d:DesignWidth="1920">

 

 

The code for the shell is :

using System;

using System.Windows;

using System.Windows.Controls;

using Prism.Rocky.Shell.ViewModels;

namespace Prism.Rocky.Shell.Views

<font face="Consolas" size="2" color="#0000ff"><font face="Consolas" size="2" color="#0000ff"><font face="Consolas" size="2" color="#0000ff">

{

 

</font></font></font><font face="Consolas" size="2" color="#0000ff"><font face="Consolas" size="2" color="#0000ff">

 

</font></font><font face="Consolas" size="2" color="#0000ff">

 

</font>

public partial class ShellView : Window {<font face="Consolas" size="2"><font face="Consolas" size="2">

  

</font></font><font face="Consolas" size="2">

 

</font>

public ShellView(ShellViewModel viewModel)// Set the ViewModel as this View's data context.

     {

     InitializeComponent();

     this.DataContext = viewModel;

     }

  }

}

<font face="Consolas" size="2"><font face="Consolas" size="2">

 

</font></font><font face="Consolas" size="2">

 

</font>

Sep 19, 2009 at 4:58 AM

A default constructor is an empty constructor.  If you'll add the following your error will go away:

      public ShellView(){ }

As for the code formatting.   CodePlex has a cool feature that is on the toolbar to the right of the [html] button - it is the [</>] button.   It will provide a window that you can paste code into and then select the applicable language - it will format it (colorized) so that we can easily view it.