2017-01-30 90 views
0

当我将应用程序作为服务运行时,出现汇编错误。当我直接从Visual Studio启动项目时,不会发生这种情况。以下是完整的错误消息。看来,错误是这样的:作为服务运行时出现汇编错误

比较程序集名称时发生不匹配:公钥标记

任何人都知道什么是PUBLIC KEY TOKEN以及如何解决这一问题?

30/01/2017 11:06:41 a.m.: System.IO.FileLoadException: Could not load file or assembly 'ClearScript, Version=5.4.4.0, Culture=neutral, PublicKeyToken=935d0c957da47c73' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) 
File name: 'ClearScript, Version=5.4.4.0, Culture=neutral, PublicKeyToken=935d0c957da47c73' 
    at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type) 
    at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) 
    at System.Reflection.Assembly.GetType(String name) 
    at Microsoft.ClearScript.V8.V8Proxy.GetImplType(Type type) 
    at Microsoft.ClearScript.V8.V8Proxy.CreateImpl[T](Object[] args) 
    at Microsoft.ClearScript.V8.V8IsolateProxy.Create(String name, V8RuntimeConstraints constraints, Boolean enableDebugging, Int32 debugPort) 
    at Microsoft.ClearScript.V8.V8Runtime..ctor(String name, V8RuntimeConstraints constraints, V8RuntimeFlags flags, Int32 debugPort) 
    at Microsoft.ClearScript.V8.V8Runtime..ctor(String name, V8RuntimeConstraints constraints, V8RuntimeFlags flags) 
    at Microsoft.ClearScript.V8.V8Runtime..ctor(String name, V8RuntimeConstraints constraints) 
    at Microsoft.ClearScript.V8.V8ScriptEngine..ctor(V8Runtime runtime, String name, V8RuntimeConstraints constraints, V8ScriptEngineFlags flags, Int32 debugPort) 
    at Microsoft.ClearScript.V8.V8ScriptEngine..ctor(String name, V8RuntimeConstraints constraints, V8ScriptEngineFlags flags, Int32 debugPort) 
    at Microsoft.ClearScript.V8.V8ScriptEngine..ctor(V8ScriptEngineFlags flags, Int32 debugPort) 
    at Microsoft.ClearScript.V8.V8ScriptEngine..ctor(V8ScriptEngineFlags flags) 
    at NinoJS.Core.Main.RunScript(Object filePath) 

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll 
Running under executable C:\NinoJS\NinoJS\NinoJS.Service.exe 
--- A detailed error log follows. 

=== Pre-bind state information === 
LOG: DisplayName = ClearScript, Version=5.4.4.0, Culture=neutral, PublicKeyToken=935d0c957da47c73 
(Fully-specified) 
LOG: Appbase = file:///C:/NinoJS/NinoJS/ 
LOG: Initial PrivatePath = NULL 
Calling assembly : ClearScriptV8-32, Version=5.4.4.0, Culture=neutral, PublicKeyToken=935d0c957da47c73. 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: C:\NinoJS\NinoJS\NinoJS.Service.exe.Config 
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. 
LOG: Post-policy reference: ClearScript, Version=5.4.4.0, Culture=neutral, PublicKeyToken=935d0c957da47c73 
LOG: Attempting download of new URL file:///C:/NinoJS/NinoJS/ClearScript.DLL. 
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN 
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated. 
+0

这似乎更严重:System.IO.FileLoadException:无法加载文件或程序集'ClearScript,Version = 5.4.4.0。确保该DLL与可执行文件在同一个文件夹中。 – invalidusername

+0

@invalidusername该库位于同一文件夹中,这是我检查的第一件事 – NicoRiff

+0

尝试配置您的Windows服务在Windows的本地用户下运行,而不是在系统用户(默认)下运行。您可以在Windows服务属性中找到这些设置。它可以帮助。 –

回答

0

它看起来像从日志,ClearScriptV8-32,链接到DLL的非签约版本,但所有的本地版本的签名。

如果你建立自己ClearScriptV8-32 - 检查是否参考ClearScript点签名的版本,否则用ILDASM仔细检查ClearScriptV8-32确实是指非签约版本,并要求货主提供另一个版本。

有关更多信息,请参阅this forum thread