Skip to content

InvalidProgramException in .NET 7 Android application #2799

@jonathanpeppers

Description

@jonathanpeppers

We started seeing this here: dotnet/android#6986

With a dotnet/linker diff of: 04c49c9...b9c9da2

A unit test using HTTP fails with:

System.Net.WebException : net_webclient
----> System.InvalidProgramException : Invalid IL code in System.Net.HttpWebRequest:AddCacheControlHeaders (System.Net.Http.HttpRequestMessage): IL_0202: unused5

Stack trace
   at System.NetTests.SslTest.SslWithinTasksShouldWork()
   at System.Reflection.RuntimeMethodInfo.InvokeNonEmitUnsafe(Object , IntPtr* , Span`1 , BindingFlags )
--InvalidProgramException
   at System.Net.HttpWebRequest.SendRequest(Boolean )
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult )
   at System.Net.WebClient.GetWebResponse(WebRequest , IAsyncResult )
   at System.Net.WebClient.GetWebResponseTaskAsync(WebRequest )
   at System.Net.WebClient.DownloadBitsAsync(WebRequest , Stream , AsyncOperation , Action`3 )

It fails regardless if AOT is used.

ILSpy shows that IL_0202 might be after this method entirely?

image

Here are the .NET assemblies from this app:

assemblies.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions