T for DelegateCommand is not an object nor Nullable Exception

12 בNovember 2013

תגיות: , , ,
תגובה אחת

Prism Provide ICommand implementation called DelegateCommand,

As the other Markets Commands one version is the DelageteCommand<T>

Supporting Target function with Parameters,

The problem is when doing something like this:

DelegateCommand<int> test;

 

    //ctor

    public Object 

    {

       try

        {

            test = new DelegateCommand<int>((a) => { return; });

        }

        catch (Exception ex)

        {

            

            throw;

        }

 

    }

 

We get runtime Exception ,

<{"T for DelegateCommand<T> is not an object nor Nullable."}>

Well , either use other ICommand implementation or as prism suggested the signature must declare with Nullable or value type.

For example your code will looks as this:

DelegateCommand<Nullable<int>> test;

 

//ctor

public Object 

{

   try

    {

       test = new DelegateCommand<Nullable<int>>((a) => { return; });

    }

    catch (Exception ex)

    {

        

        throw;

    }

 

}

הוסף תגובה
facebook linkedin twitter email

Leave a Reply

Your email address will not be published. Required fields are marked *

תגובה אחת

  1. Itamar30 בApril 2015 ב 10:18

    1. you can use
    DelegateCommand which is actually the same as Nullable

    2. you can use object and check if it is an int later on your code.

    Reply