StrataFrame Forum

Error when use GUID field as browse search field

http://forum.strataframe.net/Topic6918.aspx

By Chan - 2/17/2007

Hi,

I hit error below if I set a GUID field as browse search field. This search field is also set to use combobox - Business Object.

Please advice.

Thank you

InvalidOperationException
 The input value could not be converted to the output type.
FormatException
 Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

Source     : MicroFour StrataFrame Base

Stack Trace:
   at System.Guid..ctor(String g)
   at MicroFour.StrataFrame.Data.ObjectConverter.ConvertValue(Object InputValue, Type InputType, Type OutputType, String FormatString)
   at MicroFour.StrataFrame.Data.ObjectConverter.ConvertValue(Object InputValue, Type OutputType)
   at MicroFour.StrataFrame.UI.Windows.Forms.ListControl.PopulateComboFromBusinessObject(IListControl lstControl, Object[] Parameters)
   at MicroFour.StrataFrame.UI.Windows.Forms.ListControl.PopulateCombo(Control lstControl, Object[] Parameters)
   at MicroFour.StrataFrame.UI.Windows.Forms.ComboBox.PopulateCombo(Object[] Parameters)
   at MicroFour.StrataFrame.UI.Windows.Forms.ComboBox.Requery()
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogWindow.CreateBOCombo(SearchFieldItem Item)
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogWindow.CreateAllSearchFieldControls()
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogWindow.AddSearchFields()
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogWindow..ctor(BrowseDialog BrowseDialogSettings, Boolean PopulateOnShow)
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialog.ShowDialog(Boolean PopulateOnShow)
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialog.ShowDialog()
   at MicroFour.StrataFrame.UI.Windows.Forms.MaintenanceFormToolStrip.cmdBrowse_Click(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

By StrataFrame Team - 2/19/2007

Do you have a valid selection within the combo box?  The SelectedValue of the combo box will have to be GUID value...
By Chan - 2/19/2007

Hi,

I have retest this issue. I found that, after I set combo - Business Object, code is generated to designer.cs.

However, if I try to reconfigure the same search field, the UI unable to get my Business Object, and show blank in business object type, method to execute and display field.

Any ideas? I can use the same BO in data entry form without any problem.

By Chan - 2/19/2007

Hi,

After some debugging, I found this.

At the line of code shown below, value of

.TopMostItem.TopMostValue = "-1"
loBO.GetPropertyDescriptor(.PopulationDataSourceSettings.ValueMember).PropertyType = {Name = "Guid" FullName = "System.Guid"} System.Type

When SF.NET try to convertvalue, "-1" cant be converted to GUID. Does lstControl..TopMostItem.TopMostValue always been defaulted to "-1"? Can it be changed?

Private Shared Sub PopulateComboFromBusinessObject(ByVal lstControl As IListControl, ByVal Parameters As Object())
...
loNewRow.Item(VALUE) = MicroFour.StrataFrame.Data.ObjectConverter.ConvertValue(.TopMostItem.TopMostValue, loBO.GetPropertyDescriptor(.PopulationDataSourceSettings.ValueMember).PropertyType)

 

By Chan - 2/19/2007

Hi,

I just found this code may cause the problem

Private Function CreateBOCombo(ByVal Item As SearchFieldItem) As Control
...
.TopMostItem = New TopMostListItem(_BrowseDialog.EnumTopMostText, "-1")

How to fix it?

Thank you

By Trent L. Taylor - 2/19/2007

Just select the combo box, right-click the TopMostItem property, and then click Reset.  This will remove the top most item settings within your designer.
By Chan - 2/19/2007

Hi,

The combobox is in browse dialog form. How to reset its the combobox property? I was thinking all search fields are generated only during runtime.

Please advice.

Thank you

By StrataFrame Team - 2/20/2007

Are you wondering how to repopulate the combobox with fresh values?  The combo box is built at runtime whenever the browse dialog is displayed, so shouldn't need to repopulate it because it will contain the fresh values each time the dialog is shown.
By Chan - 2/20/2007

No, I don't meant that.

OK, I have a field called VendorID which is GUID field type.

I add this field as browse dialog search field, ComboBox - business object (VendorsBO.FillAll()). I would hit error when I click on browse button.

InvalidOperationException
 The input value could not be converted to the output type.
FormatException
 Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

After some debugging, I found that, TopMostItem.TopMostValue is always defaulted as "-1" when combobox is created (as shown as below). When program try to convert TopMostValue to GUID, it hit error.

Private Function CreateBOCombo(ByVal Item As SearchFieldItem) As Control
...
.TopMostItem = New TopMostListItem(_BrowseDialog.EnumTopMostText, "-1")

Do you get what I meant?

Please advice

By Trent L. Taylor - 2/20/2007

Change the "-1" to "{00000000-0000-0000-0000-000000000000}" and give it a try.  I have not tested this, but a -1 cannot be converted to a GUID.
By Chan - 2/20/2007

Hi,

I cant test on it because my project no longer working after I compile SF source code. I got to reinstall SF.

By Chan - 2/20/2007

Hi,

I am able to "hijack" the value of TopMostValue to change it from "-1" to "00000000-0000-0000-0000-000000000000" and it would work.

I would wait for your next update.

Thank you

By Trent L. Taylor - 2/21/2007

We would have to test this on the GUID as this was not designed with this in mind.  You can just create your own top most item instead of using the property.
By Chan - 2/21/2007

Hi,

Which event should I place the code to create my own topmostitem?

Do you meant to modify SF source code?

Thank you

By Trent L. Taylor - 2/21/2007

No, do not modify the SF source code.  I was referring to adding an item to the data source that is shown within combo.  Just another another item.
By Chan - 2/21/2007

Sorry, I am lost.

Why to add another item to my datasource? My PL field is GUID. How to assign "-1" ? hmm... didn't get you.. sorry.

By StrataFrame Team - 2/22/2007

To add your own item, you would need to handle the DataSource changed event on the ComboBox.  Within the event, you can add a new record to the top of the data table (.Insert() it rather than .Add() it).  You can check the structure of the table for the field names, but it should only have two columns... a "display" column and a "value" column.  Then, just set the values in the new record and insert it into the table.
By Chan - 5/1/2007

Hi,

May I know if this issue been handled natively in upcoming update?

Thank you

By Chan - 8/14/2007

Hi

Sorry, I still don't know how to solve this problem.

Where should I put my code? How to set Browsedialog combobox.topmost to Guid.Empty instead if '-1'?



Thank you
By Chan - 8/16/2007

Ben Chase (02/22/2007)
To add your own item, you would need to handle the DataSource changed event on the ComboBox. Within the event, you can add a new record to the top of the data table (.Insert() it rather than .Add() it). You can check the structure of the table for the field names, but it should only havetwo columns... a "display" column and a "value" column. Then, just set the values in the new record and insert it into the table.




Hi,

Since the combobox in browsedialog is created at runtime while ShowDialog() method been called, how could I handle its DtaaSourceChanged event?



Also, FYI, the error is occured at ListControl.PopulateComboFromBusinessObject().



loNewRow.Item(VALUE) = MicroFour.StrataFrame.Data.ObjectConverter.ConvertValue(.TopMostItem.TopMostValue, loBO.GetPropertyDescriptor(.PopulationDataSourceSettings.ValueMember).PropertyType)

By Chan - 1/19/2008

Hi,

I found that this issue has been fixed in version 1.6.1.

I specified {00000000-0000-0000-0000-000000000000} in Top Most Value under Combo-General.

After I select item from combobox and click search, I hit error error below. Any ideas?



InvalidCastException

Conversion from type 'Guid' to type 'String' is not valid.



Source : Microsoft.VisualBasic



Stack Trace:

at Microsoft.VisualBasic.CompilerServices.Conversions.ToString(Object Value)

at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.BuildWhereElement(SearchFieldItem SearchField)

at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.BuildSearchWhereClause()

at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.ExecuteSearch()

at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.tsiSearch_Click(Object sender, EventArgs e)

at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)

at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)

at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)

at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)

at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)

at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)

at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

at System.Windows.Forms.ToolStrip.WndProc(Message& m)

at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)

at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)

at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
By StrataFrame Team - 1/21/2008

The processing of the where element for GUID was assuming that the type could be cast or converted to a Guid, so I changed it so that it would use the Guid constructor and pass over the value.ToString() (the Guid constructor will then parse the value back into a valid Guid).  So, it should fix the problem you're having.  However, if you need the fix before then, then you can change your source code:

BrowseDialogwindow.vb line 2207:

loFieldValue.Add(New Guid(_CurrentValue.ToString()))

Instead of the:

loFieldValue.Add(CType(_CurrentValue, Guid))

By Chan - 1/21/2008

Hi,

Thank you answer.

When would next SF release? I am using SF 1.6.1 (posted at forum) which doesn't have source code. Therefore, I am not able to change my source code.
By StrataFrame Team - 1/21/2008

I am not positive when the next release will be... we are currently getting our finishing out the rest of the posted bugs and getting the install ready for VS2008 and 64-bit.