gmcs error generating dll

470 Views Asked by At

I have a C# file that I want to turn into a dll. Test1.cs contains the following code:

using System;

namespace ProgramLibrary
{
    public class Lib
    {
        public Lib()
        {
            Console.WriteLine("Lib Created");
        }
    }
}

In a directory with gmcs.exe and Test1.cs, I run the following command:

gmcs -target:library -out:Test1.dll Test1.cs

This generates the following error:

Unhandled Exception: System.ArgumentException: Illegal enum value: 2051.
Parameter name: access
   at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, String dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions, StackCrawlMark& stackMark, IEnumerable`1 unsafeAssemblyAttributes)
   at System.AppDomain.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, String dir)
   at Mono.CSharp.CodeGen.Init(String name, String output, Boolean want_debugging_support, CompilerContext ctx)
   at Mono.CSharp.Driver.Compile()
   at Mono.CSharp.Driver.Main(String[] args)
Signal 79

I'm using Windows 7 64. So far I've tried running it with cmd and cygwin, altering the code to be cut down to nothing, variations of the command line arguments e.g. leaving out "out:" etc. Running "gmcs --version" works fine. I'm stumped.

1

There are 1 best solutions below

0
On BEST ANSWER

I figured it out. I had to run the program via mono.exe like this:

mono.exe ../lib/mono/2.0/gmcs.exe ../lib/mono/2.0/Test1.cs -target:library -out:Test1.dll

Thanks for the help!