Getting crash on when call Marshal.GetDelegateForFunctionPointer in with App sandbox in Appstore

  Kiến thức lập trình

I am creating .net maui cross platform application, and in this app i am using one sccanner. and i have dylib for this scanner and when i load this dylib its successfully loaded but when i use this function i got crash in testflight build.

Following is code :

var strDllName = dylib path 
var  _Dll = NativeMethods.dlopen(strDllName,1);

IScannerService.SiResult value = IScannerService.SiResult.SirUnknownError;
                IntPtr pAddressOfFunctionToCall = GetProcAddress(_Dll, "SI_OpenInterface");

                if (pAddressOfFunctionToCall == IntPtr.Zero)
                {
                    state = SCANNER_STATE.SCANNER_NO_INIT;
                    return IScannerService.SiResult.SirInitializationFailure;
                }
                else
                {
                        __SI_OpenInterface ___SI_OpenInterface = (__SI_OpenInterface)Marshal.GetDelegateForFunctionPointer(
                                                                                                            pAddressOfFunctionToCall,
                                                                                                            typeof(__SI_OpenInterface));
                       value = (IScannerService.SiResult)___SI_OpenInterface(scanner/*"nScan690gt"*/);
                }

Here is my code so please anything anyone know let me share.

LEAVE A COMMENT