[Mono-list] CLSCompliant problem
Jaroslaw Kowalski
jaak@zd.com.pl
Sat, 21 Aug 2004 17:56:43 +0200
Hi guys!
I wanted to compile NLog under mono/linux and I'm getting very strange
compilation errors which seem to be related to the CLSCompliant attribute.
In src/NLog directory I do "mcs -t:library -recurse:*.cs" and it spits out
some error about CLSCompliant attribute not being found:
=====================================================
./Logger.cs(38) error CS0246: Could not find attribute 'CLSCompliant' (are
you missing a using directive or an assembly reference ?)
./Logger.cs(38) error CS8006: Attribute CLSCompliant resolved to different
types at different times: System.CLSCompliantAttribute vs.
Unhandled Exception: System.NullReferenceException: Object reference not set
to an instance of an object
in <0x0006b> Mono.CSharp.Attribute:GetClsCompliantAttributeValue
(Mono.CSharp.DeclSpace)
in <0x000cb> Mono.CSharp.MemberCore:GetClsCompliantAttributeValue
(Mono.CSharp.DeclSpace)
in <0x00059> Mono.CSharp.MemberCore:IsClsCompliaceRequired
(Mono.CSharp.DeclSpace)
in <0x0004a> Mono.CSharp.AttributeTester:AnalyzeTypeCompliance (System.Type)
in <0x00110> Mono.CSharp.AttributeTester:IsClsCompliant (System.Type)
in <0x00163> Mono.CSharp.MethodCore:VerifyClsCompliance
(Mono.CSharp.DeclSpace)
in <0x00027> Mono.CSharp.MemberCore:Emit (Mono.CSharp.TypeContainer)
in <0x00022> Mono.CSharp.Method:Emit (Mono.CSharp.TypeContainer)
in <0x00602> Mono.CSharp.TypeContainer:Emit ()
in <0x00896> Mono.CSharp.RootContext:EmitCode ()
in <0x00c35> Mono.CSharp.Driver:MainDriver (string[])
in <0x00012> Mono.CSharp.Driver:Main (string[])
=====================================================
The attribute is of course there (under Windows the app compiles without a
problem).
The problematic line is:
using System;
namespace NLog
{
[CLSCompliant(true)]
public abstract class Logger
{
...
}
}
When I remove the attribute line - the library compiles fine.
Also, when I add -clscheck+ option on mcs - the library compiles fine.
What's REALLY STRANGE that when I remove AssemblySign.cs file which contains
only:
[assembly: AssemblyKeyFile("src/NLog.snk")]
the library compiles without a problem!!!!!!!!
What's EVEN MORE STRANGE, when I compile the minimal closure of the
Logger.cs file consisting of just 4 files: "mcs -t:library AssemblyInfo.cs
AssemblySign.cs Logger.cs LogLevel.cs" the library compiles fine.
To reproduce this error, you can get NLog at:
http://svn.sav.net/snapshots/nlog-latest.tar.bz2
Jarek