尝试从同行实现代码时出现以下错误:
无法加载一个或多个请求的类型。检索LoaderExceptions属性以获取更多信息。
我看到有关如何“如何检索LoaderException属性?”的帖子。这里(How to retrieve the LoaderException property?)
但是,我不明白这个try catch应该去哪里,因为实现我的peer代码的代码在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容器,IConfigurationStore商店)位于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 C:\ MyCompNameProjects \ PrideLands \ Common \ Main \ Source \ MyCompNameIT.Common \ MyCompNameIT.Common.Utils \ InstallerExtension.cs中的MyCompNameIT.Common.Utils.InstallerExtension.WithMyCompNameDefaults(IWindsorContainer容器):52 C:\ MyCompNameProjects \ PrideLands \ Common \ Main \ Source \ MyCompNameIT.Common \ MyCompNameIT.Common.Web \ InstallerExtension.cs中的MyCompNameIT.Common.Web.InstallerExtension.WithMyCompNameWebMvc(IWindsorContainer容器):20 MyCompNameIT.Common.Web.MvcHttpApplication..cctor()在C:\ MyCompNameProjects \ PrideLands \ Common \ Main \ Source \ MyCompNameIT.Common \ MyCompNameIT.Common.Web \ IocHttpApplication.cs:30
[TypeInitializationException:'MyCompNameIT.Common.Web.MvcHttpApplication'的类型初始值设定项引发异常。] MyCompNameIT.Common.Web.MvcHttpApplication..ctor()+ 0 IMS_STS_Example_SIT.MvcApplication..ctor()+ 40 ASP.global_asax..ctor()在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
[TargetInvocationException:调用目标抛出了异常。] System.RuntimeTypeHandle.CreateInstance(RuntimeType类型,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 culture,Object [] activationAttributes,StackCrawlMark& stackMark)+14429965 System.Activator.CreateInstance(Type type,BindingFlags bindingAttr,Binder binder,Object [] args,CultureInfo culture,Object [] activationAttributes)+200 System.Activator.CreateInstance(Type type,BindingFlags bindingAttr,Binder binder,Object [] args,CultureInfo culture)+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)+475
[HttpException(0x80004005):调用目标抛出了异常。] System.Web.HttpRuntime.FirstRequestInit(HttpContext context)+12881108 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)+159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext context)+12722297
答案 0 :(得分:0)
将StsMvcHttpApplication
替换为MvcHttpApplication
,或确保您引用的是St Mvc HttpApplication程序集及其所有依赖项