Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)

1

I have a winforms app that is using reflection to load up assembly X. It runs great from my local machine, but craps out when run from a network share. I created a code group granting full trust(for testing only) to assemblies from the share (by specifying the url property). The app now launches up. However, it bombs when I try to perform an operation that requires X to access a dependent assembly Y with the following error:

Could not load file or assembly 'Bloomberg.Api, Version=1.8.0.3, 

Culture=neutral, PublicKeyToken=65c07ea3148235aa' or one of its dependencies. Failed to grant minimum 

permission requests. (Exception from HRESULT: 0x80131417)

I am loading assembly X into an appdomain using the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.IO;
using System.Reflection;
using TCPSecurityMaster;
using System.Windows.Forms;
using System.Security.Policy;
using System.Security;
using System.Security.Permissions;

namespace SecurityMasterReflectionTest
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                AppDomainSetup ads = new AppDomainSetup();
                ads.ApplicationBase = ConfigurationManager.AppSettings["SecurityMasterBinDir"];
                ads.ConfigurationFile = Assembly.GetEntryAssembly().Location + ".config";
                AppDomain newAD = AppDomain.CreateDomain("SM", null, ads);


                string dir = ConfigurationManager.AppSettings["SecurityMasterBinDir"];
                string asmName = dir + "\\" + ConfigurationManager.AppSettings["SecurityMasterFacadeAssemblyName"];
                string typeName = ConfigurationManager.AppSettings["SecurityMasterFacadeClassName"];
                if (File.Exists(asmName))
                {
                    object obj = (ISecurityMasterAPI)newAD.CreateInstanceFromAndUnwrap(asmName, typeName);
                    ISecurityMasterAPI api = obj as ISecurityMasterAPI;
                    api.Initialize();
                    Form f = api.GetSecurityDetailDialog(35516);
                    f.ShowDialog();// this works, but a subsequent operation that requires assembly Y to be loaded doesn't
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}

I would have imagined that granting full trust to all assemblies under the network share would have taken care of any CAS issues. Any hints appreciated.

-- UPDATE

In my code group, I had specified permission set as 'Everything' instead of 'Full Trust'. Changing to 'Full Trust' fixed the error. However, I am still mystified that I have to tweak CAS just for using reflection, while non-reflection code works fine over the network. Isn't there a programmatic way of saying "I fully trust this assembly I loaded over the network."? Any light shed on this appreciated.

c#
.net
reflection
cas
asked on Stack Overflow Dec 30, 2010 by cs31415 • edited Dec 30, 2010 by cs31415

2 Answers

1

After DLL are uploaded on internet and downloaded, they go in trust issues. Those needs to explicitly unblocked by going into Properties and click the "unblock" button and the problem may be solved.

enter image description here

answered on Stack Overflow Jan 28, 2020 by Vaibhav Jain
0

I received the same error in powershell, when I ran the line below:

Add-Type -Path WinSCPnet.dll

All I had to do to fix this issue is update powershell to v3.

http://www.microsoft.com/en-us/download/details.aspx?id=34595

When I tried to Adjust Zone Security settings(https://social.msdn.microsoft.com/Forums/en-US/d5135c8b-7629-464b-9078-8c179010ea82/minimum-permission-requests?forum=vblanguage), I couldn't find the .Net Framework Configuration tool. I think I couldn't find it, because my default .Net framework is 4.0.

answered on Stack Overflow Jun 17, 2015 by JPlatts

User contributions licensed under CC BY-SA 3.0