首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在单声道上结合使用MEFContrib和MVC3时出错

在单声道上结合使用MEFContrib和MVC3时出错
EN

Stack Overflow用户
提问于 2011-12-19 21:35:50
回答 1查看 499关注 0票数 0

在我的CentOS5服务器上安装了Mono和Mod_Mono之后,我已经设法让服务器激活了我的MVC3站点(它在IIS下运行得很好)。

不幸的是,在尝试使用Apache运行时,我得到了一个错误:

找不到方法:'System.Web.Helpers.Chart.ExecuteChartAction'.描述: HTTP 500。处理请求时出错。

这是我所特有的,因为我的代码中根本没有对Chart类的引用。异常似乎也来自组合,堆栈跟踪包括对MefContrib的各种引用。

我已经尝试过在我的bin目录中使用各种不同的.dlls组合。这是它目前的内容,它让我走到了这个阶段:

代码语言:javascript
复制
MyDll.dll            MefContrib.Web.Mvc.dll  System.Web.WebPages.Deployment.dll
MyDll.pdb            System.Web.Helpers.dll  System.Web.WebPages.Deployment.xml
MyDll2.dll           System.Web.Helpers.xml  System.Web.WebPages.dll
MyDll2.pdb           System.Web.Mvc.dll      System.Web.WebPages.Razor.dll
HtmlAgilityPack.dll  System.Web.Mvc.xml      System.Web.WebPages.Razor.xml
HtmlAgilityPack.pdb  System.Web.Razor.dll    System.Web.WebPages.xml
HtmlAgilityPack.xml  System.Web.Razor.xml    WebActivator.dll
MefContrib.dll       System.Web.Routing.dll

其中,MyDll和MyDll2是我构建的项目dlls,其中包括为MEF组成的各种服务的导出和导入。

我最好的猜测是,除了这个,我的项目是一个非常简单的MefContrib应用程序,在Mono中有一些东西不能很好地与Mono一起运行。

完整堆栈跟踪:'/‘应用程序中的服务器错误

代码语言:javascript
复制
Method not found: 'System.Web.Helpers.Chart.ExecuteChartAction'.

Description: HTTP 500. Error processing request.

Stack Trace:

Server Error in '/' Application

Method not found: 'System.Web.Helpers.Chart.ExecuteChartAction'.

Description: HTTP 500. Error processing request.

Stack Trace:

