简体   繁体   English

生成DLL的gmcs错误

[英]gmcs error generating dll

I have a C# file that I want to turn into a dll. 我有一个C#文件,我想变成一个DLL。 Test1.cs contains the following code: Test1.cs包含以下代码:

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.exe和Test1.cs的目录中,我运行以下命令:

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 eg leaving out "out:" etc. Running "gmcs --version" works fine. 我正在使用Windows 7 64.到目前为止,我已尝试使用cmd和cygwin运行它,将代码更改为零,代码行参数的变化,例如省略“out:”等运行“gmcs - -version“工作正常。 I'm stumped. 我很难过。

I figured it out. 我想到了。 I had to run the program via mono.exe like this: 我必须通过mono.exe运行程序,如下所示:

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

Thanks for the help! 谢谢您的帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM