I'm unit testing a piece of code that uses a nested using statement. I've changed it to a using
statement in a try/finally
block. When I try to call the Dispose
method in the finally
block I get an EntryPointNotFoundException
. I've tried a lot of things but I'm not sure how to solve this problem. Here is my code:
var memoryStream = new MemoryStream(message.FileContent);
try
{
using (var sftpClient = this.GetSftpClientFromId(message.CustomerId))
{
return sftpClient.UploadFileAsync(memoryStream, message.FileName, true);
}
}
finally
{
memoryStream?.Dispose();
}
How can I solve this issue?
Just had this happen.
The problem ended up being:
Short version:
An assembly had a reference to an object that implemented IDisposable in a future version, but an old version was loaded at runtime. So when it tried to call Dispose(), which didn't exist in the old version, it goes ummmmm EntryPointNotFoundException!
Long version:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.