Custom Data Type issue


Author
Message
Ulrik Mueller
Ulrik Mueller
StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)
Group: Forum Members
Posts: 18, Visits: 59
I try to use the Custom Data Type, but is getting stuck in some kind of Casting error.

I have a numeric field that is the STATUS (Active or Passive) in my Customer record.

I have made the following Enum definition

public enum StatusType
{
Aktiv = 0,
Passiv = 1
}

When using the ComboBox compononent everything is working ok.

In step two I would like to set the "Custom Data Type" in the BOM to the "StatusType" definition. Adding the datatype seems to go fine and the IDE is working correctly when adding a default value

this.tr_status = StatusType.Aktiv;

When I run the application - open the maintainance form for the CustomerBO, I receive the following error

"InvalidCastException: Specified cast is not valid"

>>>>  return (mbs2.Business.StatusType)this.CurrentRow["tr_status"];

Can someone explain me what might be wrong here, thanks!

I need to mention that when I search for the Class Type in the BOM I receive an error saying that it "Could not gather enums for Strataframe Inherited UI" and then it fails on "DevExpress.xxxxxx.v8.1".

I have v7.1 installed!!!!

Best regards
Ulrik Mueller (Denmark)

 

 

 

Exception
  Could not gather enums for MicroFour StrataFrame Inherited UI
ReflectionTypeLoadException
  Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
  LoadExceptions:
  FileNotFoundException
    Could not load file or assembly 'DevExpress.XtraEditors.v8.1, Version=8.1.1.0, Culture=neutral, PublicKeyToken=9b171c9fd64da1d1' or one of its dependencies. The system cannot find the file specified.


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
Do you receive the same error if you use the standard StrataFrame combobox? It appears that you have several potential issues here. So let's remove some things from the mix. If you use a standard StrataFrame combo, does the error persist? In other words, remove any Inherited UI elements from the formula and let's see if you the problem continues.
Ulrik Mueller
Ulrik Mueller
StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)
Group: Forum Members
Posts: 18, Visits: 59
I only use Strataframe controls 

The ComboBox control is a MicroFour.StrataFrame.UI.Windows.Forms.ComboBox

The DevExpress package is not being used in this project!!

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
If you are referencing the MicroFour StrataFrame Inherited UI, then that is a DevExpress wrapper. This class is never touched outside of itself. So if you are receiving an exception through this class (the stack trace supplied) then the DevExpress control is in the formula at some point. You might double check that this is the case.
Ulrik Mueller
Ulrik Mueller
StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)
Group: Forum Members
Posts: 18, Visits: 59
OK - I had the Inherited UI in my project and after this have been removed from the REFERENCES I don't get the DevExpress error any more!!

I still have the error when opening the form containing the Custome Data Type

"InvalidCastException: Specified cast is not valid"

>>>>  return (mbs2.Business.StatusType)this.CurrentRow["tr_status"];   <<<<<

Do I have to set anything special on the ComboBox properties when using a CDT'ed field.  The BindingField is still pointing to the field "tr_status". (PopulationEnumName=StatusType  PopulationType=Enumeration)

Regards
/Ulrik

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
What type is tr_Status? How is it defined in the database and what it the type in the CurrentDataTable when it comes back?
Ulrik Mueller
Ulrik Mueller
StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)
Group: Forum Members
Posts: 18, Visits: 59
In the database tr_status is a SmallInt - could that be the problem ?
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
Yes. Enums, by default, are typed as int. You can manually cast this, though:



(mbs2.Business.StatusType)((int)this.CurrentRow["tr_status"]);

Ulrik Mueller
Ulrik Mueller
StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)
Group: Forum Members
Posts: 18, Visits: 59
It looks like it's seeing it as a SHORT in the debugger!

  this.CurrentRow["tr_status"] 0 object {short}

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
Correct. That is what a smallint will be typed as. Just recast it as an int and you will be fine.
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