Common Language Specification (CLS) compliance in Aspose.Email (C# .NET)

Hi,

I am encountering the following message when attempting to use/access the object that is created after using the Email.MailMessage.Load method:

The field or property: “Cc” for type: “Aspose.Email.MailMessage” differs only in letter casing from the field or property: “CC”. The type must be Common Language Specification (CLS) compliant.

The Load method appears to work, but I am unable to do anything with the object that is created. I am using PowerShell to access the Aspose libraries and the code that generates this issue is as follows:

$stream = [System.IO.MemoryStream]::new()
$message = [Aspose.Email.MailMessage]::Load($msgFile);
$message.Save( $stream, [Aspose.Email.MailMessageSaveType]::MHtmlFormat )

I also tried using MsgLoadOptions with the Load method, but I am still getting the same CLS compliance error.

Can anyone provide advice on how I can overcome this apparent CLS compliance issue?

Thanks and regards,

Chris

@whitec,

Can you please share source files along with complete working sample code so that we may further investigate to help you out.

Hi Adnan,

Thanks for offering to help. The code that generates the error is as follows:

$asposeAPIDir = "C:\Projects\Powershell\Aspose APIs"
$emailDLL = "$($asposeAPIDir)\Aspose.Email.dll"
$asposeLicense  = "$($asposeAPIDir)\Aspose.Total.lic"
[void] [System.Reflection.Assembly]::LoadFile("$($emailDLL)")
$emailLicense = [Aspose.Email.License]::new()
$emailLicense.SetLicense("$($asposeLicense)")
$msgFile = "C:\Projects\Test Files\test-email.msg"
$stream = [System.IO.MemoryStream]::new()
$message = [Aspose.Email.MailMessage]::Load($msgFile);
$message.Save( $stream, [Aspose.Email.MailMessageSaveType]::MHtmlFormat )

Please note that the CLS Compliance error appears to be being caused by the implementation of the Aspose.Email API itself, as it does not appear to be CLS compliant because it contains methods that reference properties that have character case variations in their names (e.g., ‘Cc’ vs ‘CC’).

Kind regards,

Chris

@whitec,

As requested earlier, can you please share source file which is causing issue on your end to further investigate and help you out.

Projects.zip (2.6 MB)

I’ve uploaded a copy of the Powershell script, Aspose.email.dll, and the test .msg file.

@whitec,

We are working on this and will get back to you with feedback soon.

Just wondering if there’s been any progress in resolving this issue?

I’ve been able to work around the issue to an extent by executing C# code directly within my PowerShell script, however, doing so is onerous as the PowerShell environment needs to be reset after each change to the C# code. This reset is required because the C# assembly that is created using the Add-Type commandlet cannot be modified and reloaded into, or unloaded from, the System.AppDomain.

@whitec,

An issue with ID EMAILNET-39500 has already been added in our issue tracking system as investigation to further investigate the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

@mudassir.fayyaz

Thanks for the update.

The issues you have found earlier (filed as EMAILNET-39500) have been fixed in this update.

I downloaded version 19.6 of the aspose.email.dll and am no longer encountering the CLS compliance issues when using it with Powershell.

Thanks for fixing this issue.

@whitec,

Thank you for sharing positive feedback.