0

We are trying to get values returned from a COM object, the function is:

bool AxSB100BPC.GetEnrollData(int dwMachineNumber,
int dwEnrollNumber,
int dwEMachineNumber,
int dwBackupNumber,
ref int dwMachinePrivilege,
ref object dwEnrollData,
ref int dwPassWord

We are calling this function as:

vRet = axSB100BPC1.GetEnrollData(mMachineNumber,
                                 vEnrollNumber,
                                 vEMachineNumber,
                                 vFingerNumber,
                                 ref vPrivilege,
                                 ref oglngEnrollData,
                                 ref glngEnrollPData);

The problem is with oglngEnrollData which is type of ref object. It is declared as object oglngEnrollData;.

The error is:

System.Runtime.InteropServices.COMException was unhandled
HResult=-2147352571
Message=Tür uyuşmazlığı. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
Source=mscorlib
ErrorCode=-2147352571
StackTrace:
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName,           BindingFlags          flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at SB100BPCLib._DSB100BPC.GetEnrollData(Int32 dwMachineNumber, Int32 dwEnrollNumber, Int32 dwEMachineNumber, Int32 dwBackupNumber, Int32& dwMachinePrivilege, Object& dwEnrollData, Int32& dwPassWord)
   at AxSB100BPCLib.AxSB100BPC.GetEnrollData(Int32 dwMachineNumber, Int32 dwEnrollNumber, Int32 dwEMachineNumber, Int32 dwBackupNumber, Int32& dwMachinePrivilege, Object& dwEnrollData, Int32& dwPassWord)
   at enrolldata.Form1.button2_Click(Object sender, EventArgs e) in f:\enrolldata\Form1.cs:line 196
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at enrolldata.Program.Main() in f:\enrolldata\Program.cs:line 19
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Any ideas are welcomed

2
  • Crappy manual. I'd guess at byte[] that's 1416 elements long or an int[] that's 354 elements long. secubio.com/upload/file/1292045533.pdf Call the vendor if you can't figure it out. Commented Feb 11, 2013 at 2:19
  • Thank you @HansPassant, it seems 354 for my case; ` const int DATASIZE = 354; //(1404 + 12) / 4;` Commented Feb 11, 2013 at 2:31

1 Answer 1

1

This question on another forum seems to be dealing the same problem for the same interface.

This is just a guess based on that thread, but the problem seems to be that the dwEnrollData parameter is actually a variant type (not a managed System.Object type) in which case you should try using System.Runtime.InteropServices.VariantWrapper to wrap the parameter value you are passing into the method.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you @mike, tried : int glngEnrollData; object var = new System.Runtime.InteropServices.VariantWrapper(glngEnrollData);, but got : Error 1 A field initializer cannot reference the non-static field, method, or property 'enrolldata.Form1.glngEnrollData' F:\enrolldata\Form1.cs 28 72 enrolldata

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.