locked
Command Disabled Exception! RRS feed

  • Question

  • Hi,

     

    Ihave disabled Command in code behind and it renderes ok ina PartPane Chrome.

    Nevertheless, I can click on that menu an I got an exception "Component command is disabled."

     

    Friday, August 31, 2007 9:33 AM

Answers

  • Hi Alex,

    Thanks for spotting this, this looks like a bug but we need to investigate further. For now I was trying to find a workaround and one way is to override GenericParameterExecute method of a ComponentCommand. Basically you can create your own ComponentCommand:

     

    Code Snippet

    public class MyComponentCommand:ComponentCommand

    {

    public override void GenericParameterExecute(object parameter)

    {

    if (Enabled)

    base.GenericParameterExecute(parameter);

    }

    }

     

     

     

     

    which will not throw an exception when the triggered command is disabled. Then you can use this command class instead of the acropolis one.

     

    Code Snippet

    xmlns:local="clr-namespace:AcropolisApp3"

    .....

     

    <AcropolisComponent.ConnectionPoints>

    <local:MyComponentCommand Name="SampleCommand" Enabled="False" Description="Sample Command" />

    </AcropolisComponent.ConnectionPoints>

     

     

    I hope this helps to get rid of this annoying exception.

    Thanks!

    Sunday, September 9, 2007 11:46 PM

All replies

  • Hi Alex,

    Thanks for spotting this, this looks like a bug but we need to investigate further. For now I was trying to find a workaround and one way is to override GenericParameterExecute method of a ComponentCommand. Basically you can create your own ComponentCommand:

     

    Code Snippet

    public class MyComponentCommand:ComponentCommand

    {

    public override void GenericParameterExecute(object parameter)

    {

    if (Enabled)

    base.GenericParameterExecute(parameter);

    }

    }

     

     

     

     

    which will not throw an exception when the triggered command is disabled. Then you can use this command class instead of the acropolis one.

     

    Code Snippet

    xmlns:local="clr-namespace:AcropolisApp3"

    .....

     

    <AcropolisComponent.ConnectionPoints>

    <local:MyComponentCommand Name="SampleCommand" Enabled="False" Description="Sample Command" />

    </AcropolisComponent.ConnectionPoints>

     

     

    I hope this helps to get rid of this annoying exception.

    Thanks!

    Sunday, September 9, 2007 11:46 PM
  • Hi Alex,

     

    Thanks for your answer I believe it will work. I just noticed this and wanted for you guys to know.

     

    p.s.

    I was on a holiday so my reply is a little late ...

     

     

    Monday, September 17, 2007 10:27 AM