Exception has been thrown by the target of an invocation.


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
From going back and rereading your previous posts, it just sounds like it is a simple matter of creating a custom property and setting using a ReflectionPropertyDescriptor defined in the GetCustomBindablePropertyDescriptors methods.  Just create a custom property that is properly exposed to respect a BBS (look at a property built through the BO Mapper for the required attributes).
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
The details are quite simple (sample app attached). 

1)  Create form.
2)  Add BO (the BO must have a custom property).
3)  Add DevEx GridView.
4)  Add BBS.
5)  Connect BO to BBS and BBS to Grid.
6)  Remove several columns from the grid, including the custom property.
7)  Run the app.

The grid will appear with data filling it (Movies).  Simply close the form and the error will appear.

I know the error is because of the custom property, but I cannot determine why.

Attachments
DataGridTest.zip (159 views, 744.00 KB)
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
The following data retrieval method was not updated properly before I zipped...sorry...

FillDataTable("SELECT * AS ItemCount FROM Movies");

Just delete the " AS ItemCount" from the select statement.  All will be well after that.  I was trying to pull a value for the custom property, but it does not matter.


Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
I duplicated the details I found in the designer file of a BO and this is what I ended up with:


[Browsable(false),
BusinessFieldDisplayInEditor(),
Description("Items Count"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int ItemsCount
{
   
get
   
{
       
object loValue;
        loValue =
this.CurrentRow["ItemsCount"];
       
if (loValue == DBNull.Value)
        {
           
return 0;
        }
       
else
       
{
           
return (int)this.CurrentRow["ItemsCount"];
        }
    }
}

protected override FieldPropertyDescriptor[] GetCustomBindablePropertyDescriptors()
{
   
return new FieldPropertyDescriptor[]
    {
       
new ReflectionPropertyDescriptor("ItemsCount", typeof(BusinessObject1))
    };
}

It does not make any difference.  I still get the same error.

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Adding the following fixes the problem. 


private void BusinessObject1_CurrentDataTableInitialized()
{
   
if (CurrentDataTable.Columns["ItemsCount"] == null) { CurrentDataTable.Columns.Add(new DataColumn("ItemsCount", typeof(int))); }
}

private void BusinessObject1_CurrentDataTableRefilled()
{
   
if (CurrentDataTable.Columns["ItemsCount"] == null) { CurrentDataTable.Columns.Add(new DataColumn("ItemsCount", typeof(int))); }
}

I will make sure to add these to every BO in which I have created custom properties. 

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
It worked on the test solution, but my application is not responding the same way.  I am still getting the elusive error.  Any ideas would be appreciated.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Here is the most recent error message for us to work with...
Attachments
exception (0810131005).png (173 views, 81.00 KB)
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
This looks like you may need to take something into account within your BO and properties.  For example, the LastInvQty looks as thought it may be a custom property (it may not) but in either case, there is an illegal cast exception.  So the property may be getting evaluated earlier or in a different way than normal.  Put a break point in the Get of the property and see when and how it is being accessed.  Work backwards from there. 
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Yup...you are right...it is a custom property.  Here is the code (the corresponding FieldPropertyDescriptor exists):


[Browsable(false),
BusinessFieldDisplayInEditor(),
Description("Last Inventory Quantity"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public decimal LastInvQty
{
   
get
   
{
       
object loValue;
        loValue =
this.CurrentRow["LastInvQty"];
       
if (loValue == null)
        {
           
return 0.00M;
        }
       
else
       
{
           
return (decimal)this.CurrentRow["LastInvQty"];
        }
    }
}

I even forced the 0 value, if null, to be a decimal (even though I should not have to do that).  What is extremely odd is that the value of the object is {} rather than null (see attached).  Why would the object come back as an empty set rather than null?

Attachments
breakpoint (0810131117).png (170 views, 33.00 KB)
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Here is another exception.  This one comes about by removing the following code from CurrentDataTableInitialized and CurrentDataTableRefilled events:


if (CurrentDataTable.Columns["LastInvQty"] == null) { CurrentDataTable.Columns.Add(new DataColumn("LastInvQty", typeof(decimal))); }

So, using the above code causes the column to evaluate as {} rather than null (how do I work with a {}?) and not using the code makes the application complain that the column does not exist in the datatable.  I am using a standard DataGridView...no DevEx object involved at this point.  The three objects used are SF BO (with custom properties), SF BBS and the DataGridView.

Thanks for helping!!
Bill

Attachments
exception (0810131137).png (163 views, 52.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search