Skip to content

ILVerify fails with error [MissingMethod] if call to method uses a parameter with type from an embedded interop assembly #62732

@carlos-quintero

Description

@carlos-quintero

Description

When a call to a method uses a parameter whose type is embedded from an interop assembly, ILVerify fails to verify the dll with:

Error [MissingMethod]

Reproduction Steps

  • Using Visual Studio 2022 create a .NET Framework (not .NET) Class Library named ClassLibraryInterop
  • Add the NuGet package Microsoft.VisualStudio.Imaging (version 14.3.25407)
  • Add the NuGet package Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime (version 14.3.26931). This interop assembly is automatically embedded, which is typical of the Visual Studio SDK used to create VSIX extensions for Visual Studio
  • Add this code:
using Microsoft.VisualStudio.Imaging.Interop;
using System.Runtime.InteropServices;

namespace ClassLibraryInterop
{
   public class Class1
   {
      void f1()
      {
         ImageAttributes imageAttributes = new ImageAttributes
         {
            StructSize = Marshal.SizeOf(typeof(ImageAttributes))
         };

         Microsoft.VisualStudio.Imaging.ImagingUtilities.ValidateAttributes(imageAttributes);
      }
   }
}
  • Build the DLL
  • Open a command prompt and change to the output folder (ClassLibraryInterop\bin\Debug)
  • Run:

ilverify ClassLibraryInterop.dll -r "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\*.dll" -r ".\*.dll"

Expected behavior

No error (PEVerify from .NET Framework works fine in this case, but ILVerify doesn't)

Actual behavior

[IL]: Error [MissingMethod]
ClassLibraryInterop.Class1::f1()] Missing method 'Void Microsoft.VisualStudio.Imaging.ImagingUtilities.ValidateAttributes(Microsoft.VisualStudio.Imaging.Interop.ImageAttributes)'

This is likely because the signature of the method doesn't match due to the type of the parameter, which has been embedded:
Embedded

Regression?

No response

Known Workarounds

No response

Configuration

.NET Framework 4.7.2
Windows 10
AnyCPU

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:3Work that is nice to havearea-Tools-ILVerificationIssues related to ilverify tool and IL verification in general

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions