[英]Entry point was not found on calling Dispose
I'm unit testing a piece of code that uses a nested using statement.我正在对一段使用嵌套 using 语句的代码进行单元测试。 I've changed it to a
using
statement in a try/finally
block.我已将其更改为
try/finally
块中的using
语句。 When I try to call the Dispose
method in the finally
block I get an EntryPointNotFoundException
.当我尝试在
finally
块中调用Dispose
方法时,我得到一个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.程序集具有对在未来版本中实现 IDisposable 的对象的引用,但在运行时加载了旧版本。 So when it tried to call Dispose(), which didn't exist in the old version, it goes ummmmm EntryPointNotFoundException!
因此,当它尝试调用旧版本中不存在的 Dispose() 时,它会发生 ummmmm EntryPointNotFoundException!
Long version:长版:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.