DinkToPdf icon indicating copy to clipboard operation
DinkToPdf copied to clipboard

[FIX] Managed Debugging Assistant 'CallbackOnCollectedDelegate' exception

Open sergei66666 opened this issue 5 years ago • 0 comments

If you have such a problem, then you need to download the source and make the following changes in BasicConverter.cs

  1. Add this lines to constructor and generate properties for delegates
public BasicConverter(ITools tools)
{
            Tools = tools;

            /// THIS LINES
            OnPhaseChangedDelegate = new VoidCallback(OnPhaseChanged);
            OnProgressChangedDelegate = new VoidCallback(OnProgressChanged);
            OnFinishedDelegate = new IntCallback(OnFinished);
            OnWarningDelegate = new StringCallback(OnWarning);
            OnErrorDelegate = new StringCallback(OnError);
}        
  1. Inside method byte[] Convert(IDocument document) find this lines
Tools.SetPhaseChangedCallback(converter, OnPhaseChanged);
Tools.SetProgressChangedCallback(converter, OnProgressChanged);
Tools.SetFinishedCallback(converter, OnFinished);
Tools.SetWarningCallback(converter, OnWarning);
Tools.SetErrorCallback(converter, OnError);

and replace with

Tools.SetPhaseChangedCallback(converter, OnPhaseChangedDelegate);
Tools.SetProgressChangedCallback(converter, OnProgressChangedDelegate);
Tools.SetFinishedCallback(converter, OnFinishedDelegate);
Tools.SetWarningCallback(converter, OnWarningDelegate);
Tools.SetErrorCallback(converter, OnErrorDelegate);
  1. And if you want remove little memory leak - add ProcessingDocument = null; before return in byte[] Convert(IDocument document)

p.s. I deliberately did not use the pool requests, because they have not been accepted for a long time.

sergei66666 avatar Nov 19 '18 15:11 sergei66666