Free Support Forum - aspose.com

System.Security.Cryptography.CryptographicException

I've used the Aspose.Excel component inside a C#/Win Forms application to generate Excel sheets. Everything works on my development machine, however, when deploying to the target user desktops I receive the following exception:

System.Security.Cryptography.CryptographicException: CryptoAPI cryptographic service provider (CSP) for this implementation could not be acquired.
at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)
at Aspose.Excel.License.?(XmlNode ?, XmlNode ?)
at Aspose.Excel.License.?(XmlDocument ?)
at Aspose.Excel.License.SetLicense(Stream stream)
at Aspose.Excel.License.SetLicense(String licenseName)
at ML.GSL.Browser.Client.UI.Dialog.ExcelExport.WriteExcelFile(String filepath)

Any ideas on the best approach to resolve?

Thanks,

Alister

Hi Alister,

Please check http://www.aspose.com/wiki/default.aspx/Aspose.Purchase/HowToFixCSPException.html for reference.

Thanks. This doesn't really solve my problem though. I'm using the component from a desktop application not a web app.

My guess is that the Aspose.Excel component explicitly requests to use the machine key store to get around the issues with using the Crypto API from Web Apps & Web Services. For a desktop app this shouldn't be necessery - is there a way to signal to the Aspose component to use the logged on users "application data" folder instead? If not this will be a real deployment headache for us as our user base do not have (and should not need) read/write access to anything under the Documents and Setting\\All Users folder.

Thanks,

Alister

I think this makes sense. I will add a parameter to SetLicense or maybe a property to License to specify whether one wants machine or user key storage used. Give me till tomorrow at least.

Thanks, sounds like excactly what I'm looking for. Will you be able to make this available as a hotfix? Any idea how long it will take to turn around?

Cheers,

Al

I've updated the licensing code so it first tries to use the machine key store and if that fails tries to use the user's key store.

I decided not to expose a flag to control that because it is really an MS issue since Aspose components do not need the key store. It is just the constructor of the RSA provider always tries to create a key wasting CPU time. Hopefully, they will fix it in the future.

Laurence will be able to release a hotfix shortly.

Hi Alister,

Please try this attached hotfix.

Works perfectly - thanks for your help and the rapid turnaround.

Al

Smile [:)]