BOLGenerateSearchAdapter cast error

I’m trying to launch the research “Pack / MP Selection” that is contained in the BOLGenerateSearchAdapter, and I having the error:

Unable to cast object of type ‘Ice.Lib.Searches.SearchOptions’ to type ‘Erp.UI.Searches.BOLGenerateSearchOptions’.

I hate to have to code the hole functionality since it already exists and it work wonderfully.
A great programmer I know told me this error means that I cannot use this search.

This happens when calling the Simple Search Wizard and when calling the code from the dashboard:

Show us ze code!

gus sorola money GIF by Rooster Teeth

:grin:
extern alias Erp_Contracts_BO_BOL;
extern alias Erp_Contracts_BO_BOLGenerateSearch;
using Erp.Adapters;
using Erp.UI;
using Erp.BO;
using Ice.Adapters;

// Please ignore the use of CallContextBpmData , at this point I just entered some code for testing but I need the selection to be available in the BOLForm Report.

private void SearchOnBOLGenerateSearchAdapterShowDialog_1()
{
	// Wizard Generated Search Method
	// You will need to call this method from another method in custom code
	// For example, [Form]_Load or [Button]_Click

	bool recSelected;
	string whereClause = string.Empty;
	System.Data.DataSet dsBOLGenerateSearchAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "BOLGenerateSearchAdapter", out recSelected, true, whereClause);
	if (recSelected)
	{
		System.Data.DataRow adapterRow = dsBOLGenerateSearchAdapter.Tables[0].Rows[0];

		// Map Search Fields to Application Fields
		EpiDataView edvCallContextBpmData = ((EpiDataView)(this.oTrans.EpiDataViews["CallContextBpmData"]));
		System.Data.DataRow edvCallContextBpmDataRow = edvCallContextBpmData.CurrentDataRow;
		if ((edvCallContextBpmDataRow != null))
		{
			edvCallContextBpmDataRow.BeginEdit();
			edvCallContextBpmDataRow["Character01"] = adapterRow["BOLNum"];
			edvCallContextBpmDataRow.EndEdit();
		}
	}
}

Was he mad at you ?

This should get you started, it’s all I have time to mess with.
I included my little object walker if you want to print out the properties for an object.

//ref: Erp.Adapters.BOLGenerateSearch
//ref: Erp.Contracts..BO.BOLGenerateSearch


using Erp.Adapters;
using Erp.UI.Searches;

private void epiButtonC1_Click(object sender, System.EventArgs args)
{
    CallBOLGenerateSearchAdapterGetRowsMethod();
}


private void CallBOLGenerateSearchAdapterGetRowsMethod()
{
    try
    {
        BOLGenerateSearchAdapter adapterBOLGenerateSearch = new BOLGenerateSearchAdapter(this.oTrans);
        adapterBOLGenerateSearch.BOConnect();


        BOLGenerateSearchOptions searchOptions = new BOLGenerateSearchOptions(SearchMode.ShowDialog);
        adapterBOLGenerateSearch.InvokeSearch(searchOptions);

        //MessageBox.Show(GetObjectProperties(searchOptions, 40));
        //Clipboard.SetText(GetObjectProperties(searchOptions, 40));

        // Cleanup Adapter Reference
        adapterBOLGenerateSearch.Dispose();

    } catch (System.Exception ex)
    {
        ExceptionBox.Show(ex);
    }
}

//For Classic UI Customization
//Single Level Object Walker
string GetObjectProperties(object _obj, int padding = 10)
{

string _nl = Environment.NewLine;
//string tab = "\t";

string retValue = "";
foreach (var prop in _obj.GetType().GetProperties())
{
    try
    {
    retValue += prop.Name.PadRight(padding);

    try
    {
        retValue += prop.GetValue(_obj, null).ToString();
    }
    catch {}
    
    }
    catch {}
    retValue += _nl;
}
return retValue;
}	

Here are the properties I printed from the object walker:

Type                                    
ShipDate                                7/4/2023 12:00:00 AM
ShipViaCode                             
CustNum                                 0
VendorNum                               0
PackNum                                 0
CustomArgs                              System.Collections.Hashtable
HasFormOptsNamedSearch                  False
DSDefined                               System.Data.DataSet
SearchMethod                            
IsSubTable                              False
SubTableWhereClauses                    
PageSize                                100
SelectedKeys                            
AbsolutePage                            0
SuppressAutoByCondition                 False
SearchMode                              ShowDialog
DataSetMode                             RowsDataSet
SelectMode                              SingleSelect
SearchName                              EpiRuntime
NamedSearch                             Ice.Lib.Searches.NamedSearch
StartsWithColumn                        
PrimaryTableName                        
SearchTitle                             
SortDescending                          False
SortByColumn                            
PreLoadSearchFilter                     
CurrentAdapter                          
Like                                    
EpiBinding                              
WhoCalledSearch                         
Sender