views:

67

answers:

1

Hi,

I have a silverlight 3 application with the latest Caliburn RTW.

I have a button with the following caliburn property in XAML: PresentationFramework:Message.Attach="ContainerCommand ClassesCommand()"/>

In my module.cs I have :

  _container.RegisterType(typeof(ClassesCommand), new ContainerControlledLifetimeManager());


  _regionManager.RegisterViewWithRegion("MenuRegion", () => _container.Resolve<ClassesButton>());

On the _container.Resolve() I get AG_E_PARSER_BAD_PROPERTY_VALUE for "ContainerCommand ClassesCommand()" in the XAML.

My ClassesCommand.cs is :

public class ClassesCommand
{

 public void Execute()
 {
  //
 }

 public bool CanExecute()
 {
  //
  return true;
 }

}

JD.

+1  A: 

Try registering your command by Key instead of type. Also, try removing the empty parenthesis from the end. Let me know if either of these things fixes your issue. Thanks!

EisenbergEffect
@EisenbergEffect: Sorry, no luck. Tried registering by key and removing parenthesis. I think I may try to see if I can get it working via ResourceCommand.
JD
Please confirm that the constuctor of your command does not throw an exception as well. If you can, feel free to send me a repro and I will try and discover the problem.
EisenbergEffect
Thanks. I am not seeing the constructor called at all. All I am doing is in module.cs is _container.RegisterType<ClassesCommand>("ClassesCommand", new ContainerControlledLifetimeManager());. Forgot to mention that I am using prism if it helps.
JD
Just sent an email with attached zip file to [email protected]. Thanks.
JD
Thanks to Rob, the issues I had have now been resolved. First the registration of the command should have been : unityContainer.RegisterType(typeof(object), typeof(ClassesCommand), "ClassesCommand", new ContainerControlledLifetimeManager()); Secondly, the documentation on caliburn show the manual configuration mechanism but I was inheriting App from CaliburnApplication which does the configuration in the base class. All I had to do was override CreateContainer to return the unityContainer. These two issues resolved the problems I was having.
JD