0

I am creating a C++ Project where I access some properties of PDF using iTextSharp, so I have created a Managed C++ Dll to get values from C# and pass it on to C++.

Now If I keep these two Dlls (iTextSharp and Managed C++ ) in the Executable folder, then everything works fine but if I keep these two Dlls in Custom Folder, then it doesn't. Here is my code.

LPCTSTR wrapperFullPath = "D://New Folder//PDFWrapper.dll";

LPCTSTR iTextFullPath = "D://New Folder//itextsharp.dll";

HMODULE wrapInst = LoadLibraryExA(wrapperFullPath , NULL, LOAD_WITH_ALTERED_SEARCH_PATH);

HMODULE iTextInst = LoadLibraryExA(iTextFullPath , NULL, LOAD_WITH_ALTERED_SEARCH_PATH);

if((wrapInst != NULL) && ((iTextInst != NULL)) {

... // Get PDF Property here - Line 1

}

Now if my iTextSharp Dll is executable folder, then it is OK otherwise it is crash in Line 1 . I tried setting the Environment Variable as well but that didn't helped.

-Pankaj

Pankaj
  • 2,618
  • 3
  • 25
  • 47
  • itextsharp.dll is a managed DLL, you are not supposed to use LoadLibrary on it... – yms Oct 01 '12 at 16:49
  • thanks @yms, then any idea how can I achieve this task that place iTextSharp from some other folder than executable one. ? – Pankaj Oct 01 '12 at 17:29
  • 1
    I think this is what you need: http://stackoverflow.com/questions/1373100/how-to-add-folder-to-assembly-search-path-at-runtime-in-net – yms Oct 01 '12 at 17:34
  • Thanks @yms, but that is done in C#, Any idea how can we achieve it in C++ ? – Pankaj Oct 01 '12 at 17:37
  • It's not C#, it's .Net framework. The same classes are available for you from your managed C++ DLL – yms Oct 01 '12 at 17:38
  • It just saw that PrivateBinPath is available in C++ as well, let me try it now on my code. Thanks @yms.. – Pankaj Oct 01 '12 at 17:40

0 Answers0