Hi
I am getting an error when getting a docx attached to a Note in Dynamics CRM. The error is
An exception of type 'System.Runtime.InteropServices.ExternalException' occurred in Spire.Doc.dll but was not handled in user code
Additional information: Can't open storage on LockBytes.
Here is the code:
CrmServiceClient crmConn = new CrmServiceClient(ConfigurationManager.ConnectionStrings["CRM"].ConnectionString);
IOrganizationService service = crmConn.OrganizationServiceProxy;
var entNote = service.Retrieve("annotation", id, new ColumnSet(true));
if (entNote.Attributes.Contains("filename") && entNote.GetAttributeValue<string>("filename").ToLower().Contains("termsheet") && entNote.GetAttributeValue<EntityReference>("objectid").LogicalName == "esd_project")
{
var strBase64String = Convert.ToBase64String(new UnicodeEncoding().GetBytes(entNote.GetAttributeValue<string>("documentbody")));
byte[] fileContent = Convert.FromBase64String(strBase64String);
using (MemoryStream ms1 = new MemoryStream(fileContent))
{
var a = ms1.CanRead;
Document doc = new Document(ms1);
}
Please help what is wrong. I have added Sprie DLL's using Nuget in Visual Studio and the version is 5.8.76. I am using trial version and if issue is resolved would look into purchasing the product.