c# - CallbackOnCollectedDelegate was detected on Walther MFS100 Check Scanner -
i trying programming interface walther mfs100 check scanner after scan "callbackoncollecteddelegate detected" error. how can fix this. use .net 2.0 c#
[dllimport("mflib.dll.stdcall")] public static extern int mfscanfeeder(int mode, int font, int timeout); retval = modmfs100.mfscanfeeder(0, 2,5000);
it isn't particular api call that's source of problem. api obscure , poorly documented give straight answer, initialization style function let's set callback. callback cause of exception. must create delegate object , store in field of class. way garbage collector sees reference , won't garbage collect it.
thus, instead of:
void setupscanner() { mfinitialize(something, mycallback); }
do this:
somedelegatetype callback; void setupscanner() { callback = new somedelegatetype(mycallback); mfinitialize(something, callback); }
contact vendor support if doesn't help.
Comments
Post a Comment