Can not create an instance of type Deal.IDealView?

Topics: CAB & Smart Client Software Factory
Nov 14, 2006 at 10:59 PM
originally posted by: ianvink2

I have a simple test app with 3 views. Each view implements this interface:

public interface IDealView
{
decimal Amount {set;}
DateTime StartDate {set;}
DateTime EndDate {set;}
decimal ExecutiveBonus {set;}
}

When I add the Smart Parts to my work item like this:

WorkItem child = parentWorkItem.WorkItems.AddNew<WorkItem>();

SimpleView sv = child.SmartParts.AddNew<SimpleView>(); /* ERROR HERE */
myWorkItem.Run(parentWorkItem.Workspaces"workSpaceNormal",sv );

I get an error:
->Failed to load module from assembly Deal, snip
->Can not create an instance of type 'Deal.IDealView'.
-> Cannot create an abstract class

The views are like this:

SmartPart
public partial class SimpleView : UserControl, IDealView
{
public SimpleView()
{
InitializeComponent();
}

private DealPresenter presenter;

CreateNew
public DealPresenter Presenter
{
set { presenter = value; }

}
...

Ideas why it's getting this error?
Nov 15, 2006 at 5:01 PM
originally posted by: ianvink2

More info on the error, "Can not create an instance of type Deal.IDealView".

The error is throw in:

Microsoft.Practices.ObjectBuilder.CreationStrategy's
BuildUpNewObject(IBuilderContext context, Type typeToBuild, object existing, string idToBuild)

at Line 75: existing = FormatterServices.GetSafeUninitializedObject(typeToBuild);
typeToBuild = {Deal.IDealView}


The interface the View is based on is Deal.IDealView and has this structure:
public interface IDealView
{
decimal Amount {set;}
DateTime StartDate {set;}
DateTime EndDate {set;}
decimal ExecutiveBonus {set;}
}


I can provide a sample project to cause this error.
Nov 15, 2006 at 5:58 PM
originally posted by: ianvink2

I found the offending code that causes the error. In my View I have this:

DealPresenter presenter;
CreateNew
public DealPresenter Presenter
{
set{ presenter = value; }
}

To get me a copy of the presenter for the view. If I take out the CreateNew it doesn't crash.

Do i need to use a InjectionConstructor somehow?
Jan 5, 2007 at 12:05 AM
originally posted by: RobertEwen

Hi,

post the code of the DealPresenter class ...
Are you working with the SmartClient Software Factory?

Kind regards
Robert