单声道 2.10.2 + asp.net mvc3 + MySql.Data.dll
我有以下配置:
CentOS 5.6 final (Linux 2.6.18-238.12.1.el5 #1 SMP Tue May 31 13:22:04 EDT 2011 x86_64)
Apache web server (Apache/2.2.17 (EL), API 20051115)
Mono 2.10.2 (from repository http://ftp.novell.com/pub/mono/download-stable/RHEL_5/
Mono is running via mod_mono.
我正在尝试制作非常简单的 asp.net mvc3 应用程序。在我添加 MySQL 数据库访问之前,一切都运行良好。我读过一些关于 MySQL 噩梦的文档,所以我使用非常基本的方法( http://loft7270.serverloft .com/honza/DataAccess.cs)。
我从 mysql.com 站点(.NET & Mono 版本)获取了 MySQL Connector/NET 6.4.4,获取了 mysql.data.dll(.NET4.0 版本),将文件名固定为 MySql.Data.dll 将其放在服务器上并使用安装到.NET
gacutil /i MySql.Data.dll
我已经使用验证了安装
gacutil /l
(结果列表:链接->http://loft7270.serverloft.com/honza/registeredAssemblies.txt)
无论我做什么,我当我尝试使用 MySql 时总是出现错误:
Server Error in '/yelt' Application
The assembly name is invalid.
Description: HTTP 500. Error processing request.
Stack Trace:
System.IO.FileLoadException: The assembly name is invalid.
at System.Reflection.AssemblyName..ctor (string) <0x000af>
at Mono.CSharp.ImportedAssemblyDefinition.ReadAttributes () <0x001e7>
at Mono.CSharp.MetadataImporter.GetAssemblyDefinition (System.Reflection.Assembly) <0x00093>
at Mono.CSharp.ReflectionImporter.ImportAssembly (System.Reflection.Assembly,Mono.CSharp.RootNamespace) <0x0003b>
at Microsoft.CSharp.RuntimeBinder.DynamicContext.Create () <0x00297>
at Microsoft.CSharp.RuntimeBinder.CSharpSetMemberBinder.FallbackSetMember (System.Dynamic.DynamicMetaObject,System.Dynamic.DynamicMetaObject,System.Dynamic.DynamicMetaObject) <0x00037>
at System.Dynamic.DynamicObject/MetaDynamic/<BindSetMember>c__AnonStorey3B.<>m__4 (System.Dynamic.DynamicMetaObject) <0x0002c>
at System.Dynamic.DynamicObject/MetaDynamic.CallMethodReturnLast (string,System.Dynamic.DynamicMetaObjectBinder,System.Linq.Expressions.Expression[],System.Linq.Expressions.Expression,System.Dynamic.DynamicObject/MetaDynamic/Fallback) <0x00035>
at System.Dynamic.DynamicObject/MetaDynamic.BindSetMember (System.Dynamic.SetMemberBinder,System.Dynamic.DynamicMetaObject) <0x000eb>
at System.Dynamic.SetMemberBinder.Bind (System.Dynamic.DynamicMetaObject,System.Dynamic.DynamicMetaObject[]) <0x000ac>
at System.Dynamic.DynamicMetaObjectBinder.Bind (object[],System.Collections.ObjectModel.ReadOnlyCollection`1<System.Linq.Expressions.ParameterExpression>,System.Linq.Expressions.LabelTarget) <0x001a4>
at System.Runtime.CompilerServices.CallSiteBinder.BindCore<System.Func`4<System.Runtime.CompilerServices.CallSite, object, string, object>> (System.Runtime.CompilerServices.CallSite`1<System.Func`4<System.Runtime.CompilerServices.CallSite, object, string, object>>,object[]) <0x000a1>
at System.Dynamic.UpdateDelegates.UpdateAndExecute2<object, string, object> (System.Runtime.CompilerServices.CallSite,object,string) <0x00417>
at Yelt.Controllers.HomeController.Index () <0x0011d>
at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,System.Web.Mvc.ControllerBase,object[]) <0x00045>
at System.Web.Mvc.ActionMethodDispatcher.Execute (System.Web.Mvc.ControllerBase,object[]) <0x0002d>
at System.Web.Mvc.ReflectedActionDescriptor.Execute (System.Web.Mvc.ControllerContext,System.Collections.Generic.IDictionary`2<string, object>) <0x0012b>
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod (System.Web.Mvc.ControllerContext,System.Web.Mvc.ActionDescriptor,System.Collections.Generic.IDictionary`2<string, object>) <0x00033>
at System.Web.Mvc.ControllerActionInvoker/<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12 () <0x00072>
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter (System.Web.Mvc.IActionFilter,System.Web.Mvc.ActionExecutingContext,System.Func`1<System.Web.Mvc.ActionExecutedContext>) <0x000ed>
Version information: Mono Runtime Version: 2.10.2 (tarball Mon Apr 18 19:06:50 UTC 2011); ASP.NET Version: 4.0.30319.1
尝试将 MySql.Data.dll 复制到 /bin 文件夹会导致不同的错误:
Server Error in '/yelt' Application
Compilation Error
Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.
Compiler Error Message: : at System.Reflection.AssemblyName..ctor (System.String assemblyName) [0x00000] in <filename unknown>:0
~/Global.asax
Show Detailed Compiler Output:
dmcs /target:library /lib:"/var/www/asp.net/yelt/bin" /debug+ /optimize- /warn:4 /out:"/tmp/apache-temp-aspnet-0/165eac4/App_global.asax_4aaabf1a.dll" /r:"/opt/novell/mono/lib/mono/4.0/mscorlib.dll" /r:"/opt/novell/mono/lib/mono/gac/Microsoft.CSharp/4.0.0.0__b03f5f7f11d50a3a/Microsoft.CSharp.dll" /r:"/opt/novell/mono/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Web/4.0.0.0__b03f5f7f11d50a3a/System.Web.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Data/4.0.0.0__b77a5c561934e089/System.Data.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Web.Services/4.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll" /r:"/opt/novell/mono/lib/mono/gac/System.EnterpriseServices/4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll" /r:"/opt/novell/mono/lib/mono/gac/System.IdentityModel/4.0.0.0__b77a5c561934e089/System.IdentityModel.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Runtime.Serialization/4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Xaml/4.0.0.0__b77a5c561934e089/System.Xaml.dll" /r:"/opt/novell/mono/lib/mono/gac/System.ServiceModel/4.0.0.0__b77a5c561934e089/System.ServiceModel.dll" /r:"/opt/novell/mono/lib/mono/gac/System.ServiceModel.Web/4.0.0.0__31bf3856ad364e35/System.ServiceModel.Web.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Web.Extensions/4.0.0.0__31bf3856ad364e35/System.Web.Extensions.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Data.DataSetExtensions/4.0.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Xml.Linq/4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll" /r:"/opt/novell/mono/lib/mono/gac/System.ComponentModel.DataAnnotations/4.0.0.0__31bf3856ad364e35/System.ComponentModel.DataAnnotations.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Web.DynamicData/4.0.0.0__31bf3856ad364e35/System.Web.DynamicData.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Data.Linq/4.0.0.0__b77a5c561934e089/System.Data.Linq.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Web.ApplicationServices/4.0.0.0__31bf3856ad364e35/System.Web.ApplicationServices.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Web.Abstractions/4.0.0.0__31bf3856ad364e35/System.Web.Abstractions.dll" /r:"/var/www/asp.net/yelt/bin/System.Web.Helpers.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Web.Routing/4.0.0.0__31bf3856ad364e35/System.Web.Routing.dll" /r:"/var/www/asp.net/yelt/bin/System.Web.Mvc.dll" /r:"/var/www/asp.net/yelt/bin/System.Web.WebPages.dll" /r:"/var/www/asp.net/yelt/bin/MySql.Data.dll" /r:"/var/www/asp.net/yelt/bin/NuGet.Core.dll" /r:"/var/www/asp.net/yelt/bin/System.Web.Razor.dll" /r:"/var/www/asp.net/yelt/bin/System.Web.WebPages.Administration.dll" /r:"/var/www/asp.net/yelt/bin/System.Web.WebPages.Deployment.dll" /r:"/var/www/asp.net/yelt/bin/System.Web.WebPages.Razor.dll" /r:"/var/www/asp.net/yelt/bin/WebMatrix.Data.dll" /r:"/var/www/asp.net/yelt/bin/WebMatrix.WebData.dll" /r:"/var/www/asp.net/yelt/bin/Yelt.dll" /nowarn:0169 /d:DEBUG -- "/tmp/apache-temp-aspnet-0/165eac4/App_global.asax_4aaabf1a_0.cs"
Unhandled Exception: System.IO.FileLoadException: The assembly name is invalid.
at System.Reflection.AssemblyName..ctor (System.String assemblyName) [0x00000] in :0
at Mono.CSharp.ImportedAssemblyDefinition.ReadAttributes () [0x00000] in :0
at Mono.CSharp.MetadataImporter.GetAssemblyDefinition (System.Reflection.Assembly assembly) [0x00000] in :0
at Mono.CSharp.ReflectionImporter.ImportAssembly (System.Reflection.Assembly assembly, Mono.CSharp.RootNamespace targetNamespace) [0x00000] in :0
at Mono.CSharp.DynamicLoader.LoadReferences (Mono.CSharp.ModuleContainer module) [0x00000] in :0
at Mono.CSharp.Driver.Compile () [0x00000] in :0
at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in :0
Version information: Mono Runtime Version: 2.10.2 (tarball Mon Apr 18 19:06:50 UTC 2011); ASP.NET Version: 4.0.30319.1
我尝试将 mono 升级到 2.10.8,因为根据一些网站 MySql.Data 根本无法工作2.10.2 由于一些错误,但不幸的是链接->http://help.tcadmin.com/Mono 也没有link->http://http://www.fcraft.net/wiki/Building_Mono walktrhoughs 导致可以工作的 asp.net 站点(即使删除了 mysql 的东西)。
知道如何强制 MySQL 连接器工作吗?我已经没有主意了:-/ VS2010 项目精简为基本内容,导致错误: http://loft7270.serverloft.com/honza/Yelt .zip
I have following configuration:
CentOS 5.6 final (Linux 2.6.18-238.12.1.el5 #1 SMP Tue May 31 13:22:04 EDT 2011 x86_64)
Apache web server (Apache/2.2.17 (EL), API 20051115)
Mono 2.10.2 (from repository http://ftp.novell.com/pub/mono/download-stable/RHEL_5/
Mono is running via mod_mono.
I am trying to make really simple asp.net mvc3 application. Everything worked well until I have added MySQL database access. I have read some documents about MySQL nightmare so I am using very elementary approach ( http://loft7270.serverloft.com/honza/DataAccess.cs ).
I have taken MySQL Connector/NET 6.4.4 from mysql.com site (.NET & Mono version), taken mysql.data.dll (.NET4.0 version), fixed filename to MySql.Data.dll put it on server and installed to .NET using
gacutil /i MySql.Data.dll
I have verified the installation using
gacutil /l
(The resulting list: link->http://loft7270.serverloft.com/honza/registeredAssemblies.txt )
No matter what I do, I always get error when I try to use MySql:
Server Error in '/yelt' Application
The assembly name is invalid.
Description: HTTP 500. Error processing request.
Stack Trace:
System.IO.FileLoadException: The assembly name is invalid.
at System.Reflection.AssemblyName..ctor (string) <0x000af>
at Mono.CSharp.ImportedAssemblyDefinition.ReadAttributes () <0x001e7>
at Mono.CSharp.MetadataImporter.GetAssemblyDefinition (System.Reflection.Assembly) <0x00093>
at Mono.CSharp.ReflectionImporter.ImportAssembly (System.Reflection.Assembly,Mono.CSharp.RootNamespace) <0x0003b>
at Microsoft.CSharp.RuntimeBinder.DynamicContext.Create () <0x00297>
at Microsoft.CSharp.RuntimeBinder.CSharpSetMemberBinder.FallbackSetMember (System.Dynamic.DynamicMetaObject,System.Dynamic.DynamicMetaObject,System.Dynamic.DynamicMetaObject) <0x00037>
at System.Dynamic.DynamicObject/MetaDynamic/<BindSetMember>c__AnonStorey3B.<>m__4 (System.Dynamic.DynamicMetaObject) <0x0002c>
at System.Dynamic.DynamicObject/MetaDynamic.CallMethodReturnLast (string,System.Dynamic.DynamicMetaObjectBinder,System.Linq.Expressions.Expression[],System.Linq.Expressions.Expression,System.Dynamic.DynamicObject/MetaDynamic/Fallback) <0x00035>
at System.Dynamic.DynamicObject/MetaDynamic.BindSetMember (System.Dynamic.SetMemberBinder,System.Dynamic.DynamicMetaObject) <0x000eb>
at System.Dynamic.SetMemberBinder.Bind (System.Dynamic.DynamicMetaObject,System.Dynamic.DynamicMetaObject[]) <0x000ac>
at System.Dynamic.DynamicMetaObjectBinder.Bind (object[],System.Collections.ObjectModel.ReadOnlyCollection`1<System.Linq.Expressions.ParameterExpression>,System.Linq.Expressions.LabelTarget) <0x001a4>
at System.Runtime.CompilerServices.CallSiteBinder.BindCore<System.Func`4<System.Runtime.CompilerServices.CallSite, object, string, object>> (System.Runtime.CompilerServices.CallSite`1<System.Func`4<System.Runtime.CompilerServices.CallSite, object, string, object>>,object[]) <0x000a1>
at System.Dynamic.UpdateDelegates.UpdateAndExecute2<object, string, object> (System.Runtime.CompilerServices.CallSite,object,string) <0x00417>
at Yelt.Controllers.HomeController.Index () <0x0011d>
at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,System.Web.Mvc.ControllerBase,object[]) <0x00045>
at System.Web.Mvc.ActionMethodDispatcher.Execute (System.Web.Mvc.ControllerBase,object[]) <0x0002d>
at System.Web.Mvc.ReflectedActionDescriptor.Execute (System.Web.Mvc.ControllerContext,System.Collections.Generic.IDictionary`2<string, object>) <0x0012b>
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod (System.Web.Mvc.ControllerContext,System.Web.Mvc.ActionDescriptor,System.Collections.Generic.IDictionary`2<string, object>) <0x00033>
at System.Web.Mvc.ControllerActionInvoker/<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12 () <0x00072>
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter (System.Web.Mvc.IActionFilter,System.Web.Mvc.ActionExecutingContext,System.Func`1<System.Web.Mvc.ActionExecutedContext>) <0x000ed>
Version information: Mono Runtime Version: 2.10.2 (tarball Mon Apr 18 19:06:50 UTC 2011); ASP.NET Version: 4.0.30319.1
Trying to copy MySql.Data.dll to /bin folder results in different error:
Server Error in '/yelt' Application
Compilation Error
Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.
Compiler Error Message: : at System.Reflection.AssemblyName..ctor (System.String assemblyName) [0x00000] in <filename unknown>:0
~/Global.asax
Show Detailed Compiler Output:
dmcs /target:library /lib:"/var/www/asp.net/yelt/bin" /debug+ /optimize- /warn:4 /out:"/tmp/apache-temp-aspnet-0/165eac4/App_global.asax_4aaabf1a.dll" /r:"/opt/novell/mono/lib/mono/4.0/mscorlib.dll" /r:"/opt/novell/mono/lib/mono/gac/Microsoft.CSharp/4.0.0.0__b03f5f7f11d50a3a/Microsoft.CSharp.dll" /r:"/opt/novell/mono/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Web/4.0.0.0__b03f5f7f11d50a3a/System.Web.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Data/4.0.0.0__b77a5c561934e089/System.Data.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Web.Services/4.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll" /r:"/opt/novell/mono/lib/mono/gac/System.EnterpriseServices/4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll" /r:"/opt/novell/mono/lib/mono/gac/System.IdentityModel/4.0.0.0__b77a5c561934e089/System.IdentityModel.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Runtime.Serialization/4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Xaml/4.0.0.0__b77a5c561934e089/System.Xaml.dll" /r:"/opt/novell/mono/lib/mono/gac/System.ServiceModel/4.0.0.0__b77a5c561934e089/System.ServiceModel.dll" /r:"/opt/novell/mono/lib/mono/gac/System.ServiceModel.Web/4.0.0.0__31bf3856ad364e35/System.ServiceModel.Web.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Web.Extensions/4.0.0.0__31bf3856ad364e35/System.Web.Extensions.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Data.DataSetExtensions/4.0.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Xml.Linq/4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll" /r:"/opt/novell/mono/lib/mono/gac/System.ComponentModel.DataAnnotations/4.0.0.0__31bf3856ad364e35/System.ComponentModel.DataAnnotations.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Web.DynamicData/4.0.0.0__31bf3856ad364e35/System.Web.DynamicData.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Data.Linq/4.0.0.0__b77a5c561934e089/System.Data.Linq.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Web.ApplicationServices/4.0.0.0__31bf3856ad364e35/System.Web.ApplicationServices.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Web.Abstractions/4.0.0.0__31bf3856ad364e35/System.Web.Abstractions.dll" /r:"/var/www/asp.net/yelt/bin/System.Web.Helpers.dll" /r:"/opt/novell/mono/lib/mono/gac/System.Web.Routing/4.0.0.0__31bf3856ad364e35/System.Web.Routing.dll" /r:"/var/www/asp.net/yelt/bin/System.Web.Mvc.dll" /r:"/var/www/asp.net/yelt/bin/System.Web.WebPages.dll" /r:"/var/www/asp.net/yelt/bin/MySql.Data.dll" /r:"/var/www/asp.net/yelt/bin/NuGet.Core.dll" /r:"/var/www/asp.net/yelt/bin/System.Web.Razor.dll" /r:"/var/www/asp.net/yelt/bin/System.Web.WebPages.Administration.dll" /r:"/var/www/asp.net/yelt/bin/System.Web.WebPages.Deployment.dll" /r:"/var/www/asp.net/yelt/bin/System.Web.WebPages.Razor.dll" /r:"/var/www/asp.net/yelt/bin/WebMatrix.Data.dll" /r:"/var/www/asp.net/yelt/bin/WebMatrix.WebData.dll" /r:"/var/www/asp.net/yelt/bin/Yelt.dll" /nowarn:0169 /d:DEBUG -- "/tmp/apache-temp-aspnet-0/165eac4/App_global.asax_4aaabf1a_0.cs"
Unhandled Exception: System.IO.FileLoadException: The assembly name is invalid.
at System.Reflection.AssemblyName..ctor (System.String assemblyName) [0x00000] in :0
at Mono.CSharp.ImportedAssemblyDefinition.ReadAttributes () [0x00000] in :0
at Mono.CSharp.MetadataImporter.GetAssemblyDefinition (System.Reflection.Assembly assembly) [0x00000] in :0
at Mono.CSharp.ReflectionImporter.ImportAssembly (System.Reflection.Assembly assembly, Mono.CSharp.RootNamespace targetNamespace) [0x00000] in :0
at Mono.CSharp.DynamicLoader.LoadReferences (Mono.CSharp.ModuleContainer module) [0x00000] in :0
at Mono.CSharp.Driver.Compile () [0x00000] in :0
at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in :0
Version information: Mono Runtime Version: 2.10.2 (tarball Mon Apr 18 19:06:50 UTC 2011); ASP.NET Version: 4.0.30319.1
I have tried to upgrade mono to 2.10.8 since according to some webs MySql.Data simply wouldn't work with 2.10.2 due to some bug but unfortunately neither link->http://help.tcadmin.com/Mono nor link->http://http://www.fcraft.net/wiki/Building_Mono walktrhoughs led to working asp.net site (even with mysql stuff stripped out).
Any idea how to force MySQL connector to work? I have run out of ideas :-/
VS2010 Project stripped down to elementary content causing error: http://loft7270.serverloft.com/honza/Yelt.zip
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论