Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

Azure Xrm Plugin security exception

  • 1.  Azure Xrm Plugin security exception

    TOP CONTRIBUTOR
    Posted 05-07-2018 11:56 AM

    Has anyone been able to use Microsoft.WindowsAzure.Storage in a plugin? I am getting an exception when I tried it. 

    Exception: System.TypeLoadException: Inheritance security rules violated while overriding member: 'Microsoft.WindowsAzure.Storage.StorageException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
    at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
    at System.Reflection.RuntimeAssembly.GetExportedTypes()
    at Microsoft.Xrm.Sdk.KnownProxyTypesProvider.LoadKnownTypes(Assembly assembly)
    at Microsoft.Xrm.Sdk.KnownProxyTypesProvider.RegisterAssembly(Assembly assembly)
    at Microsoft.Xrm.Sdk.AssemblyBasedKnownProxyTypesProvider.GetTypeForName(String name, Assembly proxyTypesAssembly)
    at Microsoft.Xrm.Sdk.ProxySerializationSurrogate.System.Runtime.Serialization.IDataContractSurrogate.GetObjectToSerialize(Object obj, Type targetType)
    at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
    at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
    at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
    at Microsoft.Crm.Sandbox.SandboxUtility.SerializeDataContract[T](T dataContract, Assembly proxyTypesAssembly)
    at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.ExecuteInternal(OrganizationRequest request)
    at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.RetrieveMultipleInternal(QueryBase query)

    Basically I am trying to store a base64 string to Azure blob using a plugin.

    Thanks!



    ------------------------------
    Rex Tan
    Kent OH
    *Always be CURRENT with JavaScript and C#, NEVER be obsolete.

    DISCLAIMER: All views expressed on this site are my own and DO NOT represent the opinions of ANY entity whatsoever with which I have been, am now, or will be affiliated.
    ------------------------------


  • 2.  RE: Azure Xrm Plugin security exception

    Posted 05-09-2018 12:13 PM
    I haven't tried it, but I'm willing to bet this is a sandbox/partial trust issue.

    There is a 'sandboxable' version of Microsoft.WindowsAzure.Storage you could try testing with to confirm, but it's not from Microsoft so I'm not sure I would use it - but it could be helpful to confirm.

    https://www.nuget.org/packages/Sandboxable.Microsoft.WindowsAzure.Storage

    You may instead want to consider triggering some code in Azure (Azure Function webhook, etc) that reaches back to CRM instead of code inside your plugin - code executing there will not be subject to the same limitations and can fully use the standard Microsoft.WindowsAzure.Storage

    ------------------------------
    Ken Heiman
    Consultant
    AKA Enterprise Solutions
    TX
    ------------------------------



  • 3.  RE: Azure Xrm Plugin security exception

    TOP CONTRIBUTOR
    Posted 05-16-2018 12:16 PM
    Thanks Ken!

    ------------------------------
    Rex Tan
    Kent OH
    *Always be CURRENT with JavaScript and C#, NEVER be obsolete.

    DISCLAIMER: All views expressed on this site are my own and DO NOT represent the opinions of ANY entity whatsoever with which I have been, am now, or will be affiliated.
    ------------------------------