views:

364

answers:

1

Mixed-mode DLL called from native C application fails to load: An unhandled exception of type 'System.IO.FileLoadException' occurred in Unknown Module.

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

My environment is: Native C application calling a mixed mode C++ DLL, which then loads a C# DLL.. This works correctly when loaded from a local drive, but when launched from a network drive, it fails with the above messages.

The call to LoadLibrary succeeds, as does the GetProcAddress. The load error happens when I call the function.

I have digitally signed the C application, and I've performed "strong name" signing on the 2 DLLs. The PublickKeyToken in the message above does match the named DLL. I have also issued the CASPOLcommands on my client to grant FullTrust to that strong name keytoken. When that failed to work, I tried the CASPOL command to grant FullTrust to the URL of the network drive (including path to my application's directory); no change in results.

I tried removing all dependencies, so that there was just the initial mixed-mode DLL... I replaced the bodies of all the functions with just a return of a "success" integer value. Results unchanged. Only when I changed it from Mixed Mode to Win32, and changed the Configuration Properties >> General >> Common Language Runtime Support from "Common Language Runtime Support" to "No Common Language Runtime Support" did calling the DLL produce the expected result (just returned the "success" integer return value).

A: 

You Haven't the permission to execute code on this share. I think you can't exen execute any .NET app from the share. Try it out, place some .NET executable on the share, and try to execute it. If it doesn't work, you have to add permission in your .net config to use the share.

Thomas Maierhofer
From what I read, adding strong name signing to the DLL, then using the CASPOL commands to grant that strong name FullTrust permission on the client machine was what is necessary. I did both those things, but the result was the same.
Steve
This is not a Question of Signing. The .NET Framework must be configured to execute FullTrust from the share. Open the .NET Framework 2.0 Configuration app (Control Panel ...)Add under Runtime Security Police > Code Groups a new Code GroupChoose the Condition Type URLAnd specify the path to your share as a URLUse the existing permission set "FullTrust" and it will work.With this code group you can control the permissions of your share.
Thomas Maierhofer