Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web项目中redis初始化出错 #71

Open
Ancore01 opened this issue Dec 25, 2018 · 24 comments
Open

web项目中redis初始化出错 #71

Ancore01 opened this issue Dec 25, 2018 · 24 comments

Comments

@Ancore01
Copy link

var csRedis = new CSRedis.CSRedisClient("xxxxxx:63140,name=test,password=pen1234Q~,poolsize=3"); RedisHelper.Initialization(csRedis);
引发的异常:“System.IO.FileLoadException”(位于 CSRedisCore.dll 中)
“var csRedis = new CSRedis.CSRedisClient("xxxxxx:63140,name=test,password=pen1234Q~,poolsize=3"); RedisHelper.Initialization(csRedis)”引发了类型“System.IO.FileLoadException”的异常
Data: {System.Collections.ListDictionaryInternal}
FileName: "Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"
FusionLog: "=== Pre-bind state information ===\r\nLOG: DisplayName = Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed\n (Fully-specified)\r\nLOG: Appbase = file:///E:/contentOfWork/Speedster/Speedster.Web/\r\nLOG: Initial PrivatePath = E:\contentOfWork\Speedster\Speedster.Web\bin\r\nCalling assembly : CSRedisCore, Version=3.0.30.0, Culture=neutral, PublicKeyToken=null.\r\n===\r\nLOG: This bind starts in default load context.\r\nLOG: Using application configuration file: E:\contentOfWork\Speedster\Speedster.Web\web.config\r\nLOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet.config\r\nLOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.\r\nLOG: Post-policy reference: Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed\r\nLOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET
Files/speedster.web/c61e2095/be700bd4/Newtonsoft.Json.DLL.\r\nLOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/speedster.web/c61e2095/be700bd4/Newtonsoft.Json/Newtonsoft.Json.DLL.\r\nLOG: Attempting download of new URL file:///E:/contentOfWork/Speedster/Speedster.Web/bin/Newtonsoft.Json.DLL.\r\nWRN: Comparing the assembly name resulted in the mismatch: Major Version\r\nERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.\r\n"
HResult: -2146234304
HelpLink: null
IPForWatsonBuckets: 0x008c10e5
InnerException: null
IsTransient: false
Message: "Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"
RemoteStackTrace: null
Source: "CSRedisCore"
StackTrace: " 在 CSRedis.CSRedisClient..ctor(Func2 NodeRule, String[] connectionStrings)\r\n 在 CSRedis.CSRedisClient..ctor(String connectionString)" TargetSite: {Void .ctor(System.Func2[System.String,System.String], System.String[])}
WatsonBuckets: null
_HResult: -2146234304
_className: null
_data: {System.Collections.ListDictionaryInternal}
_dynamicMethods: null
_exceptionMethod: {Void .ctor(System.Func`2[System.String,System.String], System.String[])}
_exceptionMethodString: null
_fileName: "Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"
_fusionLog: "=== Pre-bind state information ===\r\nLOG: DisplayName = Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed\n (Fully-specified)\r\nLOG: Appbase = file:///E:/contentOfWork/Speedster/Speedster.Web/\r\nLOG: Initial PrivatePath = E:\contentOfWork\Speedster\Speedster.Web\bin\r\nCalling assembly : CSRedisCore, Version=3.0.30.0, Culture=neutral, PublicKeyToken=null.\r\n===\r\nLOG: This bind starts in default load context.\r\nLOG: Using application configuration file: E:\contentOfWork\Speedster\Speedster.Web\web.config\r\nLOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet.config\r\nLOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.\r\nLOG: Post-policy reference: Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed\r\nLOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET
Files/speedster.web/c61e2095/be700bd4/Newtonsoft.Json.DLL.\r\nLOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/speedster.web/c61e2095/be700bd4/Newtonsoft.Json/Newtonsoft.Json.DLL.\r\nLOG: Attempting download of new URL file:///E:/contentOfWork/Speedster/Speedster.Web/bin/Newtonsoft.Json.DLL.\r\nWRN: Comparing the assembly name resulted in the mismatch: Major Version\r\nERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.\r\n"
_helpURL: null
_innerException: null
_ipForWatsonBuckets: 0x008c10e5
_maybeFullPath: null
_message: "Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"
_remoteStackIndex: 0
_remoteStackTraceString: null
_safeSerializationManager: {System.Runtime.Serialization.SafeSerializationManager}
_source: "CSRedisCore"
_stackTrace: {sbyte[48]}
_stackTraceString: null
_watsonBuckets: null
_xcode: -532462766
_xptrs: 0x00000000

环境:window10, visual studio2017. .net Framework4.7

@2881099
Copy link
Owner

2881099 commented Dec 25, 2018

你用的是 .net framework v4.0 啊?

Newtonsoft.Json, Version=11.0.0.0,提示找不到这个程序集

@Ancore01
Copy link
Author

Ancore01 commented Jan 7, 2019

我的项目使用的框架确实是4.7的,而且我在下载这个插件的时候回自动生成app.config文件,项目是web项目。
image

问题出在哪呢?

@Ancore01
Copy link
Author

Ancore01 commented Jan 7, 2019

生成这个文件的是在类库项目里面,之前单独测试的时候只与package文件呀,在项目中就可多出这个文件了

@Ancore01
Copy link
Author

Ancore01 commented Jan 7, 2019

这个是web.config里面更新的,两个文件里面的Json版本不一样

@2881099
Copy link
Owner

2881099 commented Jan 7, 2019

确定是版本不一致导致的错误吗?

@2881099
Copy link
Owner

2881099 commented Jan 7, 2019

可以考虑把源代码加到项目中开发

@Ancore01
Copy link
Author

Ancore01 commented Jan 7, 2019

好的

@Ancore01
Copy link
Author

Ancore01 commented Jan 7, 2019

image
这个版本的SDK不支持SkipNonexistentTargets这个参数呀,可选的参数,删了可以吧

@Ancore01
Copy link
Author

Ancore01 commented Jan 7, 2019

https://docs.microsoft.com/zh-cn/previous-versions/z7f65y0d(v=vs.120)
里面好像就没有这个参数,看错了

@2881099
Copy link
Owner

2881099 commented Jan 7, 2019

@2881099
Copy link
Owner

2881099 commented Jan 7, 2019

整理了一下.net framework4.5的源码,编译通过了

@Ancore01
Copy link
Author

Ancore01 commented Jan 7, 2019

好的,试试

@Ancore01
Copy link
Author

Ancore01 commented Jan 7, 2019

image
将源码放在项目重开发,会找不到程序集,
初始化:
image

@2881099
Copy link
Owner

2881099 commented Jan 7, 2019

你用的还是CSRedisCore项目吧,引用CSRedisNFX45吧

@Ancore01
Copy link
Author

Ancore01 commented Jan 7, 2019

new CSRedis.CSRedisClient("xxxxxx:63140,name=test,password=pen1234Q~,poolsize=3")
引发的异常:“System.IO.FileNotFoundException”(位于 CSRedisCore.dll 中)

new CSRedis.CSRedisClient("xxxxxxx:63140,name=test,password=pen1234Q~,poolsize=3")
引发的异常:“System.IO.FileNotFoundException”(位于 CSRedisCore.dll 中)
“new CSRedis.CSRedisClient("xxxxxxx:63140,name=test,password=pen1234Q~,poolsize=3")”引发了类型“System.IO.FileNotFoundException”的异常
Data: {System.Collections.ListDictionaryInternal}
FileName: "SafeObjectPool, Version=1.0.12.0, Culture=neutral, PublicKeyToken=null"
FusionLog: "=== 预绑定状态信息 ===\r\n日志: DisplayName = SafeObjectPool, Version=1.0.12.0, Culture=neutral, PublicKeyToken=null\n (Fully-specified)\r\n日志: Appbase = file:///E:/contentOfWork/Speedster/Speedster.Web/\r\n日志: 初始 PrivatePath = E:\contentOfWork\Speedster\Speedster.Web\bin\r\n调用程序集: CSRedisCore, Version=3.0.30.0, Culture=neutral, PublicKeyToken=null。\r\n===\r\n日志: 此绑定从 default 加载上下文开始。\r\n日志: 正在使用应用程序配置文件: E:\contentOfWork\Speedster\Speedster.Web\web.config\r\n日志: 使用主机配置文件: C:\Users\Administrator\Documents\IISExpress\config\aspnet.config\r\n日志: 使用 C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config 的计算机配置文件。\r\n日志: 此时没有为引用应用策略(私有、自定义、分部或基于位置的程序集绑定)。\r\n日志: 相同的绑定已出现过,因 hr = 0x80070002 而失败。\r\n"
HResult: -2147024894
HelpLink: null
IPForWatsonBuckets: 0x0fea76cd
InnerException: null
IsTransient: false
Message: "未能加载文件或程序集“SafeObjectPool, Version=1.0.12.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。系统找不到指定的文件。"
RemoteStackTrace: null
Source: "CSRedisCore"
StackTrace: " 在 CSRedis.CSRedisClient..ctor(Func2 NodeRule, String[] connectionStrings)\r\n 在 CSRedis.CSRedisClient..ctor(String connectionString)" TargetSite: {Void .ctor(System.Func2[System.String,System.String], System.String[])}
WatsonBuckets: null
_HResult: -2147024894
_className: "System.IO.FileNotFoundException"
_data: {System.Collections.ListDictionaryInternal}
_dynamicMethods: null
_exceptionMethod: {Void .ctor(System.Func`2[System.String,System.String], System.String[])}
_exceptionMethodString: null
_fileName: "SafeObjectPool, Version=1.0.12.0, Culture=neutral, PublicKeyToken=null"
_fusionLog: "=== 预绑定状态信息 ===\r\n日志: DisplayName = SafeObjectPool, Version=1.0.12.0, Culture=neutral, PublicKeyToken=null\n (Fully-specified)\r\n日志: Appbase = file:///E:/contentOfWork/Speedster/Speedster.Web/\r\n日志: 初始 PrivatePath = E:\contentOfWork\Speedster\Speedster.Web\bin\r\n调用程序集: CSRedisCore, Version=3.0.30.0, Culture=neutral, PublicKeyToken=null。\r\n===\r\n日志: 此绑定从 default 加载上下文开始。\r\n日志: 正在使用应用程序配置文件: E:\contentOfWork\Speedster\Speedster.Web\web.config\r\n日志: 使用主机配置文件: C:\Users\Administrator\Documents\IISExpress\config\aspnet.config\r\n日志: 使用 C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config 的计算机配置文件。\r\n日志: 此时没有为引用应用策略(私有、自定义、分部或基于位置的程序集绑定)。\r\n日志: 相同的绑定已出现过,因 hr = 0x80070002 而失败。\r\n"
_helpURL: null
_innerException: null
_ipForWatsonBuckets: 0x0fea76cd
_maybeFullPath: null
_message: "未能加载文件或程序集“SafeObjectPool, Version=1.0.12.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。系统找不到指定的文件。"
_remoteStackIndex: 0
_remoteStackTraceString: null
_safeSerializationManager: {System.Runtime.Serialization.SafeSerializationManager}
_source: "CSRedisCore"
_stackTrace: {sbyte[48]}
_stackTraceString: null
_watsonBuckets: null
_xcode: -532462766
_xptrs: 0x00000000

