HttpMultipartFormDataContent.Dispose throws ObjectDisposedException

1

The following code on a UWP project throws ObjectDisposedException (targeting Windows 10 Anniversary Edition - 14393):

using (var content = new HttpMultipartFormDataContent())
{
    //Why disposing of the content raises an exception?
}

The exception message is: Additional information: The object has been closed. (Exception from HRESULT: 0x80000013)

Stack trace: at System.Runtime.InteropServices.WindowsRuntime.IClosable.Close() at System.Runtime.InteropServices.WindowsRuntime.IClosableToIDisposableAdapter.Dispose() at App3.MainPage.ButtonBase_OnClick(Object sender, RoutedEventArgs e)

Does it mean that although HttpMultipartFormDataContent implements IDisposable it should not be disposed of?

Will my app be ok if I don't dispose of HttpMultiparFormDataContent type objects?

c#
asp.net-web-api
uwp

1 Answer

1

Thanks for reporting the bug/problem. Not calling Dispose in the above case/scenario, won't necessarily cause memory leak problems for you and memory should be reclaimed back. You may notice an increase in memory, but not necessarily a memory leak. You can check it yourself by starting a diagnostic session in Visual Studio (Debug -> Performance Profiler -> Memory)


User contributions licensed under CC BY-SA 3.0