#1 2015-03-25 17:32:55

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 337

Variant custom type exception

Hi,

   I have the following problem, my application is multithread and each thread load/unload a DLL. This DLL use a TWinHTTP.Post that call an interface based service on the server side. Every so often the error "Custom variant type ($0111) already used by TDocVariant" is raised, I suspect this is because when a DLL in a thread is unloading, another (with another thread) is loading and the conflict may arise in SynCommons.pas.TDocVariantData.Init.

   I solved this keeping the DLL in memory.

Best regards.


Esteban

Offline

#2 2015-03-25 19:04:59

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,662
Website

Re: Variant custom type exception

You may try using a package instead of a plain dll instead.

Offline

#3 2015-03-25 19:11:39

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 337

Re: Variant custom type exception

I know but the DLL are as plugins, extending specific functionality for customers.

I just commented the situation. I am having another problem with mORMot but I will put in another thread.

Thanks.


Esteban

Offline

#4 2015-03-25 19:20:08

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,662
Website

Re: Variant custom type exception

The issue comes from the fact that SynCommons is initialized twice, once in the main exe, and another time in the dll.
AFAIR packages do not suffer for this, and unit initialization part is not executed twice when a package is loaded.

In all cases, loading dll in sub threads is pretty dangerous...
At least, I may use a critical section to protect the loading process, or use a dedicated thread.

Offline

Board footer

Powered by FluxBB