0

尝试实现同行的代码时出现以下错误:

无法加载一种或多种请求的类型。检索 LoaderExceptions 属性以获取更多信息。

我看到有一篇关于如何“如何检索 LoaderException 属性?”的帖子。这里(如何检索 LoaderException 属性?

但是,我不明白这个 try catch 应该去哪里,因为实现我的对等代码的代码在 Global.asax.cs 文件中。(见下文)

任何帮助将不胜感激,如果您对我投反对票,请解释原因。

namespace IMS_STS_Example_SIT
{
 // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
 // visit http://go.microsoft.com/?LinkId=9394801

 public class MvcApplication : StsMvcHttpApplication
 {
    protected override void OnApplicationStarted()
    {
        base.OnApplicationStarted();

        AreaRegistration.RegisterAllAreas();

        WebApiConfig.Register(GlobalConfiguration.Configuration);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);

    }
 }
}

以下是来自 UI 的完整错误消息:

[ReflectionTypeLoadException:无法加载一种或多种请求的类型。检索 LoaderExceptions 属性以获取更多信息。] MyCompNameIT.Common.Utils.Installer.ConfigInstaller.Install(IWindsorContainer container, IConfigurationStore store) 在 C:\MyCompNameProjects\PrideLands\Common\Main\Source\MyCompNameIT.Common\MyCompNameIT.Common.Utils \Installer\ConfigInstaller.cs:80 Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] 安装程序,DefaultComponentInstaller 范围)+200 Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] 安装程序)+144 MyCompNameIT.Common.Utils.InstallerExtension.WithMyCompNameDefaults (IWindsorContainer 容器)在 C:\MyCompNameProjects\PrideLands\Common\Main\Source\MyCompNameIT.Common\MyCompNameIT.Common.Utils\InstallerExtension.cs:52 MyCompNameIT.Common.Web.InstallerExtension。

[TypeInitializationException:'MyCompNameIT.Common.Web.MvcHttpApplication' 的类型初始化程序引发异常。] MyCompNameIT.Common.Web.MvcHttpApplication..ctor() +0 IMS_STS_Example_SIT.MvcApplication..ctor() +40 ASP.global_asax.. c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\ims_sts_example_sit\2c6588da\447046b5\App_global.asax.lkasnsc6.0.cs:0 中的 ctor()

[TargetInvocationException: 调用目标抛出异常。] System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +159 System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +256 System.Activator.CreateInstance(Type type, Boolean nonPublic) +127 System.RuntimeType.CreateInstanceImpl (BindingFlags bindingAttr、Binder binder、Object[] args、CultureInfo 文化、Object[] activationAttributes、StackCrawlMark 和 stackMark)+14429965 System.Activator。CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfoculture, Object[] activationAttributes) +200 System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfoculture) + 28 System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +83 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +312 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475Object[] args) +83 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +312 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475Object[] args) +83 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +312 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475

[HttpException (0x80004005): 调用目标抛出异常。] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881108 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime。 ProcessRequestNotificationPrivate(IIS7WorkerRequest WR,HttpContext 上下文)+12722297

4

1 回答 1

0

替换StsMvcHttpApplicationMvcHttpApplication或确保您引用 StsMvcHttpApplication 程序集及其所有依赖项

于 2013-10-02T16:20:35.220 回答