我有一个C# / .NET Windows服务,用于归档Exchange,我最近“打包”了Veeam O365备份DLL,以便能够自动备份Exchange邮箱。
我将向您展示一段日志,显示程序在没有问题的情况下运行了一段时间,然后开始因错误而突然失败:
..。在服务重新启动之前:
(见Edit1,我的照片被覆盖了)
堆叠痕迹:
System.Management.Automation.CmdletInvocationException: Could not load file or assembly 'System.IO.Compression, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ---> System.IO.FileLoadException: Could not load file or assembly 'System.IO.Compression, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Veeam.Core.FileLoggerTransport.AutoArchive()
at Veeam.Core.FileLoggerTransport.ArchiveAndDelete()
at Veeam.Core.FileLoggerTransport.ControlLogSize()
at Veeam.Core.FileLoggerTransport.WriteLine(UInt32 level, String message)
at Veeam.Core.LoggerTransport.LogDefault(UInt32 level, String message, Object[] args)
at Veeam.PowerShell.Core.BasePSCmdlet.BeginProcessing()
at System.Management.Automation.Cmdlet.DoBeginProcessing()
at System.Management.Automation.CommandProcessorBase.DoBegin()
--- End of inner exception stack trace ---
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
at VeeamArchiverConnector.VeeamArchiverConnector.ConnectToVeeamServer(String serverName, Int32 port)
at REMOVED.DeprovisionObject.DeprovisionOnline(String deprovisioningOu) in C:\Users\REMOVED\Source\Repos\ExchangeProvisioning\Deprovisioning\DeprovisionObject.cs:line 442
at REMOVED.DeprovisionObject.Start() in C:\Users\REMOVED\Source\Repos\ExchangeProvisioning\Deprovisioning\DeprovisionObject.cs:line 125 该项目确实引用了System.IO.Compression,,尽管:
在我的.csproj文件中,我有以下内容:
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>我无法访问"Veeam.Core.*“的代码/项目,因为它们是Veeam O365备份安装程序附带的Veeam DLL。
但在全球范围内,我不明白的是,它工作一段时间(通常大约一到两个小时),然后错误开始,除非我重新启动服务?
欢迎任何建议!
谢谢
编辑1:
我在我的"Veeam Connector“项目中添加了更多的日志和自定义异常抛出,但这是一样的:最后一个错误仍然是关于System.IO.Compression丢失,并且输入从未改变:
发布于 2019-11-22 15:50:17
@浩成谢谢!这就成功了,服务运行了好几个小时,没有问题。
所以问题是有约束力的:
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />这是重定向到4.2.0.0。我认为它在我唯一的.NETFramework项目上是很好的,但是正如您所提到的,.NETStandard System.IO.Compression强制了一个4.1.2.0版本,并且在安装>时没有更新绑定,所以它现在试图找到4.2.0.0,这已经不再是了,它只是4.1.2.0。
更新到"newVersion=4.1.2.0“的绑定完成了它!
发布于 2022-02-22 13:16:38
我也有同样的问题。netstandard2.0库正在使用System.IO.Compression,并从.NET Fx 4.7.2测试项目中使用。无法加载文件或程序集“System.IO.Compression、Version=4.2.2.0、Culture=neutral”异常时,试图从netstandard2.0代码加载System.IO.Compression。
解决办法就是
很奇怪,但很管用
https://stackoverflow.com/questions/58953619
复制相似问题