JuchiaLu / Multi-Supplier-MT-Plugin

memoQ multi supplier machine translation plugin
MIT License
21 stars 4 forks source link

Memoq 版本兼容问题 #2

Closed hktang closed 3 weeks ago

hktang commented 4 months ago

你好!使用Translator Pro 9.7.27 版本,启动MemoQ时出现以下错误信息:

TYPE:
System.NotSupportedException

MESSAGE:
An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

SOURCE:

SYSTEM INFORMATION:
MemoQ version   : 9.7.27 
OS              : Microsoft Windows 11 Pro
OS version      : 10.0.22631
OS architecture : 64-bit
Visible memory  : 33322900
Free memory     : 14191020
Processor       : 12th Gen Intel(R) Core(TM) i5-12400
.NET version    : v4, v4.0

忽略后打开项目,出现以下信息:

TYPE:
System.TypeInitializationException

MESSAGE:
The type initializer for 'MemoQ.Termbase.GUI.TBAddin.TaasProjectLevelManager' threw an exception.

SOURCE:
MemoQ.Termbase.GUI

CALL STACK:
   at MemoQ.Termbase.GUI.TBAddin.TaasProjectLevelManager.get_Instance()
   at MemoQ.Project.ProjectDocument.initHeavyResourceManagers()
   at MemoQ.Project.ProjectDocument.OnOpenDocument(Object openParam)
   at MemoQ.ApplicationFramework.DocTypeManager.<>c__DisplayClass14_0.<OpenDocument>b__0()
   at MemoQ.ApplicationFramework.DocTypeManager.executeFromOpenErrorHandlingBlock(Func`1 func, Object openParam)
------------------ Inner exception ------------------

TYPE:
System.IO.FileLoadException

MESSAGE:
Could not load file or assembly 'file:///C:\Program Files\memoQ\memoQ-9\Addins\MultiSupplierMTPlugin.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

SOURCE:
mscorlib

CALL STACK:
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at MemoQ.Common.Framework.Modules.ModuleManager.loadAssemblyModules(String assemblyPath, UnsignedPluginDescription& unsignedDesc)
   at MemoQ.Common.Framework.Modules.ModuleManager.loadModules(String moduleDir, IUnsignedPluginsApprove unsignedPluginsapproval)
   at MemoQ.Common.Framework.Modules.ModuleManager.<>c__DisplayClass3_0.<Initialize>b__0()
   at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Lazy`1.get_Value()
   at MemoQ.Termbase.TBAddin.TBAddinManager..ctor()
   at MemoQ.Termbase.TBAddin.TBAddinManager.<>c.<.cctor>b__67_0()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at MemoQ.Termbase.GUI.TBAddin.TaasProjectLevelManager.setGlobalInfoLanguagesAccordingToPlugin()
   at MemoQ.Termbase.GUI.TBAddin.TaasProjectLevelManager..ctor()
   at MemoQ.Termbase.GUI.TBAddin.TaasProjectLevelManager..cctor()
------------------ Inner exception ------------------

TYPE:
System.NotSupportedException

MESSAGE:
An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

SOURCE:

SYSTEM INFORMATION:
MemoQ version   : 9.7.27 
OS              : Microsoft Windows 11 Pro
OS version      : 10.0.22631
OS architecture : 64-bit
Visible memory  : 33322900
Free memory     : 14074496
Processor       : 12th Gen Intel(R) Core(TM) i5-12400
.NET version    : v4, v4.0

请问您有计划修复这种兼容性问题吗?不知道上面的信息是否有用,如需更多信息请告知。谢谢。

JuchiaLu commented 4 months ago

太巧了,我在官网提供的版本中,从 9.7.28 一直测试到 10.4.12 版本,刚好 9.14 版本开始插件能用。

已经找到原因,因为 这个类中实现 ISessionWithMetadata 接口导致,这个接口从 9.14 版本开始提供,将这个接口变成之前的 ISession 接口后已经成功在 9.7 版本中运行插件。

这个接口提供的参数虽然目前也没有用到,但毕竟新版本才是主流,我考虑下是否放弃这个接口兼容老版本,还是仅单独提供一个编译好的文件给老版本用户使用。

Multi-Supplier-MT-Plugin(Compatible with versions earlier than 9.14).zip,这是临时提供的兼容 9.14 之前版本的插件。

hktang commented 3 months ago

谢谢。好像还会出现同样的错误(使用9.7.27和9.7.28)。

An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

似乎需要打开loadFromRemoteSources? 不好意思不是很懂DotNet,没法帮你解决。使用旧版本也是因为买断了MemoQ,没有购买附加的升级服务😅

JuchiaLu commented 3 months ago

我在 Windows 沙箱中测试 9.7.28 成功运行:

050045

这里有提到:“在 .NET Framework 4.5 中,本地网络共享上的程序集默认以完全信任方式运行;您不必启用 \<loadFromRemoteSources> 元素。”

我怀疑是你的电脑环境问题,尝试重新安装 .net 4.8 运行环境。

hktang commented 3 months ago

检查了一下,.NET的版本应该是没问题的,SFC检查也通过。

Currently installed "classic" .NET Versions in the system: 4.0.0.0 4.8.09032

我试试重装MemoQ...

hktang commented 3 months ago

找到问题的根源了。

  1. 需要使用您在二楼 https://github.com/JuchiaLu/Multi-Supplier-MT-Plugin/issues/2#issuecomment-1986940880 提供的兼容版本
  2. 下载后需要手动信任zip文件。

现在可以使用了。非常感谢!

Ref1: Stackoverflow 文章 Ref2: 具体操作

Screenshot 2024-03-21 202338

JuchiaLu commented 3 months ago

感谢提供解决方法,我也搜了一下相关信息,这个问题只有 dll 的加载方才能控制,插件作为被加载方视乎无法解决这个问题,所以老版本用户只能使用该方法了。

james1016 commented 2 months ago

我测试了9.14 和10.55,都可以