We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Unable to create Aspose.Net Objects in unit tests

We have a licensed version of the Aspose.Net email libraries. We have been using version 5.4 in our product which includes a number of unit tests. We recently decided to update the Aspose library to 5.9. Unfortunately, as soon as we did, any unit tests we had which included an Aspose object started failing with an error message similar to the following:

Test Name: Aspose59UnitTestFailure.UnitTests59.CreateAsposeObject_ObjectIsCreatedSuccessfully
Test FullName: Aspose59UnitTestFailure.UnitTests59.CreateAsposeObject_ObjectIsCreatedSuccessfully
Test Source: f:\AsposeUnitTestFailure\Aspose59UnitTestFailure.UnitTests\UnitTests59.cs : line 10
Test Outcome: Failed
Test Duration: 0:00:00.465

Result Message: System.InvalidProgramException : Common Language Runtime detected an invalid program.
Result StackTrace:
at Aspose.Email.Outlook.MapiTask…ctor()
at Aspose59UnitTestFailure.UnitTests59.CreateAsposeObject_ObjectIsCreatedSuccessfully() in f:\AsposeUnitTestFailure\Aspose59UnitTestFailure.UnitTests\UnitTests59.cs:line 11


We have tried using versions 5.9/5.8/5.7 with net2/net3.5/net4, but all fail with the same exception. Only versions 5.4 and 5.6 seem to work.

Our application is currently running .Net 4.5.2 and we are building for “AnyCPU.” We are using Xunit as our testing framework. We have tried using both the Microsoft and ReSharper test runners, but both fail in an identical fashion.

I should mention that the Aspose objects do get created successfully in the application itself, it’s just in the unit test runner where the object construction results in an exception.

I have attached a zip file containing a Visual Studio 2013 solution which demonstrates the issue. It can be used with the build Microsoft Test Runner.

Hi,


Thank you for writing to Aspose Support team.

Can you please share with us how to reproduce this issue at our end? We have compiled your sample application at our end and it compiles fine without any issue. There is no error raised. Could you please share with us if this raises errors at compile time at your end?

The tests build without issue. It’s when the tests execute that the error occurs:

  1. Open Visual Studio 2013 (I’m using Visual Studio Professional)
  2. From the menu select "Test > Run > All Tests"
This will execute the tests using the Microsoft Test Runner. One of the tests will pass, the other will fail. Please see the attached image as an example.

Hi,


Thank you for sharing the additional information. We are currently investigating the issue at our end and shall share our feedback with you soon.

Hi,


We have tested this issue at our end with a number of systems but are unable to reproduce the problem at our side. The issue has been tested on different systems with VS 2012 and 2013, and specific .NET environments. Can you please try the same test on another PC and share your feedback with us?

We have attempted to run it on a number of different machines here, and most of them failed. However, we did find one machine where this has worked. We will investigate further and get back to you.


Please leave this ticket open, and I will report our findings next week.

Hi,


Please feel free to write to us once your investigation is complete. We shall assist you further after your feedback.

After experimenting on different development machines in the office, we have been able to determine that the issue only occurs if Typemock is installed and Mocking Integration has been enabled in Visual Studio. If I disable Mocking Integration both tests pass.



Hi,

Thank you for sharing your feedback.

We have downloaded the Typemock and installed it at our end. After this, we have run the tests from your sample application and no error/exception is raised. Could you please re-verify if Typemock is the only reason behind this? We assume that after installing, Typemock is enabled by default in Visual studio. If it is not so, could you please guide us how to enable it in Visual Studio?

You will also need to do the following:


Integrate with other runners:
1) Open the “Typemock” menu in Visual Studio’s menu bar
2) Ensure “Integrate with other runners” is selected.


Ensure “Mocking Integration” is turned on:
1) Open the “Typemock” menu in Visual Studio’s menu bar
2) Select "Options"
3) In the resulting dialog, browse to "Typemock > Mocking Integration"
4) Ensure “Enable Mocking integration” is selected.


Hi,


Thank you for sharing the additional information.

We were able to reproduce this issue at our end using the latest version of the API i.e. 5.9.0 and have logged it as EMAILNET-35052 in our issue tracking system. Our product team will investigate the issue and we shall update you here once there is some information available about this problem.

What is the state of the bug EMAILNET-35052 ?

We wanted to update Aspose.Email but following Versions did not run in our tests (using TypeMock Version 8.5)
- Aspose.Email 17.1, 16.12, 16.10, 6.9

As @BigGriz23 wrote, version 5.6 seems to be the latest without the reported problems.

Hi,


We have checked the status of this issue and have found that it has been postponed due to the complexity involved. At present, there is no ETA available for resolution of this issue. We have requested our Product team about the same. If there will be a change in plan for resolving this issue targeting a definite timeline, we’ll update you here via this forum thread.

Hi,

Yesterday i had the same problem with Aspose.Email 17.8

And @BigGriz23 solution worked for me but this is not good, because i can not disable TypeMock.

I want to know if someone working to solve this problem, because is quite big problem if every test involve this library is broken. :slight_smile:

@Kodofix,

Thank you for contacting Aspose support team.

As mentioned in the previous post, we are afraid that still this issue is in queue for analysis and any update in this regard will be posted here immediately. We are sorry for the inconvenience caused in this regard.