Free Support Forum - aspose.com

C++ Throwing Exception


#1

I’m using the latest version of Aspose Cells C++ and keep getting a Aspose::Cells::System::ObjectDisposedException with this very simple code:

StringPtr dirPath = new String(“test.xlsx”);
try {
intrusive_ptr workBook = Factory::CreateIWorkbook(dirPath);
intrusive_ptr workSheet = workBook->GetIWorksheets()->GetObjectByIndex(0);
}
catch (Aspose::Cells::System::ObjectDisposedException &e) {
Console::WriteLine(e.GetMessageExp());
}

The exception message just says “ObjectDisposed_StreamClosed”

Any ideas? Thanks!


#2

@akerfonta,

Thanks for your query.

I have tried to reproduce the scenario using one of my sample file with the latest version Aspose.Cells for C++ 19.1 but could not observe any issue. Slight changes are done in code as it was not compiling at my end. Notice the change where intrusive_ptr is provided with argument. Please try the following sample code and provide the feedback.

StringPtr dirPath = new String("test.xlsx");
try {
	intrusive_ptr<IWorkbook> workBook = Factory::CreateIWorkbook(dirPath);
	intrusive_ptr<IWorksheet> workSheet = workBook->GetIWorksheets()->GetObjectByIndex(0);
}
catch (Aspose::Cells::System::ObjectDisposedException &e) {
	Console::WriteLine(e.GetMessageExp());
}

#3

I really appreciate the change you proposed.

Unfortunately, I get the same exception when I run it. Any more ideas?

Thanks again!


#4

@akerfonta,

You may please download a working project from the following GitHub repo and test your scenario.


#5

The sample works for me, but it raises a question: is the runtime library for Aspose Cells C++ MT (Multi-threaded) only?
I’m wondering if my issues are caused by my existing project using MD (multi-threaded DLL). We use Qt and it doesn’t seem super practical to switch to MT.

Thanks again for the help!

Edit - If I build the sample with either MD or MDd, it throws exceptions when I try to run it.


#6

@akerfonta,

We are gathering information in this regard and will write back here soon to provide our feedback.


#7

@akerfonta,

We are evaluating this issue but still not clear about it. You may post us simple standalone VS.NET C++ project to reproduce the issue. Also provide details or steps (involved) or other options/details, so we could evaluate your issue and provide assistance.


#8

I have attached a very slightly modified version of the Cells example. When switched to MDd from MT, it throws an exception at line 47 in main().
Here’s what the output shows for me (this is also what we see in our application when we try to add Cells):
HEAP[CellsCPP.exe]: Invalid address specified to RtlValidateHeap( 0000022E18ED0000, 0000022E1CD0F990 )

I’m building this in VS 2017 on Windows 10. Simply build and then start debugging to reproduce. Switch back to MT and it runs perfectly.

Thanks!


#10

@akerfonta ,
It seems that sample project is not attached properly as no link is available. Please zip the project and attach it again. If its little larger in size, please upload it on some public file sharing server and share the link here.


#11

Sorry about that. Here is a link:


#12

@akerfonta,

Thank you for the sample project. We will look into it and provide our feedback after analysis.


#13

@akerfonta,

I have analyzed the sample project which is compiled in VS 2017. You mentioned that it is slightly modified. Please provide the details of modifications which you have performed in this project. Apparently you have trimmed down the main function and added some code at the end of the main function to test your scenario. If there is any other change, please share those details like adding/changing some references or linking some other library etc.

You have shared the complete examples project (229MB) for testing. Is it possible to remove all the unnecessary projects/resources and just reduce it to the minimum possible code which can be used to re-produce the scenario here?

Little time is required to prepare the testing environment as I have VS 2015 at my test machines. Is it possible for you to reproduce this issue on some of your machine having VS2015? If yes please check it and share the modified project.


#14

The changes to the main function are the only ones.

However, I tried running the Aspose example project (link above in this thread). It runs fine as it is, but if I switch to MDd rather than MT or MTd it throws an exception exactly like the code I uploaded. I made no other changes to your project. This is, once again, in VS2017.

Unfortunately, I do not have VS2015 to test on and our software requires VS2017, so we really need Cells to work on VS2017 with MD.

Thank you again for all the help.


#15

@akerfonta,

Thank you for providing more details. Please spare us time to configure the environment for testing this issue at our end. In the meanwhile you may please send us the details about switching to MDd, MT and MTd along with the steps and images for our assistance. We will analyse the information and provide our assistance at the earliest.

We are sorry for the inconvenience caused to you in this regard.


#16

All that I did was load the sample project in VS 2017 and then followed these steps:

  1. Right click on the project name (CellsCPP)
  2. Select Properties
  3. Select C/C++
  4. Select Code Generation
  5. Change Runtime Library from “Multi-threaded (/MT)” to either “Multi-threaded DLL (/MD)” or “Multi-threaded debug DLL (/MDd)”
  6. Rebuild and run project

See this image for project setting:
Aspose Sample Settings.PNG (33.8 KB)

See this image for exception:
Aspose Sample Exception.PNG (141.9 KB)

Let me know if there are more details I can supply. Many thanks!


#17

@akerfonta,

Thanks for the details.

We are looking into it and will provide our feedback after analysis.


#18

@akerfonta,

We were able to observe the issue with ( Multi-threaded debug DLL (/MDd)) only but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSCPP-204 - Exception raised for Runtime Library:Multi-threaded debug DLL (/MDd)

#19

@akerfonta,

Well, we do publish Aspose.Cells for C++ DLL in MD mode. This can minimize the DLL size. For your application (EXE), I am afraid, you cannot use MDd mode. Since these two modes (MD mode and MDd mode) use different CRT. If you use the library MDd , it might cause some runtime error. We recommend you to use MD mode for your program if possible.