Skip to content

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

Open

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

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Dec 13, 2021
  2. changed the title [-]ILVerify fails with error [MissingMethod] if calls to method uses a parameter with type from an embedded interop assembly[/-] [+]ILVerify fails with error [MissingMethod] if call to method uses a parameter with type from an embedded interop assembly[/+] on Dec 13, 2021
  3. JulieLeeMSFT commented on Jan 26, 2022

    @JulieLeeMSFT
    Member

    cc @TIHan.

  4. self-assigned this
    on Jan 26, 2022
  5. added this to the Future milestone on Jan 31, 2022
  6. removed
    untriagedNew issue has not been triaged by the area owner
    on Jan 31, 2022
  7. removed their assignment
    on Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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