asp.net移植到linux下mono环境碰到的问题

近来需要把一个asp.net的站点部署到linux下。

asp.net使用的是mvc3框架,其中也有webservice和wcf服务。

至于mono安装云云就不说了,网上很多。

下面几个问题有些我也没有解决。但网站是正常跑起来了。

第一次放上去时就出现无法编译的问题:

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) [0x00045] in /data/tmp/mono-2.10/mcs/class/corlib/System.Reflection/AssemblyName.cs:93

~/Global.asax

Show Detailed Compiler Output:


Version information: Mono Runtime Version: 2.10 (tarball Fri May 4 11:10:52 CST 2012); ASP.NET Version:4.0.30319.

好吧,这问题我头痛了,可能是以前建项目的问题,我重新创建项目再把以前的文件加进来。结果好了。我就不管这个了

下面又碰到问题了,站点中有个webservice,死活访问不了,一直报:

System.Web.Compilation.CompilationException CS1703: An assembly with the same identity `mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ has already been imported. Consider removing one of the references Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error. Details: CS1703: An assembly with the same identity `mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ has already been imported. Consider removing one of the references Error origin: Compiler Error source file: ~/DefaultWsdlHelpGenerator.aspx Exception stack trace: at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00000] in :0 at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] in :0 at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00000] in :0 at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x00000] in :0 Version Information: 2.11.1 (tarball Wed May 9 23:15:56 CST 2012); ASP.NET Version: 4.0.30319.17020

这我也悲据了,在windows下的mono都能跑,但一放到linux下就出这个,我也没有解决,直接换成wcf.嗯。。OK了。虽然webservice切成wcf很简单,但我还是郁闷。webservice为啥就不行了呢。好了正常了就算了。我也懒得管它。WCF用起来也不错。

哎。下面这个问题我最蛋痛了,站点中 要引用其它webservice和wcf.

一般情况下我们直接引用进来,new一个client即可访问了,但linux下死活也不行。

System.Reflection.ReflectionTypeLoadException The classes in the module cannot be loaded. Description: HTTP 500.Error processing request. Details: Non-web exception. Exception origin (name of application or object): mscorlib. Exception stack trace: at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool) at System.Reflection.Assembly.GetTypes () [0x00000] in :0 at System.ServiceModel.Configuration.ConfigUtil.GetTypeFromConfigString (System.String name, NamedConfigCategory category) [0x00000] in :0 at System.ServiceModel.ChannelFactory.ApplyConfiguration (System.String endpointConfig) [0x00000] in :0 at System.ServiceModel.ChannelFactory.InitializeEndpoint (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in :0 at System.ServiceModel.ChannelFactory`1[JM.Common.Examples.web.monoserver.Itest2]..ctor (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in :0 at System.ServiceModel.ClientBase`1[JM.Common.Examples.web.monoserver.Itest2].Initialize (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in :0 at System.ServiceModel.ClientBase`1[JM.Common.Examples.web.monoserver.Itest2]..ctor (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName) [0x00000] in :0 at System.ServiceModel.ClientBase`1[JM.Common.Examples.web.monoserver.Itest2]..ctor (System.ServiceModel.InstanceContext instance) [0x00000] in :0 at System.ServiceModel.ClientBase`1[JM.Common.Examples.web.monoserver.Itest2]..ctor () [0x00000] in :0 at JM.Common.Examples.web.monoserver.Itest2Client..ctor () [0x00000] in :0 at JM.Common.Examples.web.testserver.Page_Load (System.Object sender, System.EventArgs e) [0x00000] in :0 at System.Web.UI.Control.OnLoad (System.EventArgs e) [0x00000] in :0 at System.Web.UI.Control.LoadRecursive () [0x00000] in :0 at System.Web.UI.Page.ProcessLoad () [0x00000] in :0 at System.Web.UI.Page.ProcessPostData () [0x00000] in :0 at System.Web.UI.Page.InternalProcessRequest () [0x00000] in :0 at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] in :0

除了这个外还报过一个key为空的错,同样是找不到引用中的一些配置。

那我只有试试手动new了,

  1. var binding = new BasicHttpBinding(“BasicHttpBinding_Itest2”);
  2. var epa = new EndpointAddress(“http://127.0.0.1:8080/test2.svc”);
  3. var client = new monoserver.Itest2Client(binding,epa);
  4. var r = client.DoWork();

BasicHttpBinding_Itest2就是webconfig中的binding配置名,如此顺利跑通了。这个问题确实让我不解,难道mono不能自动去读取的么。非要我手动实例化,微软的.net就没有这问题。

引用webservice也是如些。必须手动去实例化才不出错。以windows下的想法搞不定它啊

最后一个问题就是mvc3中。我们经常用model去生成页面控件。这样当提交时,后台可直接用model.XX读取这个控件的值。

但在linux下的mono却不行,model的属性全是空,非得自已写<input 等等。后台request.Form[“name”]去获取。

这个问题可能是mono下的mvc就是不支持这样吧。

以上问题如果有大虾知道更好的解决办法的话。可以告知小生,THS

本文链接



You must enable javascript to see captcha here!

Copyright © All Rights Reserved · Green Hope Theme by Sivan & schiy · Proudly powered by WordPress

无觅相关文章插件,快速提升流量