Failed to grant minimum permission requests when calling C# library from C++/CLI DLL from local console app

4

This question follows on from Assembly does not allow partially trusted callers when using a custom resolver

Thanks to the solution in that question I am now able to call into a C# Library on a network share from a local console application (with no changes to CasPol)

I now need to take the next step which is calling the C# Library from another mixed C++/CLI DLL that is in the same folder on the network as the C# Library. The C++/CLI DLL will be called by the local console application.

I'm using the same custom handler in question above (ie. with evidence) that works when calling into a C# library fromn a local console application.

When calling into the C++/CLI library from the local Console application I get the following exception:

Could not load file or assembly 'MyCplusplusCLILib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)

If I fully trust the network location it works correctly however I do not understand why I need to grant this trust when according to changes in 3.5 SP1 the Intranet should no longer require FullTrust to be applied to it (all libraries are compiled for .NET 3.5 in the Visual Studio options)

c#
.net
c++-cli
asked on Stack Overflow Feb 13, 2012 by TownCube • edited May 23, 2017 by Community

2 Answers

6

The cases where you don't get FullTrust are listed at the bottom of this blog post:

  1. Assemblies loaded from a subdirectory of the share where the .exe was launched from
  2. Assemblies loaded from shares other than the one where the main .exe was launched
  3. Any assembly loaded on a machine with the LegacyMyComputer registry value set to 1
  4. Any assembly loaded into a CLR host, including assemblies loaded into Internet Explorer as controls.
  5. Any assembly loaded from shares by an application that was launched from the "real" MyComputer zone.

Sounds like your case is number 5. Copying the .exe to the same network directory would be a workaround.

answered on Stack Overflow Feb 13, 2012 by Hans Passant
0

I faced an issue with DLL permissions. DLL files downloaded from internet get blocked in windows due to security/trust issue. They needed to be manually unblocked before any part of code can use these dependency.

To unblock:
 Go to properties & click the "unblock" button and the problem may be solved.

enter image description here

answered on Stack Overflow Jan 28, 2020 by Vaibhav Jain

User contributions licensed under CC BY-SA 3.0