Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common Language Runtime detected an invalid program #3937

Closed
hyke123 opened this issue Oct 12, 2024 · 5 comments
Closed

Common Language Runtime detected an invalid program #3937

hyke123 opened this issue Oct 12, 2024 · 5 comments

Comments

@hyke123
Copy link

hyke123 commented Oct 12, 2024

Describe the bug

I got the exception when I want to visit the image in ImageList

Steps To Reproduce

I get the exception "Common Language Runtime detected an invalid program" for this line: ImageList1.Images[0];

[TestMethod]
public void TestMethod1()
{
    ImageList ImageList1 = new ImageList();
    // Set the ImageSize property to a larger size 
    ImageList1.ImageSize = new Size(112, 112);
    // Add two images to the list.
    ImageList1.Images.Add(System.Drawing.Image.FromFile("C:\\inv2026\\x64\\INV\\Usr\\Pub\\Doc\\ADSK\\INV\\Tex\\car3.BMP"));
    ImageList1.Images.Add(System.Drawing.Image.FromFile("C:\\inv2026\\x64\\INV\\Usr\\Pub\\Doc\\ADSK\\INV\\Tex\\Millennium.bmp"));
    var tt = ImageList1.Images[0];
    Console.WriteLine("1");
}
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net8.0-windows</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <UseWindowsForms>true</UseWindowsForms>
    <IsPackable>false</IsPackable>
    <IsTestProject>true</IsTestProject>
    <ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="coverlet.collector" Version="6.0.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
    <PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
    <PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
  </ItemGroup>

  <ItemGroup>
    <Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
  </ItemGroup>

</Project>

Expected behavior

Actual behavior

Additional context

Image

@Evangelink
Copy link
Member

I can reproduce the error only when using improper images but this is not linked to MSTest so I am going to close this issue.

@Evangelink Evangelink closed this as not planned Won't fix, can't repro, duplicate, stale Oct 14, 2024
@hyke123
Copy link
Author

hyke123 commented Oct 14, 2024

Hi @Evangelink Thanks for you reply,Could you share me what's the "improper images". Could you give one example? Thanks.

@hyke123
Copy link
Author

hyke123 commented Oct 14, 2024

The code can work fine in ConsoleApp(net8) project. It also work fine in UnitTest Framework project.

@Evangelink
Copy link
Member

Can you share the 2 images you are using so that I can ensure there is a bug in MSTest?

@hyke123
Copy link
Author

hyke123 commented Oct 14, 2024

@Evangelink Thanks for your help,I think I find the root cause,the root cause is we are using 3rd plugin:typeMock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants