We had one non-reproducable in our environment exception from our clients which stoped any work with documents.
Aspose.Words v6.1.0.0
Exception environment:
Windows Server 2003 SP2
Framework 2.0 SP1
Exception: System.IndexOutOfRangeException
Message: Index was outside the bounds of the array.
Data: System.Collections.ListDictionaryInternal
Source: mscorlib
Stack trace:
at System.Collections.ArrayList.get_Item(Int32 index)
at ?.?.?(Stream ?)
at Aspose.Words.License.SetLicense(Stream stream)
Quick downgrade to version 6.0.1.0 resolved problem. Upgrade to version 6.2.0.0 in this issue wasn’t available for us because where some bugs in 6.2.0.0 version which needs to be overriden with lot of code.
I understand that this is not reproducible bug, bet please review this code area because this is a key feature (license set) for working with documents.
Thanks for your request. We did not change anything in the code of applying license. Maybe there is something wrong with license file. Could you please send me the license file as described here? https://forum.aspose.com/t/aspose-words-faq/2711
Best regards.
License worked and works now fine, file is correct. I checked digital signature of Aspose.Words.dll (as CRC verify) - file is OK. And checked our library with license file embeded - it was without changes too. May be it’s possible to generate some specialized exception like LicenseNotValid and LicenseIsCorrupt for best handling…
This is really odd. Just to confirm, you have told that license works fine with Aspose.Words 6.0.1 and 6.2.0 and does not work with 6.1.0. Right?
Best regards.
Right. License works fine with all tested versions (6.0.0.0, 6.0.1.0, 6.1.0.0, 6.2.0.0) in my environment and client’s environment. But from some time described exceptions occured. Client’s hardware and software configuration doesn’t changed before exception and doesn’t damaged (already tested). I have no idea for this issue.
I tested SetLicense method and I see that method throws XML exception if Stream is new and empty. How about throwing some like “InvalidLicenseFormat” exception if any of which described exception occurs. I shall be able to provide a more readable error messages by handling this exception type.
Thanks. I have one question about described exception in first post. May be you be able to provide me any version about it - which error in license format may result to exception in this call stack position:
at System.Collections.ArrayList.get_Item(Int32 index)
And I shall try to detect which invalid data was send to SendLicense method. I just want to analyze any cause.
Thanks for your request. Unfortunately, I have no idea why this exception can occur. I tried to reproduce the problem on my side using different approaches but cannot get this exception.
Best regards.
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Data: System.Collections.ListDictionaryInternal
Stack trace:
at ?.?.?(Stream ?)
at Aspose.Words.License.SetLicense(Stream stream)
I think the reason for the problem is that you call SetLicense on multiple threads. The first thread might be loading an internal resource into a static variable and I now see that this operation is not guarded for multithreading in our code.
SetLicense by design should be called only once. Calling it multiple times was supposed to be safe but we never expected it to be called from different threads.
So you can fix the problem if you make sure SetLicense is called only once.
In the meantime I logged an issue #7879 to make it safe for multithreading just so nobody has this problem ever again.
I also want to answer the earlier question about throwing a license error specific exception class. I want to say that we will not make a special license exception class due to security reasons.
I am also getting this error. I have a solution that contains 3 console applications and a web service. I also created a pdf util class within the solution that handles all the Aspose stuff. So i am setting the license within that class…I am also threading the console apps and get this error when multiple threads are setting the license around the same time. Any idea when the next update will include thread safe SetLicense method or can you provide an example of setting the license one time in the console app but the aspose libraries are being referenced in a different class within the solution?
Thanks for your request. The issue # 7879 is not resolved yet. You will be notified as soon as the issue is resolved. For now, you can try do as Alexander suggested.
Best regards.
So by doing this when spawning multiple threads (cause each thread will instantiate Class1), some threads will be instantiating Class1 at the same time, I will no longer have the contention when setting the license???
I’m getting an exception while setting the license for Aspose.Words and I believe it might be caused by multithreading issues.
We use Aspose.Words (as well as other Aspose DLLs) in ASP.NET applications. In our enviroment multiple web applications access our DLL which contains a static method for setting the Aspose licenses.
I’m using Aspose.Words 5.3.0 and I noticed the latest release is 7.0.0. Was there any significant improvements regarding setting licenses between these releases?
Could I have access to some debug version of the Aspose.Words DLL in order to get more detailed information on the exception I’m getting? The stack trace I’m getting doesn’t say much.
Thanks for your request. There is not debug versions of Aspose.Words. So please provide me your stack trace.
Also, maybe you should apply the license in your Web application on Application_Start event as described here: https://docs.aspose.com/words/net/licensing/
Best regards.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.