web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

security error in custom workflow

(0) ShareShare
ReportReport
Posted on by 2,510

Hi, I have added System.Web.Extensions to custom workflow, and it gave me this error, any solution to this problem?

Exception Details Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Unexpected exception from plug-in (Execute): CRM.Workflows.Email: System.MethodAccessException: Attempt by security transparent method 'CRM.Workflows.Email.ExecuteCRMWorkFlowActivity(System.Activities.CodeActivityContext, LocalWorkflowContext)' to access security critical method 'System.Web.Script.Serialization.JavaScriptSerializer..ctor()' failed. Assembly 'CRM.Workflows, Version=1.3.0.0, Culture=neutral, PublicKeyToken=dc437796e33d376f' is partially trusted, which causes the CLR to make it entirely security transparent regardless of any transparency annotations in the assembly itself. In order to access security critical code, this assembly must be fully trusted. Assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is a conditionally APTCA assembly which is not enabled in the current AppDomain. To enable this assembly to be used by partial trust or security transparent code, please add assembly name 'System.Web.Extensions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9' to the the PartialTrustVisibleAssemblies list when creating the AppDomain.Detail: <OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts"> <ActivityId>d0fd30d7-bf05-4a98-9816-4e44ea2f5095</ActivityId> <ErrorCode>-2147220956</ErrorCode> <ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic" /> <Message>Unexpected exception from plug-in (Execute): CRM.Workflows.Email: System.MethodAccessException: Attempt by security transparent method 'CRM.Workflows.Email.ExecuteCRMWorkFlowActivity(System.Activities.CodeActivityContext, LocalWorkflowContext)' to access security critical method 'System.Web.Script.Serialization.JavaScriptSerializer..ctor()' failed. Assembly 'CRM.Workflows, Version=1.3.0.0, Culture=neutral, PublicKeyToken=dc437796e33d376f' is partially trusted, which causes the CLR to make it entirely security transparent regardless of any transparency annotations in the assembly itself. In order to access security critical code, this assembly must be fully trusted. Assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is a conditionally APTCA assembly which is not enabled in the current AppDomain. To enable this assembly to be used by partial trust or security transparent code, please add assembly name 'System.Web.Extensions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9' to the the PartialTrustVisibleAssemblies list when creating the AppDomain.</Message> <Timestamp>2017-11-28T20:37:43.253457Z</Timestamp> <ExceptionRetriable>false</ExceptionRetriable> <ExceptionSource>PluginExecution</ExceptionSource> <InnerFault i:nil="true" /> <OriginalException>System.MethodAccessException at System.Activities.WorkflowApplication.Invoke(Activity activity, IDictionary`2 inputs, WorkflowInstanceExtensionManager extensions, TimeSpan timeout) at System.Activities.WorkflowInvoker.Invoke(Activity workflow, IDictionary`2 inputs, TimeSpan timeout, WorkflowInstanceExtensionManager extensions) at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, String customActivityTypeName, IExecutionContext requestContext, Dictionary`2 sandboxServices, Boolean useDrawbridgeEnabled, Boolean chaosFailAppDomain) at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, String customActivityTypeName, IExecutionContext requestContext, Dictionary`2 sandboxServices, Boolean useDrawbridgeEnabled, Boolean chaosFailAppDomain) at Microsoft.Crm.Sandbox.SandboxWorker.ExecuteCustomWorkflowActivity(SandboxCallInfo callInfo, SandboxCustomActivityExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, SandboxRequestCounter&amp; workerCounter, Boolean returnTraceInfo)</OriginalException> <TraceText> Internal user : 2E1BF026-95AE-E711-A81C-005056B5FEFA,4C42D128-ACAE-E711-A81C-005056B5FEFA Internal List Items : 2E1BF026-95AE-E711-A81C-005056B5FEFA Internal List Items : 4C42D128-ACAE-E711-A81C-005056B5FEFA Internal user: 2E1BF026-95AE-E711-A81C-005056B5FEFA Internal user: 4C42D128-ACAE-E711-A81C-005056B5FEFA finish toParty setup start to setup fromParty system user : c6fd02c2-a6ae-e711-a81c-005056b5fefa From and To parties are set up. {""{template1}"":""car"",""{template2}"":""red""} </TraceText> </OrganizationServiceFault> Server stack trace: at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.Crm.Sandbox.ISandboxHost.ExecuteCustomWorkflowActivityAndReturnTraceInfo(SandboxCallInfo callInfo, SandboxCustomActivityExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String assemblyContents, Boolean returnTraceInfo) at Microsoft.Crm.Sandbox.SandboxCustomActivity.Execute(SandboxClient client, SandboxCallTracker callTracker, IExecutionContext requestContext, String assemblyContents, Boolean returnTraceInfo) at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context) 

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Unexpected exception from plug-in (Execute): CRM.Workflows.Email: System.MethodAccessException: Attempt by security transparent method 'CRM.Workflows.Email.ExecuteCRMWorkFlowActivity(System.Activities.CodeActivityContext, LocalWorkflowContext)' to access security critical method 'System.Web.Script.Serialization.JavaScriptSerializer..ctor()' failed.

