FileLoadException using .NET 7 and a web api

Hey Joe, I have a script that runs a web api that works fine in .NET 6.0 and below but when I run it in .NET 7.0 I get a FileLoadException and LINQPad breaks at services.AddControllers. The InnerException is a NotSupportedException with the message "A non-collectible assembly may not reference a collectible assembly."

After digging around for a while I found an older thread where you mentioned that the error would be accompanied by the following message: "Tip: You can make the query's load-context non-collectible by checking the option in Query Properties | Advanced (press F4)". However, I don't see this in .NET 7.0 so it took a bit to figure it out. The checkbox in the advanced query properties does indeed fix the issue for me but I wanted to let you know that the helpful error message doesn't show up in this scenario.

I wonder if the following breaking change is what caused the message not to show up in LINQPad any longer:

Since this is an option that we need to turn on I'm also curious what we lose by using it? In other words, what harm would it cause to use it by default or by having something in the LINQPad preferences to do this by default?


Sign In or Register to comment.