2

我从 Cassette 2.0.0 升级到最新版本,但出现以下异常:

[NullReferenceException: Object reference not set to an instance of an object.]
   System.Lazy`1.get_Value() +10785860
   Cassette.Aspnet.IsolatedStorageContainer.get_IsolatedStorageFile() +27
   Cassette.Aspnet.WebHostSettingsConfiguration.<GetCacheDirectory>b__0() +5
   Cassette.IO.IsolatedStorageFile.get_Storage() +10
   Cassette.IO.IsolatedStorageFile.get_Exists() +13
   Cassette.Aspnet.WebHostSettingsConfiguration.IsStaticCacheManifest(CassetteSettings settings) +48
   Cassette.Aspnet.WebHostSettingsConfiguration.Configure(CassetteSettings settings) +219
   Cassette.ConfigurationEnumerableExtensions.Configure(IEnumerable`1 configurations, T configurable) +151
   Cassette.CassetteSettings..ctor(IEnumerable`1 configurations) +33

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +190
   Cassette.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) +607

[TinyIoCResolutionException: Unable to resolve type: Cassette.CassetteSettings]
   Cassette.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) +642
   Cassette.TinyIoC.SingletonFactory.GetObject(Type requestedType, TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options) +103
   Cassette.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options) +85
   Cassette.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) +361

[TinyIoCResolutionException: Unable to resolve type: Cassette.BundleCollection]
   Cassette.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) +482
   Cassette.TinyIoC.SingletonFactory.GetObject(Type requestedType, TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options) +103
   Cassette.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options) +85
   Cassette.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) +361

[TinyIoCResolutionException: Unable to resolve type: Cassette.Views.BundlesHelper]
   Cassette.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) +482
   Cassette.TinyIoC.SingletonFactory.GetObject(Type requestedType, TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options) +103
   Cassette.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options) +85
   Cassette.TinyIoC.TinyIoCContainer.<ResolveAllInternal>b__44(TypeRegistration registration) +32
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +145
   System.Linq.<CastIterator>d__b1`1.MoveNext() +85
   Cassette.HostBase.RunStartUpTasks() +65
   Cassette.HostBase.Initialize() +147
   Cassette.Aspnet.CassetteHttpModule.InitWithoutTraceLogging() +34
   Cassette.Aspnet.CassetteHttpModule.InitWithTraceLogging() +137
   Cassette.Aspnet.CassetteHttpModule.Init(HttpApplication httpApplication) +121
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +418
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): Unable to resolve type: Cassette.Views.BundlesHelper]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9874568
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

我尝试用谷歌搜索,但我找不到任何东西。有任何想法吗?

当我创建一个新的空 MVC 项目并安装最新版本的 Cassette-Aspnet 时,也会发生这种情况。这是我的网络配置:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <section name="cassette" type="Cassette.CassetteConfigurationSection, Cassette" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <httpRuntime targetFramework="4.5" />
    <compilation debug="true" targetFramework="4.5" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
        <add namespace="Cassette.Views" />
      </namespaces>
    </pages>
    <httpModules>
      <add name="CassetteHttpModule" type="Cassette.Aspnet.CassetteHttpModule, Cassette.Aspnet" />
    </httpModules>
    <httpHandlers>
      <add path="cassette.axd" verb="*" type="Cassette.Aspnet.CassetteHttpHandler, Cassette.Aspnet" />
    </httpHandlers>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
      <add name="CassetteHttpHandler" path="cassette.axd" preCondition="integratedMode" verb="*" allowPathInfo="true" type="Cassette.Aspnet.CassetteHttpHandler, Cassette.Aspnet" />
    </handlers>
    <modules>
      <add name="CassetteHttpModule" type="Cassette.Aspnet.CassetteHttpModule, Cassette.Aspnet" />
    </modules>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="AjaxMin" publicKeyToken="21ef50ce11b5d80f" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.84.4790.14405" newVersion="4.84.4790.14405" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <cassette />
</configuration>

我在本地 IIS 和真正的 IIS 中都进行了尝试。

4

2 回答 2

3

我刚刚通过 Nuget 从 Cassette 2.0 升级到 Cassette 2.3,并在应用程序启动时遇到了完全相同的异常。事实证明,当前 Nuget 包的目标是 .NET 4.0 客户端配置文件,而不是针对 Cassette.dll 的普通 .NET 4.0,因此 Nuget 创建了对导致此异常的 .NET 3.5 版本的 DLL 的引用。

我不得不在我的项目文件..\packages\Cassette.2.3.0\lib\net35\Cassette.dll中手动更新 Cassette 引用的路径。..\packages\Cassette.2.3.0\lib\net40-client\Cassette.dll

于 2013-11-01T01:10:31.567 回答
1

最后我设法修复它。我没有从 Nuget 下载 Cassette.Aspnet,而是从他们的 GitHub 存储库下载了 Cassette、Cassette.Aspnet 和 Cassette.Views,并将其添加到解决方案中,并且它工作正常。

于 2013-08-26T11:29:33.870 回答