This is not the specific API call that is the source of the problem. The API is too obscure and too poorly documented to give a direct answer, but look for an initialization style function that allows you to set a callback. This callback is the cause of the exception. You must create a delegate object and save it in the field of your class. Thus, the garbage collector sees a link to it and will not collect garbage.
, :
void SetupScanner() {
mfInitialize(something, myCallback);
}
:
SomeDelegateType callback;
void SetupScanner() {
callback = new SomeDelegateType(myCallback);
mfInitialize(something, callback);
}
, .