System.MissingMethodException: Method not found: 'System.Web.Helpers.Chart.ExecuteChartAction'.
at (wrapper managed-to-native) System.Reflection.MonoMethodInfo.get_method_info (intptr,System.Reflection.MonoMethodInfo&) <IL 0x00008, 0x0004c>
at System.Reflection.MonoMethodInfo.GetMethodInfo (intptr) [0x00000] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/corlib/System.Reflection/MonoMethod.cs:63
at System.Reflection.MonoMethod.GetPseudoCustomAttributes () [0x00002] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/corlib/System.Reflection/MonoMethod.cs:295
at System.MonoCustomAttrs.GetPseudoCustomAttributes (System.Reflection.ICustomAttributeProvider,System.Type) [0x0000d] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/corlib/System/MonoCustomAttrs.cs:68
at System.MonoCustomAttrs.IsDefined (System.Reflection.ICustomAttributeProvider,System.Type,bool) [0x00039] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/corlib/System/MonoCustomAttrs.cs:291
at System.Reflection.MonoMethod.IsDefined (System.Type,bool) [0x00000] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/corlib/System.Reflection/MonoMethod.cs:276
at Microsoft.Internal.AttributeServices.IsAttributeDefined<System.ComponentModel.Composition.ExportAttribute> (System.Reflection.ICustomAttributeProvider,bool) <0x00036>
at System.ComponentModel.Composition.AttributedModel.AttributedPartCreationInfo.IsExport (System.Reflection.ICustomAttributeProvider) [0x00000] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/AttributedModel/AttributedPartCreationInfo.cs:355
at System.ComponentModel.Composition.AttributedModel.AttributedPartCreationInfo/<GetExportMembers>c__Iterator0.MoveNext () [0x0017f] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/AttributedModel/AttributedPartCreationInfo.cs:302
at System.Linq.Enumerable.Any<System.Reflection.MemberInfo> (System.Collections.Generic.IEnumerable`1<System.Reflection.MemberInfo>) <0x0009e>
at System.ComponentModel.Composition.AttributedModel.AttributedPartCreationInfo.HasExports () [0x00000] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/AttributedModel/AttributedPartCreationInfo.cs:106
at System.ComponentModel.Composition.AttributedModel.AttributedPartCreationInfo.IsPartDiscoverable () [0x0003a] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/AttributedModel/AttributedPartCreationInfo.cs:95
at System.ComponentModel.Composition.AttributedModel.AttributedModelDiscovery.CreatePartDefinitionIfDiscoverable (System.Type,System.ComponentModel.Composition.Primitives.ICompositionElement) [0x0000a] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/AttributedModel/AttributedModelDiscovery.cs:19
at System.ComponentModel.Composition.Hosting.TypeCatalog.get_PartsInternal () [0x00051] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/TypeCatalog.cs:166
at System.ComponentModel.Composition.Hosting.TypeCatalog.get_Parts () [0x00006] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/TypeCatalog.cs:123
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_Parts () [0x00000] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/AssemblyCatalog.cs:137
at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,System.ComponentModel.Composition.Primitives.ComposablePartCatalog) <IL 0x00001, 0x00013>
at System.Linq.Enumerable/<CreateSelectManyIterator>c__Iterator29`2<System.ComponentModel.Composition.Primitives.ComposablePartCatalog, System.ComponentModel.Composition.Primitives.ComposablePartDefinition>.MoveNext () <0x00114>
at System.Linq.Enumerable/<CreateSelectManyIterator>c__Iterator29`2<System.ComponentModel.Composition.Primitives.ComposablePartCatalog, System.ComponentModel.Composition.Primitives.ComposablePartDefinition>.MoveNext () <0x00206>
at System.Collections.Generic.List`1<System.ComponentModel.Composition.Primitives.ComposablePartDefinition>.AddEnumerable (System.Collections.Generic.IEnumerable`1<System.ComponentModel.Composition.Primitives.ComposablePartDefinition>) <0x0008a>
at System.Collections.Generic.List`1<System.ComponentModel.Composition.Primitives.ComposablePartDefinition>..ctor (System.Collections.Generic.IEnumerable`1<System.ComponentModel.Composition.Primitives.ComposablePartDefinition>) <0x0008b>
at MefContrib.Hosting.Interception.InterceptingCatalog.GetParts () <IL 0x00033, 0x0009b>
at MefContrib.Hosting.Interception.InterceptingCatalog.get_Parts () <IL 0x00001, 0x0000f>
at System.ComponentModel.Composition.Primitives.ComposablePartCatalog.GetExports (System.ComponentModel.Composition.Primitives.ImportDefinition) [0x00017] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Primitives/ComposablePartCatalog.cs:88
at MefContrib.Hosting.Interception.InterceptingCatalog.GetExports (System.ComponentModel.Composition.Primitives.ImportDefinition) <IL 0x00010, 0x00033>
at MefContrib.Hosting.Filter.FilteringCatalog.GetExports (System.ComponentModel.Composition.Primitives.ImportDefinition) <IL 0x00007, 0x00021>
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore (System.ComponentModel.Composition.Primitives.ImportDefinition,System.ComponentModel.Composition.Hosting.AtomicComposition) [0x00040] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/CatalogExportProvider.cs:279
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore (System.ComponentModel.Composition.Primitives.ImportDefinition,System.ComponentModel.Composition.Hosting.AtomicComposition,System.Collections.Generic.IEnumerable`1<System.ComponentModel.Composition.Primitives.Export>&) [0x00006] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/ExportProvider.cs:208
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports (System.ComponentModel.Composition.Primitives.ImportDefinition,System.ComponentModel.Composition.Hosting.AtomicComposition) [0x0000b] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/ExportProvider.cs:102
at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore (System.ComponentModel.Composition.Primitives.ImportDefinition,System.ComponentModel.Composition.Hosting.AtomicComposition) [0x00030] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/AggregateExportProvider.cs:157
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore (System.ComponentModel.Composition.Primitives.ImportDefinition,System.ComponentModel.Composition.Hosting.AtomicComposition,System.Collections.Generic.IEnumerable`1<System.ComponentModel.Composition.Primitives.Export>&) [0x00006] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/ExportProvider.cs:208
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports (System.ComponentModel.Composition.Primitives.ImportDefinition,System.ComponentModel.Composition.Hosting.AtomicComposition,System.Collections.Generic.IEnumerable`1<System.ComponentModel.Composition.Primitives.Export>&) [0x0000e] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/ExportProvider.cs:145
at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore (System.ComponentModel.Composition.Primitives.ImportDefinition,System.ComponentModel.Composition.Hosting.AtomicComposition) [0x00008] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/CompositionContainer.cs:396
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore (System.ComponentModel.Composition.Primitives.ImportDefinition,System.ComponentModel.Composition.Hosting.AtomicComposition,System.Collections.Generic.IEnumerable`1<System.ComponentModel.Composition.Primitives.Export>&) [0x00006] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/ExportProvider.cs:208
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports (System.ComponentModel.Composition.Primitives.ImportDefinition,System.ComponentModel.Composition.Hosting.AtomicComposition) [0x0000b] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/ExportProvider.cs:102
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportsCore (System.Type,System.Type,string,System.ComponentModel.Composition.Primitives.ImportCardinality) [0x0006b] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/ExportProvider.GetExportOverrides.cs:799
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports (System.Type,System.Type,string) [0x00000] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/ComponentModel/Composition/Hosting/ExportProvider.GetExportOverrides.cs:267
at MefContrib.Web.Mvc.CompositionDependencyResolver.GetService (System.Type) <IL 0x00009, 0x0002b>
at System.Web.Mvc.DependencyResolverExtensions.GetService<System.Web.Mvc.IControllerFactory> (System.Web.Mvc.IDependencyResolver) <0x0002d>
at System.Web.Mvc.SingleServiceResolver`1<System.Web.Mvc.IControllerFactory>.get_Current () <0x00097>
at System.Web.Mvc.ControllerBuilder.GetControllerFactory () <IL 0x00006, 0x00021>
at System.Web.Mvc.MvcRouteHandler.GetSessionStateBehavior (System.Web.Routing.RequestContext) <IL 0x00024, 0x00097>
at System.Web.Mvc.MvcRouteHandler.GetHttpHandler (System.Web.Routing.RequestContext) <IL 0x00008, 0x0002c>
at System.Web.Mvc.MvcRouteHandler.System.Web.Routing.IRouteHandler.GetHttpHandler (System.Web.Routing.RequestContext) <IL 0x00002, 0x00015>
at System.Web.Routing.UrlRoutingModule.PostResolveRequestCache (System.Web.HttpContextBase) [0x00054] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.Web.Routing/System.Web.Routing/UrlRoutingModule.cs:127
at System.Web.Routing.UrlRoutingModule.PostResolveRequestCache (object,System.EventArgs) [0x00007] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.Web.Routing/System.Web.Routing/UrlRoutingModule.cs:87
at System.Web.HttpApplication/<RunHooks>c__Iterator5.MoveNext () [0x001aa] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.Web/System.Web/HttpApplication.cs:1050
at System.Web.HttpApplication/<Pipeline>c__Iterator6.MoveNext () [0x006d3] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.Web/System.Web/HttpApplication.cs:1259
at System.Web.HttpApplication.Tick () [0x00000] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.Web/System.Web/HttpApplication.cs:932
Version information: Mono Runtime Version: 2.10.2 (tarball Mon Apr 18 19:06:50 UTC 2011); ASP.NET Version: 4.0.30319.1
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-12-20 07:24:32

另一个问题使我得到了这个问题的答案:missingmethodexception-w-mono

事实证明,MefContrib默认设置为使用DirectoryCatalog,这在Mono上是不起作用的(因为它试图在没有的dlls中查找导出-这在Windows中是可以的)。

如果您将应用程序的Start()方法中的MvcApplicationRegistry替换为您自己的自定义dlls (而不是扫描整个bin),那么一切都很顺利。

Start()方法:

代码语言:javascript
复制
var catalog = new AggregateCatalog(
            new AssemblyCatalog(Assembly.GetAssembly(typeof(MyClass))),
            new ConventionCatalog(new MyMvcApplicationRegistry())); 

MvcApplicationRegistry:

代码语言:javascript
复制
public class MyMvcApplicationRegistry : PartRegistry
      {
        public MyMvcApplicationRegistry()
        {
            Scan(x => x.Assembly(Assembly.GetExecutingAssembly()));

            Part()
                .ForTypesAssignableFrom<IController>()
                .MakeNonShared()
                .AddMetadata(new PartCreationScopeAttribute(PartCreationScope.Default))
                .ExportAs<IController>()
                .Export()
                .Imports(x =>
                {
                    x.Import().Members(
                        m => new[] { m.GetConstructors().FirstOrDefault(c => c.GetCustomAttributes(typeof(ImportingConstructorAttribute), false).Length > 0) ?? m.GetGreediestConstructor() });
                    x.Import().Members(
                        m => m.GetMembers().Where(mbr => mbr.GetCustomAttributes(typeof(ImportAttribute), false).Length > 0).ToArray());
                });
        }
      }
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8562133

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档