Replies: 2 comments 6 replies
-
Hi @Capsup, Unfortunately this look very specific to ILRepack. I'm thinking they're not adjusting the custom attributes on generic constraints containing types when merging them, so when writing Cecil is telling you that there's a mismatch in the metadata. I suggest you file a bug with ILRepack. |
Beta Was this translation helpful? Give feedback.
-
The base issue seems to be that ILRepack has not been updated with knowledge of Nullable Reference Types, so any assembly that uses them may confuse it. What may contribute to the problem is that for several of the new C# features, the compiler will emit "system" attributes directly in the compiled assembly instead of referencing them; that allows such features to work on older runtimes, like .NET Framework 4.7.2 (which would not include this new attribute). If you removed the uses of the attribute, consider checking whether the assembly contains Finally, if those internal attributes are present, chances are there'll also be a Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
So I realize this may not be the correct place for asking for help with this problem, but I'm hoping that the people here might be able to help me in any case, since it is Mono.Cecil related.
So I'm using ILRepack, which as far as I understand, uses this library behind the scenes, to do ILWeaving. I'm running into a problem in my project, which ends up resulting in the following error as soon as I import, for example, Newtonsoft.Json version 13.0.1:
All I'm doing is adding it as a PackageReference, and when building in release mode, I get this error.
I realize the error message is quite specific, but after hours of attempts at solving this, I have been unable to. My biggest problem is I have no idea what "another module" means exactly.
This is a completely empty project except using the ILRepack package and importing Newtonsoft.Json. It targets
netstandard2.0
, which I need to be the target. I cannot change this to a newer version for... reasons.Building in release mode without Newtonsoft.Json works. It also works building in debug, where ILRepack doesn't execute. So this means that the necessary Attribute must exist, otherwise it wouldn't have compiled in debug, right?
I tried defining this attribute in my project manually, like so:
but even then, I get the above error. So where is Mono.Cecil actually looking for this attribute? And why is it not even enough for me to manually define it, in my project?
The ILRepack configuration I use is this:
From a purely Mono.Cecil point of view, what options do I have for telling Mono.Cecil where to look for this attribute?
Or can I somehow make it ignore the attribute completely? I don't need to use it, I just need this to compile properly.
See the attached output.txt for a log file:
output.txt
Inside this log file, I also noticed that it actually does import the NullableAttribute that I manually defined:
Importing System.Runtime.CompilerServices.NullableAttribute from TestSolution4.dll
, but why doesn't Mono.Cecil just use this one then?Any help greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions