Exception has been thrown by the target of an invocation.


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K 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 (196 views, 33.00 KB)
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
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.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K 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 (199 views, 81.00 KB)
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K 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.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K 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.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K 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.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K 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.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K 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 (182 views, 744.00 KB)
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
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).
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
We have developers using a DevExpress grid and BBS objects every day.  So I really don't know what you are referring to here and exactly what issue that you are having.  A sample or more details would be helpful. 
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