Aspose.PDF Triggers Breakpoint

Asked by At

I implemented Aspose.Cells and Aspose.PDF into our companies existing application. While I had some trouble with this (mostly caused by the fact that I tried to implement both APIs into the exat same file which was a bad idea) I figured out how to make it work more or less.

My Problem now is while Aspose.Cells works perfectly fine and doesn't seem to have any unusual behavior Aspose.PDF already struggles with setting the license and even when I eventually got this to work I can't even initiate a Aspose::Pdf::Document.

So the first totally unusual thing is the way I had to set the License in the Example code given with the Aspose Package and in the official resources the license is set like this.

auto lic = System::MakeObject<Aspose::Pdf::License>();
lic->SetlLicense("c:\\Foo\fooproj\\Aspose.Total.C++.lic");

This code won't run on my machine and cause the error.

Rough Translation

food.exe triggered a breakpoint

Original

food.exe Hat einen Haltepunkt ausgelöst

The same happens when I initialise a System::String with a emtpy constructor like this.

 auto lic = System::MakeObject<Aspose::Pdf::License>();
 System::String str;
 str.FromUtf8("C:\\foo\fooproj\\Aspose.Total.C++.lic");
 lic->SetLicense(str);

BUT if I initialise the System::String with an empty String in the first place setting the license seems to work just fine so this works.

 auto lic = System::MakeObject<Aspose::Pdf::License>();
 System::String str(u"");
 str.FromUtf8("C:\\Projekte\\Aspose\\Lizens\\Aspose.Total.C++.lic");
 lic->SetLicense(str);

If this code above works and I try to make an object from Aspose::Pdf::Document this will crash.

void Aspose_pdf::helloWorld()
{
  auto doc = System::MakeObject<Aspose::Pdf::Document>();
.....
.....
}

I actually have no idea what's going on. I am not using any using namespace commands at the moment. Would be greate if someone had an idea how to fix this.

Edit: The error occures exactly in smart_ptr.h in the following function.

typename std::enable_if<!IsSmartPtr<T>::value, SmartPtr<T> >::type  MakeObject(Args&&... args)
{
    System::Detail::OwnNextObject ownershipSentry;
    T *const object = ::new T(std::forward<Args>(args)...);
    ownershipSentry.CreatedSuccessfully(object);
    return SmartPtr<T>(object);
}

in the second line so T *const object = ::new T(std::forward<Args>(args)...); is "causing" the error or atleast here the error will ne triggered.

Edit2:

Here you will find a simple example of how my code looks in general. I Started with implementing Aspose.Pdf into my Programm so I edited my Additional Library directories,additional dependencies, additional include directories,preprozessor definitions and my stacksize to fit these settings given in the Aspose.Pdf examples. After this I created my Aspose_Pdf class and tested it. worked perferctly so far. After this I made the same edits to fit Aspose.Cells aswell. Also I created a class Aspose_Cells and tested it. While this worked now my Aspose_Pdf class stoped working. After a little time passed I managed to atleast get the License Activation for Aspose_Pdf to work from this point on I had the problems described above.

Additional Dependencies:

   ...
    Aspose.PDF_vc141x64d.lib
    aspose_cpp_vc141x64d.lib
    Aspose.Cells.lib

Additional Librariedirectories:

   ...
    ..\Aspose\Aspose.PDF\lib\Debug
    ..\Aspose\Aspose.Cells\lib64

additional Includedirectories

 ...
    ..\Aspose\Aspose.PDF\lib\Debug
    ..\Aspose\Aspose.PDF\include\asposecpplib
    ..\Aspose\Aspose.PDF\include\Aspose.Pdf.Cpp
    ..\Aspose\Aspose.Cells\Include
    ..\Aspose\Aspose.Cells\Include\icu\include
    ..\Aspose\Aspose.Cells\Include\boost

1 Answers

0
Sergey Shevchenko On

I've never heard about Aspose.Pdf neither I know how does System::MakeObject< work. But for me it looks that all the code might be simplified to next:

Aspose::Pdf::License^ lic = gcnew Aspose::Pdf::License();
System::String^ str = "C:\\foo\\fooproj\\Aspose.Total.C++.lic";
lic->SetLicense(str);

When it comes to Pdf.Document the initialization might look like this:

Aspose::Pdf::Document^ doc = gcnew Aspose::Pdf::Document();