M
mike.medland
Hi
I am developing a web based application in asp.net and am in the
process of trying to integrate a third party application. The third
party application is supplied in the form of a .h file.
The example they provided is also in C++, which uses the .h file in
question. I would like to create a dll from this .h file which i can
then call from my .Net code. They have provided me with the following
advice about creating a wrapper, which i must admit is a little beyond
my current C++ understanding. I would be grateful if someone could
explain the steps a little clearer to me or suggest a possible
solution. I am currently developing in Visual Studio .Net 2003.
Notes about wrapping the Paper SDK for VS7/VS8:
- The Paper SDK lib\dll directory must be in your path.
- GAPATHOME must be properly set to the GAPAT directory installed by
the FDT (or a copy of that directory).
- The Paper SDK cannot be linked to VC8 libraries; the VC6 linker must
be employed. In other words, both the demo code AND the actual Paper
SDK libraries themselves use template library functions which VC8 does
not know about.
- I wrapped Paper SDK functionality in a VC6 DLL exposing it via
primitive types (char *, int, etc) and then called that VC6 DLL from
VC8 C++ (mixing managed and unmanaged code). The VC8 C++ assembly is
then easily referenced by/callable from .NET 2.0 C# or other managed
code.
- Don't forget that memory allocated in a VC6 DLL must be freed by
that DLL (cannot be freed by VC8 code). Your VC6 wrapper DLL has to
expose a Delete function if it returns pointers to memory it has
allocated.
- You can set GAPATHOME at runtime (using SetEnvironmentVariable)
without having it already set in the environment if (and only if) you
dynamically load the DLL that is linked to the Paper SDK components,
using LoadLibrary and GetProcAddress. If the DLL's load when your
code (app or DLL) is loaded, and then GAPATHOME is set afterwards, it
is too late.
- A similar trick could be employed (with setcwd to set current
directory) to avoid having to have the Paper SDK lib\dll directory on
your PATH.
Thanks in advance
Mikey
I am developing a web based application in asp.net and am in the
process of trying to integrate a third party application. The third
party application is supplied in the form of a .h file.
The example they provided is also in C++, which uses the .h file in
question. I would like to create a dll from this .h file which i can
then call from my .Net code. They have provided me with the following
advice about creating a wrapper, which i must admit is a little beyond
my current C++ understanding. I would be grateful if someone could
explain the steps a little clearer to me or suggest a possible
solution. I am currently developing in Visual Studio .Net 2003.
Notes about wrapping the Paper SDK for VS7/VS8:
- The Paper SDK lib\dll directory must be in your path.
- GAPATHOME must be properly set to the GAPAT directory installed by
the FDT (or a copy of that directory).
- The Paper SDK cannot be linked to VC8 libraries; the VC6 linker must
be employed. In other words, both the demo code AND the actual Paper
SDK libraries themselves use template library functions which VC8 does
not know about.
- I wrapped Paper SDK functionality in a VC6 DLL exposing it via
primitive types (char *, int, etc) and then called that VC6 DLL from
VC8 C++ (mixing managed and unmanaged code). The VC8 C++ assembly is
then easily referenced by/callable from .NET 2.0 C# or other managed
code.
- Don't forget that memory allocated in a VC6 DLL must be freed by
that DLL (cannot be freed by VC8 code). Your VC6 wrapper DLL has to
expose a Delete function if it returns pointers to memory it has
allocated.
- You can set GAPATHOME at runtime (using SetEnvironmentVariable)
without having it already set in the environment if (and only if) you
dynamically load the DLL that is linked to the Paper SDK components,
using LoadLibrary and GetProcAddress. If the DLL's load when your
code (app or DLL) is loaded, and then GAPATHOME is set afterwards, it
is too late.
- A similar trick could be employed (with setcwd to set current
directory) to avoid having to have the Paper SDK lib\dll directory on
your PATH.
Thanks in advance
Mikey