Welcome Guest Search | Active Topics | Sign In | Register

CallbackOnCollectedDelegate Options
Adam Korbuly
Posted: Monday, October 13, 2014 4:10:11 AM
Rank: Newbie
Groups: Member

Joined: 4/1/2014
Posts: 4
Dear Support!

I got the following error message when I used the EO.WebBrowser control:

Managed Debugging Assistant 'CallbackOnCollectedDelegate' has detected a problem in '****.exe'.
Additional Information:A callback was made on a garbage collected delegate of type 'EO.WebBrowser!EO.WebBrowser.Internal.af+a::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.

Please help.

Thank you
eo_support
Posted: Monday, October 13, 2014 8:56:52 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

Please check if you have created WebView in multiple threads. This can happen if you create WebView in a background thread and didn't explicitly destroy it.

If that's not the problem, please try to isolate the problem into a test app and send the test app to us. Once we have that we will be happy to investigate further and see what we can find. You can find instructions on submitting test app here:

http://www.essentialobjects.com/forum/test_project.aspx

Thanks!
Adam Korbuly
Posted: Thursday, October 16, 2014 3:34:08 AM
Rank: Newbie
Groups: Member

Joined: 4/1/2014
Posts: 4
Unfortunately, I can't attach test app, beacuse it's too complex.

The error suggests that the GC dispose the delegate which is offered by the managed code to native subsystem.

I think you your solution may be something like this:


Quote:
void initnative()
{
var callbackDelegate = new NativeFunctionManagedSign(nativeCallBack)

callNativeDllRegisterCallbackFunction( callbackDelegate );

}


In this case, first time, the GC dispose the callbackDelegate local variable, but the native DLL don't know about this.

To overcome this, I think the following solution is needed:

Quote:

[static] NativeFunctionManagedSign callbackDelegate;

void initnative()
{
callbackDelegate = new NativeFunctionManagedSign(nativeCallBack)
GC.KeepAlive( callbackDelegate );
GC.SuppressFinalize( this );

callNativeDll_RegisterCallbackFunction( callbackDelegate );
}

void donenative()
{
callNativeDll_deRegisterCallbackFunction();
callbackDelegate = null;

GC. .....
}

void nativeCallBack( ..... )
{
}
eo_support
Posted: Thursday, October 16, 2014 9:39:08 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

We do have a very complicated native/managed structure. However we have already taken extra precautions on this and we do not see any problems during our test. That's why we need a sample project from you in order to investigate further.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.