Using Open eVision in a DLL
Follow these guidelines to use Open eVision inside one or several DLLs. Ignoring this may lead to random crashes usually due to incompatibilities between the memory representations and/or the conflicting CRT.
Until Open eVision 2.14.1, a bug in the method Easy::Terminate may lead to a crash even if you follow these guidelines.
To avoid this, please use Open eVision 2.15 or later.
Depending on your configuration, implement one of the following scenarios. There are presented in the order of increasing complexity:
1. A single DLL called from an application NOT compiled with Open eVision
Inside your DLL, it is mandatory to follow these rules:
|
●
|
Call Easy::Initialize before any other call to Open eVision (with the exception of Preconfiguration calls). |
|
●
|
Destroy any object created in the DLL. |
|
●
|
In the DLL API, do not expose any Open eVision object (otherwise the application is compiled with Open eVision). |
|
●
|
If possible, use only standard C types. |
In your application:
|
●
|
Never use an Open eVision object as a global object. |
|
□
|
Create the instance only after the DLL initialization. |
|
□
|
You may use a global pointer or a reference to such an object. |
|
●
|
Never create an Open eVision object or make an Open eVision call inside DllMain. |
2. A single DLL called from an application compiled with Open eVision
Inside your DLL and in the application, it is mandatory to follow these rules:
|
●
|
Call Easy::Initialize before any other call to Open eVision (with the exception of Preconfiguration calls). |
|
●
|
Destroy in the DLL any object created in the DLL. |
|
●
|
Destroy in the application any object created in the application. |
|
●
|
In the DLL API, expose Open eVision objects only as pointers or references. |
|
□
|
You may pass these pointers and references between the DLL and the application if and only if the compilation and linking parameters are strictly the same between the DLL and the application. |
|
□
|
As this is difficult to achieve, avoid it as much as possible. |
|
□
|
Be very careful when considering the lifetime of these objects. |
|
●
|
It is highly recommended to use the same exact version (all of Ma.Mi.Re.Bu) of Open eVision, the DLL and the application. |
|
□
|
This is mandatory if you pass objects around. |
In your application:
|
●
|
Never use an Open eVision object as a global object. |
|
□
|
Create the instance only after the DLL initialization. |
|
□
|
You may use a global pointer or a reference to such an object. |
|
●
|
Never create an Open eVision object or make an Open eVision call inside DllMain. |
3. Multiple DLLs called from an application NOT compiled with Open eVision
Inside all your DLLs, it is mandatory to follow these rules:
|
●
|
Call Easy::Initialize before any other call to Open eVision (with the exception of Preconfiguration calls). |
|
●
|
Destroy in the same DLL any object created in a DLL. |
|
●
|
In the DLL API, expose Open eVision objects only as pointers or references. |
|
□
|
You may pass these pointers and references between the DLLs if and only if the compilation and linking parameters are strictly the same between the DLLs. |
|
□
|
Be very careful when considering the lifetime of these objects. |
|
●
|
In a DLL API, do not expose any Open eVision object (otherwise the application is compiled with Open eVision). |
|
●
|
If possible, use only standard C types. |
|
●
|
It is highly recommended to use the same exact version (all of Ma.Mi.Re.Bu) of Open eVision, the DLL and the application. |
|
□
|
This is mandatory if you pass objects around. |
In your application:
|
●
|
Never use an Open eVision object as a global object. |
|
□
|
Create the instance only after the DLL initialization. |
|
□
|
You may use a global pointer or a reference to such an object. |
|
●
|
Never create an Open eVision object or make an Open eVision call inside DllMain. |
4. Multiple DLLs called from an application compiled with Open eVision
Inside your DLLs and in the application, it is mandatory to follow these rules:
|
●
|
Call Easy::Initialize before any other call to Open eVision (with the exception of Preconfiguration calls). |
|
●
|
Destroy in the same DLL any object created in a DLL. |
|
●
|
Destroy in the application any object created in the application. |
|
●
|
In the DLL API, expose Open eVision objects only as pointers or references. |
|
□
|
You may pass these pointers and references between the DLLs if and only if the compilation and linking parameters are strictly the same between the DLLs. |
|
□
|
You may pass these pointers and references between a DLL and the application if and only if the compilation and linking parameters are strictly the same between the DLL and the application. |
|
□
|
As this is difficult to achieve, avoid it as much as possible. |
|
□
|
Be very careful when considering the lifetime of these objects. |
|
●
|
It is highly recommended to use the same exact version (all of Ma.Mi.Re.Bu) of Open eVision, the DLL and the application. |
|
□
|
This is mandatory if you pass objects around. |
In your application:
|
●
|
Never use an Open eVision object as a global object. |
|
□
|
Create the instance only after the DLL initialization. |
|
□
|
You may use a global pointer or a reference to such an object. |
|
●
|
Never create an Open eVision object or make an Open eVision call inside DllMain. |