Bug when using new on Controller

Topics: CAB & Smart Client Software Factory
Oct 19, 2005 at 2:50 AM
originally posted by: Kidd_Kane

Previously if I wanted a controller to have a specific instance of my WorkItem I did the following in the Controller:

public new SpecificWorkItem WorkItem {
get {return (SpecificWorkItem)base.WorkItem;}
}

Now if I do this when I try to create my workitem either using the CreateNewAttribute, DependencyAttribute, ComponentDepencyAttribute, or by simply calling AddNew<MyController>() in the workitem, I get an exception thrown from within the PropertySetterStrategy's InjectProperties method. It says "Ambiguous match found." and is an AmbiguousMatchException. It the time this happens it seems to be doing something with the WorkItem property on my controller, and I guess since I've declared WorkItem as new that it doesn't know which one to use, is this a bug or do I need to change how I access specific WorkItems from a controller?
Oct 19, 2005 at 6:46 AM
originally posted by: jburkholder

I also had this error. You probably have a Property called WorkItem in your controller, change it to something else like myWorkItem and see if that resolves it.
Oct 20, 2005 at 3:03 AM
originally posted by: DLorenz

Another approach would be to put this in your Run() in the WorkItem:

State("WorkItem") = this;

Then in your controller, you can just reference it through normal state. However, I am not sure if that is what you were actually going for.
Oct 20, 2005 at 6:50 AM
originally posted by: Kidd_Kane

These are all fine workarounds and I currentl work around the problem by just calling the specific workitem something other than WorkItem... I just wanted to point this out in case it was a bug... I believe there were example usages like I noted either previously in the Quickstarts or HoLs.
Oct 20, 2005 at 11:30 AM
originally posted by: BradWilsonMSFT

Yep, it was a bug, and it will be fixed in the final release (just squashed it right now, and changed the BankTeller back to use the old pattern).

Thanks!