Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

Workflow activity to set entity image

$
0
0

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 = newColumnSet(

newString[] { "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.


Viewing all articles
Browse latest Browse all 55831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>