Access denied while trying to use the Gnu.Getopt DLL

May 7, 2009 at 2:05 PM
I have referenced the Gnu.Getopt dll in a c# console application. I manage to create an array of longopts and build the solution (which means the DLL reference is correct. However when i execute the application i got the following error:

-----------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Gnu.Getopt, Version=0.9.1.24287, Culture=neutral, PublicKeyToken=d014b4ccdc53511a' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418) File name: 'Gnu.Getopt, Version=0.9.1.24287, Culture=neutral, PublicKeyToken=d014b4ccdc53511a' ---> System.Security.Policy.PolicyException: Execution permission cannot be acquired.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Any suggestion will be appreciated.
Coordinator
Jul 22, 2009 at 8:34 PM

I can reproduce this problem if I revoke my Traverse Folder/Execute File permission on my Gnu.Getopt.dll file.

You can find this permission in the Advanced Security Settings dialog box and I guess in cacls or xcacls or whatever is popular these days.

 

Aug 30, 2009 at 2:05 PM

Same error here using vs2008. Compiling Getopt from svn sources solved the problem.

Regards

May 4, 2010 at 5:45 PM

Same error on my machine, Compiling from sources did not solve my problem :-/

Sep 30, 2010 at 8:37 PM

I realize this thread is very old. But for those, who are desperate to make this DLL work, follow the instructions below:

1) Get the source of Gnu.Getopt.

2) Use MS Visual Studio 2005 or greater to open the project. I have not tried opening the project in earlier versions.

3) In Gnu.Getopt project, edit AssemblyInfo.cs

4) Comment the last section, where the lines start with [assembly:SecurityPermission(

5) Now compile Gnu.Getopt

6) Use the new DLL in your project

I hope this works out for you.