Unhandled exception browsing metadata from VS?

In VS2019, things work fine, in VS2022 release, this happens when you try to browse to the metadata url, or any of the other pages in it:

info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 56.7912ms 200 text/html; charset=utf-8
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/2 GET https://localhost:5000/capi/metadata
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id “0HMD3JVTFL9RL”, Request id “0HMD3JVTFL9RL:0000000F”: An unhandled exception was thrown by the application.
System.InvalidOperationException: An asynchronous socket operation is already in progress using this SocketAsyncEventArgs instance.
at System.Net.Sockets.SocketAsyncEventArgs.ThrowForNonFreeStatus(Int32 status)
at System.Net.Sockets.SocketAsyncEventArgs.set_BufferList(IList1 value) at Microsoft.WebTools.BrowserLink.Net.SocketAdapter.SendAsync(IList1 buffers)
— End of stack trace from previous location where exception was thrown —
at Microsoft.WebTools.BrowserLink.Net.DelayConnectingHttpSocketAdapter.Microsoft.WebTools.BrowserLink.Net.IHttpSocketAdapter.CompleteRequestAsync()
at Microsoft.WebTools.BrowserLink.Net.ScriptInjectionFilterStream.WaitForFilterCompleteAsync()
at Microsoft.WebTools.BrowserLink.Net.BrowserLinkMiddleware.ExecuteWithFilterAsync(IHttpSocketAdapter injectScriptSocket, String requestId, HttpContext httpContext)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 48.65ms 500

once deployed and hosted with iis, it seems to work fine again, but if you start the project up in VS2022 (non iis), you get this every time.

starting up the main project exe manually also works just fine, so this seems to be something related to VS2022 hosting

anything i can quickly check/tweak here?

The exception looks like it occurs from BrowserLink, you can try removing it if you’ve got registered in your App, i.e:

if (env.IsDevelopment())
    // app.UseBrowserLink();

Or if you have it enabled in VS you can try disabling it:

Otherwise you’d need to report the issue with VS that they have an issue with their BrowserLink integration.

here is another interesting thing. if you click a request object (once metadata loads), it fails. if you keep trying, it WILL load after a few attempts

if i get a 500 error (or no text to display at all), pressing F5 a few times and it ends up showing up.


i do not have UseBrowserLink enabled at all. that string shows up zero times in my project

Then VS is injecting it when it starts your App. The docs says Browser Link is disabled by default in Visual Studio but that may no longer be the case, see if you can try disabling it in VS.

i looked under the menu. it is not enabled. and clicking into the other options brings up a different panel that says

Enable Browser Link

and no additional details

I’m assuming it doesn’t happen if you start it from the console? It’s got to be a VS issue, I’d raise a bug report with them.

yea right from the console works fine.