Assembly 'CRM.Workflows, Version=1.3.0.0, Culture=neutral, PublicKeyToken=dc437796e33d376f' is partially trusted, which causes the CLR to make it entirely security transparent regardless of any transparency annotations in the assembly itself. In order to access security critical code, this assembly must be fully trusted.

Assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is a conditionally APTCA assembly which is not enabled in the current AppDomain. To enable this assembly to be used by partial trust or security transparent code, please add assembly name 'System.Web.Extensions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9' to the the PartialTrustVisibleAssemblies list when creating the AppDomain.Detail: 
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
 <ActivityId>d0fd30d7-bf05-4a98-9816-4e44ea2f5095</ActivityId>
 <ErrorCode>-2147220956</ErrorCode>
 <ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic" />
 <Message>Unexpected exception from plug-in (Execute): CRM.Workflows.Email: System.MethodAccessException: Attempt by security transparent method 'CRM.Workflows.Email.ExecuteCRMWorkFlowActivity(System.Activities.CodeActivityContext, LocalWorkflowContext)' to access security critical method 'System.Web.Script.Serialization.JavaScriptSerializer..ctor()' failed.

Assembly 'CRM.Workflows, Version=1.3.0.0, Culture=neutral, PublicKeyToken=dc437796e33d376f' is partially trusted, which causes the CLR to make it entirely security transparent regardless of any transparency annotations in the assembly itself. In order to access security critical code, this assembly must be fully trusted.

Assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is a conditionally APTCA assembly which is not enabled in the current AppDomain. To enable this assembly to be used by partial trust or security transparent code, please add assembly name 'System.Web.Extensions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9' to the the PartialTrustVisibleAssemblies list when creating the AppDomain.</Message>


*This post is locked for comments

I have the same question (0)
  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    A few questions:

    What is your custom workflow trying to access? Any external resources?

    In what Isolation mode is your workflow registered (Sandbox or none)?

  • sdnd2000 Profile Picture
    2,510 on at

    So, I am trying to get json format string, and deserialize, it is in sandbox

  • Suggested answer
    ashlega Profile Picture
    34,477 on at

    Hi,

      you'll need to use DataContractJsonSerializer instead:

    www.magnetismsolutions.com/.../how-to-serialize-to-json-in-sandboxed-plugin-for-dynamics-365

  • sdnd2000 Profile Picture
    2,510 on at

    Thanks, but it doesn't look like it is able to deserialize into dictionary directly.

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Can you share your code where you are trying to do this?

    Alex's response is correct. Possibly something has to be modified in your WF code.

  • ashlega Profile Picture
    34,477 on at
  • sdnd2000 Profile Picture
    2,510 on at

    Hi, it is like this,

     string json =@"{ ""{ template1 }"":""car"",""{ template2} "":""red""}";
                        var serializer = new JavaScriptSerializer();
                        Dictionary<string, string> replacements = serializer.Deserialize<Dictionary<string, string>>(json);


  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    System.Web.Extensions is partially trust assembly for the sandbox. You will not be able to make it work.

    Use Newton.Json or System.Runtime.Serialization.Json.

    Good luck.

  • sdnd2000 Profile Picture
    2,510 on at

    Hi, Andrii,

    I'd prefer using newton.json, but I got this error as well

    Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified


  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Seems like you are using an On-Prem environment. Can you add the Newtonsoft.Json to your GAC, and see if that works?

    If that doesn't work, can you test changing your registered workflow from isolated to none.

    I think you might have to change that to get your logic working.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans