Copy link to clipboard
Copied
Hello,
I am developing a plugin for Adobe Reader which has to interact with an external web service.
To interact with this web service, I'd like to use the C++ REST SDK, hence I have to include its library in my plugin.
As soon as I add a source file using any C++ REST SDK object in my plugin, it will compile, load in Adobe Reader and unload as soon as it starts.
If I just include the library in the source file, it runs normally. I tested my source file in another project and it works well.
The only clue I get about this unloading is the following lines in the output of Adobe Reader (debugged in Visual Studio):
'AcroRd32.exe' (Win32): Loaded 'C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\plug_ins\MyPlugin.api'. Symbols loaded.
'AcroRd32.exe' (Win32): Unloaded 'C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\plug_ins\MyPlugin.api'
Exception thrown at 0x7795A9F2 in AcroRd32.exe: Microsoft C++ exception: _ASExceptionInfo at memory location 0x005FD664.
My plugin is successfully signed for Adobe Reader (I have a RIKLA key), it's based on the BasicPlugin sample, and I checked that the C++ Rest SDK is correctly included in the MyPlugin.api file.
I also haven't found any information about such an "AsExceptionInfo" anywhere.
Do you have any idea about how I could solve this problem?
Thanks in advance for you answers.
You’ve been saying library – which to me implies a STATICALLY linked library. But are you instead referring to a DLL? If so, then I suspect your problem, as TSN says, is that you aren’t putting the DLL in the right place to be properly loaded!
Copy link to clipboard
Copied
Does the plugin work in Acrobat?
Do you have Sandboxing or Protected Mode enabled in Reader?
Copy link to clipboard
Copied
I haven't and cannot test the plugin in Acrobat.
Both of those modes are disabled.
Copy link to clipboard
Copied
Why can you not test the plugin in Acrobat? All plugin development – even/especially for Reader – should be done in Acrobat.
Without knowing what the 3rd party library does, and what your code is doing, it’s really impossible us to know why the crash. Offhand, I would first start by checking all your error handling, especially making sure you aren’t mixing exception models (aka try/catch vs. DURING/HANDLER). Next I would use your source debugger to walk through the code and see where the problem occurs and if you can get more info about the crash.
Copy link to clipboard
Copied
Ok, I thought that I could just use Adobe Reader since it is my target application.
I based my plugin on the BasicPlugin sample, I haven't done any modification to its code: I just added my source including the C++ REST SDK to the Visual Studio project. I never call any method of the source that I added, actually I never even include it in "BasicPlugin.cpp" or "BasicPluginInint.cpp".
I only remarked that if I never called any C++ REST SDK function in the source that I added, the plugin didn't unload.
Which part of the documentation is explaining the difference between try/catch and DURING/HANDLER?
Is the possibility to walk through the code only available with Adobe Acrobat? Because when I try to place breakpoints in my code in Visual Studio and launch Adobe Reader from it, they don't seem to be reachable.
Copy link to clipboard
Copied
Well, I can’t speak for using Reader, since you’re not supposed to be doing development in Reader…
Actually, your original message made it clear that an “Exception thrown”, which is why I pointed to that area. However, if you arent’ actually calling anything in that library – that would imply to me that the library is doing some static initialization that is not acceptable. You should contact the developers of that library about the use of it outside of an application.
Copy link to clipboard
Copied
I have tried running my plugin in Acrobat and got the same result. I also tried including another library (libcurl) and the result was the same.
Is it then forbidden to use external libraries in plugins? Or are we supposed to declare them somewhere?
Copy link to clipboard
Copied
No, it’s perfectly fine to use 3rd party libraries. Our customers have been doing it for decades.
If you got the same problem in Acrobat, then the problem is definitely on your end. As metnioen before, you will need to use standard debugging techniques (logging, breakpoints, etc.)
Copy link to clipboard
Copied
Alright.
Well, when a library is included but not called, I can use the debugger and go through my code. As soon as I call any function of a library, all my breakpoints become useless (Visual Studio says that "The breakpoint will not currently be hit. No symbol have been loaded for this document.").
I tried putting a breakpoint in the PIHandshake and/or PluginInit methods, and none of them are reached. I guess that my plugin fails before it even runs then, right? If so, how can I get more details about my Exception?
Copy link to clipboard
Copied
A common issue is library search order. Especially assuming a DLL in the same folder as the plugin will be found. Depends.exe can be your friend.
Copy link to clipboard
Copied
You’ve been saying library – which to me implies a STATICALLY linked library. But are you instead referring to a DLL? If so, then I suspect your problem, as TSN says, is that you aren’t putting the DLL in the right place to be properly loaded!
Copy link to clipboard
Copied
I am indeed referring to a DLL and that must be the problem!
Should the DLL be placed in the plug_ins folder, in the executable's folder, or somewhere else?
Copy link to clipboard
Copied
You need to follow the rules of DLL searching. A plug-in is a DLL, and loading a DLL does not update the DLL search order. So a DLL in the plug_ins folder is not found. A DLL in the Acrobat EXE folder might be found, but it would be absolutely wrong to modify Acrobat's EXE folder in this way. So you either need to install it in the standard system folders, or load it yourself with LoadLibrary etc.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now