Total for C++ 20.2 crashed with dynamic loading

@kngstr

Would you please share a bit more about the issue. Please share some code snippet which used to work before and now its not working. We will further proceed to assist you accordingly.

@asad.ali

Something like this:

@kngstr

It is recommended to use System::StaticCast, System::DynamicCast to cast SharedPtr<SaveOptions> to SharedPtr<DocSaveOptions>. Furthermore, we are looking into the issue related to RTTI and will get back to you soon.

@asad.ali

I tried youer advice, but it didn’t work.
Can you help to write a sample?

Thanks.

@kngstr

We are gathering information on this scenario and will get back to you soon.

@kngstr

RTTI has not been hided and this example works well with latest version of the API.

#include <iostream>
#include <typeinfo>
#include "Aspose.PDF.Cpp/DocSaveOptions.h"

using namespace System;
using namespace Aspose::Pdf;

void test(Aspose::Pdf::SaveOptions* p)
{
    std::cout << (typeid(*p) == typeid(Aspose::Pdf::DocSaveOptions) ? "true" : "false") << std::endl;
}

int main()
{
    auto op = MakeObject<DocSaveOptions>();
    test(op.get());
}

cast_example.zip (619 Bytes)

@asad.ali

Thanks.
I wrote a demo. Testsdk.zip (22.7 KB)

It worked fine with 20.1.
And does not work since 20.2.

@kngstr

We would also like to share with you that Aspose.PDF for C++ ( asposecpplib ) has its own RTTI, please consider next usage:

void RTTITest()
{
    auto options = MakeObject<DocSaveOptions>();
    const TypeInfo& ti = options->GetType();
    std::cout << ti.get_Name().ToUtf8String() << std::endl;
    std::cout << ti.get_FullName().ToUtf8String() << std::endl;
}

Please try it using Aspose.PDF for C++ 20.3 and let us know about your feedback.

@asad.ali

Thanks.
But it doesn’t work. I tested it a few days ago.

BTW: Which change makes this difference?

@kngstr

We are checking the related information at our end and will get back to you shortly.

@kngstr

We have checked the sample application that you have shared. You should set “Stack Reserve Size” linker option for both Dll1 and TestSDK projects. For Dll1 project, this option is set through imported aspose.pdf.cpp.targets and for TestSDK, this option should be set manually.

picturemessage_g00mdcu1.b2r.png (7.5 KB)
picturemessage_jk1vnbzc.5id.png (35.4 KB)

@asad.ali

Sorry. I forgot to say that you have to click menu: File - Test.
Stack Reserve Size does not work for me.

This is just loading dll successfully

---------success

@kngstr

We will check the scenario again as per your response and will share our feedback with you soon.

@kngstr

Issue is that you create DocSaveOptions* in DocSaveOptions_Create but use it as SaveOptions* in MyAsposePDFTest.

Please consider the next changes in dllmain.cpp. dllmain.zip (864 Bytes)

@asad.ali

With this method, the output file is invalid. It seems not work.

@kngstr

Would you kindly share your sample source and output document for our reference. We will test the scenario in our environment and address it accordingly.

@asad.ali

Thanks.
It’s my fault.
Works but just too complecatied.