After retargeting to .NET Core 2.1 getting new error System.ObjectDisposedException: Cannot access a disposed...











up vote
0
down vote

favorite












I've just successfully retargeted my Web API app from .NET Framework 4.7.1 to .NET Core 2.1. The application runs perfectly on my local machine.



After deploying it to an Azure app service the app starts up and looks healthy. However I log the following error whenever I make any API call (including to receive static files).




Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLIFNSQMBR9Q", Request id "0HLIFNSQMBR9Q:0000000D": An unhandled exception was thrown by the application.
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'FrameResponseStream'.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameResponseStream.ValidateState(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameResponseStream.WriteAsync(Byte buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameResponseStream.Write(Byte buffer, Int32 offset, Int32 count)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Write(String value)
at Microsoft.AspNetCore.Hosting.Views.ErrorPage.ExecuteAsync()
at Microsoft.Extensions.RazorViews.BaseView.ExecuteAsync(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame`1.ProcessRequestsAsync()




Unfortunately the above stack trace does not mention any of our code, and so I'm not entirely sure where this exception is coming from. This error did not occur when .NET Framework was targeted, so it must be related to the retargeting to .NET Core 2.1.



I have checked this StackOverflow question which also describes the exception after migrating to .NET Core 2.1, but I've tried looking for and fixing the situations described in the answers without success.



What could be causing this error and how can I fix it?










share|improve this question


















  • 1




    Did you follow this? docs.microsoft.com/en-us/aspnet/core/migration/…
    – Marie
    2 days ago










  • Exception kinda gives you a hint which class is causing the issue: : Cannot access a disposed object. Object name: 'FrameResponseStream'. Quick Google search for FrameResponseStream ends up in github.com/aspnet/KestrelHttpServer/issues/2299 and a referenced issue which is about improving docs.microsoft.com/en-us/aspnet/core/fundamentals/… docs page. Does that give you enough direction?
    – Tseng
    2 days ago












  • Thanks @Marie I'll check it out. The article talks about upgrading from .NET Core 2.0 to 2.1 - we are going from targeting .NET Framework. Perhaps there is done useful information there though!
    – Ivan
    2 days ago










  • Hi @Tseng I have looked at all those links but I'm not sure that the suggested improvements to the docs give me any more direction - but I'll read it thoroughly and see if I can figure it out from there, thanks
    – Ivan
    2 days ago










  • You are not using Websockets anywhere, directly or indirectly (SignalR) or putting anything form a request into the background thread / service and not awaiting the middleware till that one is finished?
    – Tseng
    2 days ago















up vote
0
down vote

favorite












I've just successfully retargeted my Web API app from .NET Framework 4.7.1 to .NET Core 2.1. The application runs perfectly on my local machine.



After deploying it to an Azure app service the app starts up and looks healthy. However I log the following error whenever I make any API call (including to receive static files).




Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLIFNSQMBR9Q", Request id "0HLIFNSQMBR9Q:0000000D": An unhandled exception was thrown by the application.
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'FrameResponseStream'.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameResponseStream.ValidateState(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameResponseStream.WriteAsync(Byte buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameResponseStream.Write(Byte buffer, Int32 offset, Int32 count)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Write(String value)
at Microsoft.AspNetCore.Hosting.Views.ErrorPage.ExecuteAsync()
at Microsoft.Extensions.RazorViews.BaseView.ExecuteAsync(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame`1.ProcessRequestsAsync()




Unfortunately the above stack trace does not mention any of our code, and so I'm not entirely sure where this exception is coming from. This error did not occur when .NET Framework was targeted, so it must be related to the retargeting to .NET Core 2.1.



I have checked this StackOverflow question which also describes the exception after migrating to .NET Core 2.1, but I've tried looking for and fixing the situations described in the answers without success.



What could be causing this error and how can I fix it?










share|improve this question


















  • 1




    Did you follow this? docs.microsoft.com/en-us/aspnet/core/migration/…
    – Marie
    2 days ago










  • Exception kinda gives you a hint which class is causing the issue: : Cannot access a disposed object. Object name: 'FrameResponseStream'. Quick Google search for FrameResponseStream ends up in github.com/aspnet/KestrelHttpServer/issues/2299 and a referenced issue which is about improving docs.microsoft.com/en-us/aspnet/core/fundamentals/… docs page. Does that give you enough direction?
    – Tseng
    2 days ago












  • Thanks @Marie I'll check it out. The article talks about upgrading from .NET Core 2.0 to 2.1 - we are going from targeting .NET Framework. Perhaps there is done useful information there though!
    – Ivan
    2 days ago










  • Hi @Tseng I have looked at all those links but I'm not sure that the suggested improvements to the docs give me any more direction - but I'll read it thoroughly and see if I can figure it out from there, thanks
    – Ivan
    2 days ago










  • You are not using Websockets anywhere, directly or indirectly (SignalR) or putting anything form a request into the background thread / service and not awaiting the middleware till that one is finished?
    – Tseng
    2 days ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I've just successfully retargeted my Web API app from .NET Framework 4.7.1 to .NET Core 2.1. The application runs perfectly on my local machine.



After deploying it to an Azure app service the app starts up and looks healthy. However I log the following error whenever I make any API call (including to receive static files).




Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLIFNSQMBR9Q", Request id "0HLIFNSQMBR9Q:0000000D": An unhandled exception was thrown by the application.
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'FrameResponseStream'.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameResponseStream.ValidateState(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameResponseStream.WriteAsync(Byte buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameResponseStream.Write(Byte buffer, Int32 offset, Int32 count)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Write(String value)
at Microsoft.AspNetCore.Hosting.Views.ErrorPage.ExecuteAsync()
at Microsoft.Extensions.RazorViews.BaseView.ExecuteAsync(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame`1.ProcessRequestsAsync()




Unfortunately the above stack trace does not mention any of our code, and so I'm not entirely sure where this exception is coming from. This error did not occur when .NET Framework was targeted, so it must be related to the retargeting to .NET Core 2.1.



I have checked this StackOverflow question which also describes the exception after migrating to .NET Core 2.1, but I've tried looking for and fixing the situations described in the answers without success.



What could be causing this error and how can I fix it?










share|improve this question













I've just successfully retargeted my Web API app from .NET Framework 4.7.1 to .NET Core 2.1. The application runs perfectly on my local machine.



After deploying it to an Azure app service the app starts up and looks healthy. However I log the following error whenever I make any API call (including to receive static files).




Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLIFNSQMBR9Q", Request id "0HLIFNSQMBR9Q:0000000D": An unhandled exception was thrown by the application.
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'FrameResponseStream'.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameResponseStream.ValidateState(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameResponseStream.WriteAsync(Byte buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameResponseStream.Write(Byte buffer, Int32 offset, Int32 count)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Write(String value)
at Microsoft.AspNetCore.Hosting.Views.ErrorPage.ExecuteAsync()
at Microsoft.Extensions.RazorViews.BaseView.ExecuteAsync(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame`1.ProcessRequestsAsync()




Unfortunately the above stack trace does not mention any of our code, and so I'm not entirely sure where this exception is coming from. This error did not occur when .NET Framework was targeted, so it must be related to the retargeting to .NET Core 2.1.



I have checked this StackOverflow question which also describes the exception after migrating to .NET Core 2.1, but I've tried looking for and fixing the situations described in the answers without success.



What could be causing this error and how can I fix it?







c# asp.net-core porting asp.net-core-2.1 objectdisposedexception






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









Ivan

2,47951847




2,47951847








  • 1




    Did you follow this? docs.microsoft.com/en-us/aspnet/core/migration/…
    – Marie
    2 days ago










  • Exception kinda gives you a hint which class is causing the issue: : Cannot access a disposed object. Object name: 'FrameResponseStream'. Quick Google search for FrameResponseStream ends up in github.com/aspnet/KestrelHttpServer/issues/2299 and a referenced issue which is about improving docs.microsoft.com/en-us/aspnet/core/fundamentals/… docs page. Does that give you enough direction?
    – Tseng
    2 days ago












  • Thanks @Marie I'll check it out. The article talks about upgrading from .NET Core 2.0 to 2.1 - we are going from targeting .NET Framework. Perhaps there is done useful information there though!
    – Ivan
    2 days ago










  • Hi @Tseng I have looked at all those links but I'm not sure that the suggested improvements to the docs give me any more direction - but I'll read it thoroughly and see if I can figure it out from there, thanks
    – Ivan
    2 days ago










  • You are not using Websockets anywhere, directly or indirectly (SignalR) or putting anything form a request into the background thread / service and not awaiting the middleware till that one is finished?
    – Tseng
    2 days ago














  • 1




    Did you follow this? docs.microsoft.com/en-us/aspnet/core/migration/…
    – Marie
    2 days ago










  • Exception kinda gives you a hint which class is causing the issue: : Cannot access a disposed object. Object name: 'FrameResponseStream'. Quick Google search for FrameResponseStream ends up in github.com/aspnet/KestrelHttpServer/issues/2299 and a referenced issue which is about improving docs.microsoft.com/en-us/aspnet/core/fundamentals/… docs page. Does that give you enough direction?
    – Tseng
    2 days ago












  • Thanks @Marie I'll check it out. The article talks about upgrading from .NET Core 2.0 to 2.1 - we are going from targeting .NET Framework. Perhaps there is done useful information there though!
    – Ivan
    2 days ago










  • Hi @Tseng I have looked at all those links but I'm not sure that the suggested improvements to the docs give me any more direction - but I'll read it thoroughly and see if I can figure it out from there, thanks
    – Ivan
    2 days ago










  • You are not using Websockets anywhere, directly or indirectly (SignalR) or putting anything form a request into the background thread / service and not awaiting the middleware till that one is finished?
    – Tseng
    2 days ago








1




1




Did you follow this? docs.microsoft.com/en-us/aspnet/core/migration/…
– Marie
2 days ago




Did you follow this? docs.microsoft.com/en-us/aspnet/core/migration/…
– Marie
2 days ago












Exception kinda gives you a hint which class is causing the issue: : Cannot access a disposed object. Object name: 'FrameResponseStream'. Quick Google search for FrameResponseStream ends up in github.com/aspnet/KestrelHttpServer/issues/2299 and a referenced issue which is about improving docs.microsoft.com/en-us/aspnet/core/fundamentals/… docs page. Does that give you enough direction?
– Tseng
2 days ago






Exception kinda gives you a hint which class is causing the issue: : Cannot access a disposed object. Object name: 'FrameResponseStream'. Quick Google search for FrameResponseStream ends up in github.com/aspnet/KestrelHttpServer/issues/2299 and a referenced issue which is about improving docs.microsoft.com/en-us/aspnet/core/fundamentals/… docs page. Does that give you enough direction?
– Tseng
2 days ago














Thanks @Marie I'll check it out. The article talks about upgrading from .NET Core 2.0 to 2.1 - we are going from targeting .NET Framework. Perhaps there is done useful information there though!
– Ivan
2 days ago




Thanks @Marie I'll check it out. The article talks about upgrading from .NET Core 2.0 to 2.1 - we are going from targeting .NET Framework. Perhaps there is done useful information there though!
– Ivan
2 days ago












Hi @Tseng I have looked at all those links but I'm not sure that the suggested improvements to the docs give me any more direction - but I'll read it thoroughly and see if I can figure it out from there, thanks
– Ivan
2 days ago




Hi @Tseng I have looked at all those links but I'm not sure that the suggested improvements to the docs give me any more direction - but I'll read it thoroughly and see if I can figure it out from there, thanks
– Ivan
2 days ago












You are not using Websockets anywhere, directly or indirectly (SignalR) or putting anything form a request into the background thread / service and not awaiting the middleware till that one is finished?
– Tseng
2 days ago




You are not using Websockets anywhere, directly or indirectly (SignalR) or putting anything form a request into the background thread / service and not awaiting the middleware till that one is finished?
– Tseng
2 days ago

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53418149%2fafter-retargeting-to-net-core-2-1-getting-new-error-system-objectdisposedexcept%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53418149%2fafter-retargeting-to-net-core-2-1-getting-new-error-system-objectdisposedexcept%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

What visual should I use to simply compare current year value vs last year in Power BI desktop

Alexandru Averescu

Trompette piccolo