I'm attempting to set the entityimage in CRM online using SampleCode\CS\GeneralProgramming\LateBound\EntityImages.cs from the sdk as a baseline. However, the File.ReadAllBytes() is throwing a security error. I'm assuming that the System.IO cannot be used in isolation mode, so is there a way to programmatically set the entity image in CRM online?
Here's what I have:
var EntID = context.PrimaryEntityId;
var EntName = context.PrimaryEntityName;
ColumnSet cols = new ColumnSet(
new String[] { "entityimage", "asi_businessline" });
 
//Get the Record
Entity tr = service.Retrieve(EntName, EntID, cols);
string busLine = tr.FormattedValues["asi_businessline"].ToString();
switch (busLine)
{
case "Neebo":
case "NMRP":
{
tr["entityimage"] = File.ReadAllBytes("//WebResources/asi_NEBookLogo.png");
break;
}
case "Textbook Underground":
tr["entityimage"] = File.ReadAllBytes("northendteleservices.crm.dynamics.com/.../asi_TULogo.png");
break;
default:
tr["entityimage"] = null;
break;
}
service.Update(tr);
And the error:
Exception: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.