C
C#•2mo ago
HMath343

Integration Test issue on ubuntu-latest (.NET 8)

Hi, While running the basic example for integration tests with WebApplicationFactory in a .net8 (8.0.303) web api on ubuntu pipeline (https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-8.0 I'm getting this exception :
[xUnit.net 00:00:00.79] Starting: IntegrationTests
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.IO.FileLoadException: Undefined resource string ID:0x80131621
at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType, Object target)
[xUnit.net 00:00:00.79] Starting: IntegrationTests
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.IO.FileLoadException: Undefined resource string ID:0x80131621
at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType, Object target)
I've found this issue : https://github.com/dotnet/runtime/issues/101581 Any hints / more information ?
Integration tests in ASP.NET Core
Learn how integration tests ensure that an app's components function correctly at the infrastructure level, including the database, file system, and network.
GitHub
System.IO.FileLoadException: Undefined resource string ID:0x8013162...
Description Observe that client.GetAsync errors out with the following error message: System.IO.FileLoadException: Undefined resource string ID:0x80131621. This issue only occurs when both conditio...
6 Replies
HMath343
HMath343•2mo ago
FullStackTrace (1) :
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.IO.FileLoadException: Undefined resource string ID:0x80131621
at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType, Object target)
at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda)
at System.Linq.Expressions.Expression`1.Compile()
at Microsoft.AspNetCore.Http.RequestDelegateFactory.Create(Delegate handler, RequestDelegateFactoryOptions options, RequestDelegateMetadataResult metadataResult)
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.IO.FileLoadException: Undefined resource string ID:0x80131621
at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType, Object target)
at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda)
at System.Linq.Expressions.Expression`1.Compile()
at Microsoft.AspNetCore.Http.RequestDelegateFactory.Create(Delegate handler, RequestDelegateFactoryOptions options, RequestDelegateMetadataResult metadataResult)
FullstackTrace (2) :
at Microsoft.AspNetCore.Routing.RouteEndpointDataSource.CreateRouteEndpointBuilder(RouteEntry entry, RoutePattern groupPrefix, IReadOnlyList`1 groupConventions, IReadOnlyList`1 groupFinallyConventions)
at Microsoft.AspNetCore.Routing.RouteEndpointDataSource.get_Endpoints()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.CreateEndpointsUnsynchronized()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.EnsureEndpointsInitialized()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.get_Endpoints()
at Microsoft.AspNetCore.Routing.DataSourceDependentCache`1.Initialize()
at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
at Microsoft.AspNetCore.Routing.Matching.DataSourceDependentMatcher..ctor(EndpointDataSource dataSource, Lifetime lifetime, Func`1 matcherBuilderFactory)
at Microsoft.AspNetCore.Routing.Matching.DfaMatcherFactory.CreateMatcher(EndpointDataSource dataSource)
at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.InitializeCoreAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatcher|10_0(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task`1 matcherTask)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
at Microsoft.AspNetCore.Routing.RouteEndpointDataSource.CreateRouteEndpointBuilder(RouteEntry entry, RoutePattern groupPrefix, IReadOnlyList`1 groupConventions, IReadOnlyList`1 groupFinallyConventions)
at Microsoft.AspNetCore.Routing.RouteEndpointDataSource.get_Endpoints()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.CreateEndpointsUnsynchronized()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.EnsureEndpointsInitialized()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.get_Endpoints()
at Microsoft.AspNetCore.Routing.DataSourceDependentCache`1.Initialize()
at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
at Microsoft.AspNetCore.Routing.Matching.DataSourceDependentMatcher..ctor(EndpointDataSource dataSource, Lifetime lifetime, Func`1 matcherBuilderFactory)
at Microsoft.AspNetCore.Routing.Matching.DfaMatcherFactory.CreateMatcher(EndpointDataSource dataSource)
at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.InitializeCoreAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatcher|10_0(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task`1 matcherTask)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
Becquerel
Becquerel•2mo ago
it seems like that ticket includes a workaround; have you tried it?
HMath343
HMath343•2mo ago
Ah brilliant ! Solved. I had
public partial class Program { }
public partial class Program { }
But i've made a mistake on how i've declared InternalsVisibleTo. Project structure : - WebApi8 - src - WebApi8.csproj - Program.cs - test - IntegrationTest - IntegrationTest.csproj - Test.cs Issue :
<ItemGroup>
<InternalsVisibleTo Include="..\test\IntegrationTests\IntegrationTests" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="..\test\IntegrationTests\IntegrationTests" />
</ItemGroup>
Fix :
<ItemGroup>
<InternalsVisibleTo Include="IntegrationTests" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="IntegrationTests" />
</ItemGroup>
Becquerel
Becquerel•2mo ago
nice, glad you got it sorted 🙂 personally i've always had issues with InternalsVisibleTo... these days i tend to just test the public interfaces especially for integration tests i think that's more 'honest' almost than using secret APIs nobody else can access
Petris
Petris•2mo ago
wait there's a dedicated InternalsVisibleTo MSBuild thing now?
HMath343
HMath343•2mo ago
Yeah i had some issue with InternalsVisibleTo in the past as well, i never know if you need the relative path or the project name (but seems that assembly name is the correct answer !). https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#internalsvisibleto I also tend to want to find the information that works without reading the full doc which is my main issue 🙂 Thanks again !
MSBuild properties for Microsoft.NET.Sdk - .NET
Reference for the MSBuild properties and items that are understood by the .NET SDK.
Want results from more Discord servers?
Add your server