PEVerify giving coded rid out of range after adding interface
See original GitHub issueHi,
I’ve just started using cecil so I’m sure I must be missing something. I’m attempting to static weave the INotifyPropertyChanged interface onto objects that are decorated with a custom attribute.
I can weave the IL into the properties just fine, but as soon as I try to add the interface I get the following error for PEVerify:
[MD]: Error (Structural): Table=0x00000009, Col=0x00000001, Row=0x00000003, has coded rid out of range.
1 Error(s) Verifying .\StaticWeaving.exe
I am using the following code to implement the interface on an AfterBuild task:
using (var notifyPropertyChangedAssembly = AssemblyDefinition.ReadAssembly(typeof(INotifyPropertyChanged).Assembly.Location))
{
using (var assembly = AssemblyDefinition.ReadAssembly(AssemblyPath, new ReaderParameters { ReadWrite = true }))
{
foreach (var type in assembly.MainModule.Types)
{
if (type.CustomAttributes.Any(x => x.Constructor.DeclaringType.FullName == typeof(NotifyPropertyChangedAttribute).FullName))
{
if (!type.Interfaces.Any(x => x.InterfaceType.FullName == typeof(INotifyPropertyChanged).FullName))
{
Log.LogMessage($"{type.FullName} has {nameof(NotifyPropertyChangedAttribute)} but no {nameof(INotifyPropertyChanged)} implementation. Weaving...");
var notifyPropertyChangedType = notifyPropertyChangedAssembly.MainModule.Types.FirstOrDefault(x => x.FullName == typeof(INotifyPropertyChanged).FullName);
Log.LogMessage(notifyPropertyChangedType.FullName);
type.Interfaces.Add(new InterfaceImplementation(notifyPropertyChangedType));
}
}
}
assembly.Write();
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
c# - PEVerify fails on explicit interface property when the ...
I'm emitting a class that explicitly implements a simple interface property with a get method. There are no problems so long as the...
Read more >Peverify.exe (PEVerify Tool) - .NET Framework
The PEVerify tool helps developers who generate Microsoft intermediate language (MSIL) (such as compiler writers and script engine developers) ...
Read more >June | 2009 - Visual Studio Extensibility (VSX)
ArgumentException “Value does not fall within the expected range.” when adding commands, buttons, commandbars, etc. Most of the AddXXX methods of the automation ......
Read more >Untitled
Code de triche sur minecraft solo, Herbretaise automobile tires! Mosaic music festival 2011 super, Redresseur de courant pdf, Sambaram telugu movie mp3 ...
Read more >ProvidedTypes.fs
The SDK for creating F# type providers. Contribute to fsprojects/FSharp.TypeProviders.SDK development by creating an account on GitHub.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
“dismayed” ?
BTW have u seen this https://github.com/Fody/PropertyChanged/ ?