@Ancore01
Copy link
Author

Ancore01 commented Jan 7, 2019

好的,谢谢

@Ancore01
Copy link
Author

Ancore01 commented Jan 7, 2019

“new CSRedis.CSRedisClient("xxxxx:63140,name=test,password=pen1234Q~,poolsize=3")”引发了类型“System.IO.FileLoadException”的异常
Data: {System.Collections.ListDictionaryInternal}
FileName: "Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"
FusionLog: "=== 预绑定状态信息 ===
日志: DisplayName = Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed\n (Fully-specified)
日志: Appbase = file:///E:/contentOfWork/Speedster/Speedster.Web/
日志: 初始 PrivatePath = E:\contentOfWork\Speedster\Speedster.Web\bin
调用程序集: CSRedisNFX45, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null。

日志: 此绑定从 default 加载上下文开始
日志: 正在使用应用程序配置文件: E:\contentOfWork\Speedster\Speedster.Web\web.config
日志: 使用主机配置文件: C:\Users\Administrator\Documents\IISExpress\config\aspnet.config
日志: 使用 C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config 的计算机配置文件。
日志: 策略后引用: Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
日志: 尝试下载新的 URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/daea0e65/5e9ac3f5/Newtonsoft.Json.DLL。
日志: 尝试下载新的 URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/daea0e65/5e9ac3f5/N
ewtonsoft.Json/Newtonsoft.Json.DLL。
日志: 尝试下载新的 URL file:///E:/contentOfWork/Speedster/Speedster.Web/bin/Newtonsoft.Json.DLL。
警告: 比较程序集名称时发生不匹配: 主版本
错误: 未能完成程序集的安装(hr = 0x80131040)。探测终止。
"
HResult: -2146234304
HelpLink: null
IPForWatsonBuckets: 0x2a08fda5
InnerException: null
IsTransient: false
Message: "未能加载文件或程序集“Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)"
RemoteStackTrace: null
Source: "CSRedisNFX45"
StackTrace: " 在 CSRedis.CSRedisClient..ctor(Func2 NodeRule, String[] connectionStrings) 在 CSRedis.CSRedisClient..ctor(String connectionString) 位置 E:\\contentOfWork\\Speedster\\CSRedisCore\\CSRedisClient.cs:行号 208" TargetSite: {Void .ctor(System.Func2[System.String,System.String], System.String[])}
WatsonBuckets: null
_HResult: -2146234304
_className: null
_data: {System.Collections.ListDictionaryInternal}
_dynamicMethods: null
_exceptionMethod: {Void .ctor(System.Func`2[System.String,System.String], System.String[])}
_exceptionMethodString: null
_fileName: "Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"
_fusionLog: "=== 预绑定状态信息 ===
日志: DisplayName = Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
(Fully-specified)
日志: Appbase = file:///E:/contentOfWork/Speedster/Speedster.Web/
日志: 初始 PrivatePath = E:\contentOfWork\Speedster\Speedster.Web\bin
调用程序集: CSRedisNFX45, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null。

日志: 此绑定从 default 加载上下文开始。
日志: 正在使用应用程序配置文件: E:\contentOfWork\Speedster\Speedster.Web\web.config
日志: 使用主机配置文件: C:\Users\Administrator\Documents\IISExpress\config\aspnet.config
日志: 使用 C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config 的计算机配置文件。
日志: 策略后引用: Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
日志: 尝试下载新的 URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/daea0e65/5e9ac3f5/Newtonsoft.Json.DLL。
日志: 尝试下载新的 URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/daea0e65/5e9ac3f5/
Newtonsoft.Json/Newtonsoft.Json.DLL。
日志: 尝试下载新的 URL file:///E:/contentOfWork/Speedster/Speedster.Web/bin/Newtonsoft.Json.DLL。
警告: 比较程序集名称时发生不匹配: 主版本
错误: 未能完成程序集的安装(hr = 0x80131040)。探测终止。
"
_helpURL: null
_innerException: null
_ipForWatsonBuckets: 0x2a08fda5
_maybeFullPath: null
_message: "未能加载文件或程序集“Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)"
_remoteStackIndex: 0
_remoteStackTraceString: null
_safeSerializationManager: {System.Runtime.Serialization.SafeSerializationManager}
_source: "CSRedisNFX45"
_stackTrace: {sbyte[48]}
_stackTraceString: null
_watsonBuckets: null
_xcode: -532462766
_xptrs: 0x00000000

看了这个日志,知道是版本不同引起的错误

@2881099
Copy link
Owner

2881099 commented Jan 7, 2019

你可以修改为你主程序中引用的版本,csredis没有其他依赖引用了,只有这一个

@2881099
Copy link
Owner

2881099 commented Jan 7, 2019

image
修改成主程序引用的版本

@Ancore01
Copy link
Author

Ancore01 commented Jan 8, 2019

谢谢大佬

@Ancore01
Copy link
Author

Ancore01 commented Jul 5, 2019

你可以修改为你主程序中引用的版本,csredis没有其他依赖引用了,只有这一个

你好,请问现在的版本是可以直接在NuGet里面引用,而不需要修改Newtonsoft的版本了吗

@2881099
Copy link
Owner

2881099 commented Jul 5, 2019

@2881099
Copy link
Owner

2881099 commented Jul 5, 2019

你那边是不是还是 json.net 11.0 的问题

@Ancore01
Copy link
Author

Ancore01 commented Jul 5, 2019

这边没问题,只是项目负责人说直接从NuGet上引用,之后可以方便升级,但是我们用的json还是之前的低版本版本。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants