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

Community site session details

Session Id :
Customer Service forum

retrieve multiple plugin throws System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

(0) ShareShare
ReportReport
Posted on by

EntityCollection businessEntityCollection = (EntityCollection)context.OutputParameters["BusinessEntityCollection"];

businessEntityCollection.Entities.Clear();


Task<List<Entity>> injectedEntityCollection = IntegrationHelper.GetResponseEntities(organizationService,context.PrimaryEntityName, true, requestId, serviceProvider);
List<Entity> entities = injectedEntityCollection.Result;
// injectedEntityCollection = FilterResponseEntities(injectedEntityCollection, query, serviceProvider, serviceData);

// injectedEntityCollection = SortResponseEntities(injectedEntityCollection, query);

businessEntityCollection.Entities.AddRange(entities);

context.OutputParameters["BusinessEntityCollection"] = businessEntityCollection;

I create retreive multiple plugin and registered on entity. The plugin logic is as below. the plugin code does make a call to one of external web api call and creating collection and assigning the entity collection to businessentity collection. the code works fine while debugging it could inject business entity collection with the list retrieve but not able to render the subgrid and throwing below error. Could you please any one suggest on this? How to proceed this is blocking one of my task.

Unhandled Exception: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.StubHelpers.StubHelpers.DemandPermission(IntPtr pNMD)
at Microsoft.XamlDiagnostics.WpfTap.NativeMethods.GetWindowLong(IntPtr hWnd, Int32 nIndex)
at Microsoft.XamlDiagnostics.WpfTap.WpfVisualTreeService.Adorners.AdornerLayerWindow.get_IsTargetWindowTopmost()
at Microsoft.XamlDiagnostics.WpfTap.WpfVisualTreeService.Adorners.AdornerLayerWindow.BringToTopIfNeeded()
at Microsoft.XamlDiagnostics.WpfTap.WpfVisualTreeService.Adorners.AdornerLayerWindow.UpdatePlacement()
at Microsoft.XamlDiagnostics.WpfTap.WpfVisualTreeService.Adorners.AdornerLayerWindow.<UpdatePlacementAsync>b__77_0(Object obj)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Window.ShowHelper(Object booleanBox)
at System.Windows.Window.ShowDialog()
at Microsoft.Crm.Tools.PluginRegistration.OrganizationControlViewModel.LoadDebugPluginUserControl()
at Microsoft.Crm.Tools.PluginRegistration.OrganizationControlViewModel.Debug_Clicked()

Categories:
I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: retrieve multiple plugin throws System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

    Help on the above query please? while opening the associated view, it returns above security error. where the business entity collection is created from the result of external web api call.

  • Suggested answer
    M I Mostafa Profile Picture
    4,257 on at
    RE: retrieve multiple plugin throws System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

    are you trying to inject business entities into the sub-grid? I'm not sure I understand what you are trying to do.

    However, to me this sounds like a security error either related to not enough privilege for the user you are using or because you are trying to inject data to a sub-grid in a non-supported way.

  • Community Member Profile Picture
    on at
    RE: retrieve multiple plugin throws System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

    Thanks Mohamed for the reply!!

    Yes, you are right I am trying inject the business entities into sub grid via registering RetrieveMultiple plugin on one of my custom entity called transaction. the user got administrator privileges which I am using. I am using Dynamics 365, what is the supported way of clearing and injecting business entity collection for the entity to display in subgrid for display in one of related entity's form.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Customer Service

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans