Taritsyn / BundleTransformer

Bundle Transformer - a modular extension for System.Web.Optimization (also known as the Microsoft ASP.NET Web Optimization Framework).
Apache License 2.0
130 stars 19 forks source link

TargetInvocationException when using MicrosoftAjaxJsMinifier Module #50

Closed RykerMunn closed 3 years ago

RykerMunn commented 3 years ago

Hello,

I've been battling this for a few hours now, and after finally thinking to check the Windows event viewer I determined the source of the problem.

When using the AjaxJsMinfier to minify the JS bundles in my project, I was being met with 404s from all of the bundles. I wasn't entirely sure what the initial problem was, but after consulting the Event Viewer I have determined the issue seems to be coming out of a dependency mismatch.

I am currently using BundleTransformerCore v1.10.0 with BundleTransformer.MicrosoftAjax v1.10.0. I have copied the sample JS and CSS configurations from the samples on this repo.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'AjaxMin, Version=5.14.5506.26196, Culture=neutral, PublicKeyToken=21ef50ce11b5d80f' or one of its dependencies. The system cannot find the file specified.
   at BundleTransformer.MicrosoftAjax.Minifiers.MicrosoftAjaxJsMinifier..ctor(MicrosoftAjaxSettings microsoftAjaxConfig)
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at BundleTransformer.Core.Utilities.Utils.CreateInstanceByFullTypeName[T](String fullTypeName)
   at BundleTransformer.Core.Assets.AssetContextBase.GetMinifierInstance(String minifierName)
   at BundleTransformer.Core.Transformers.ScriptTransformer..ctor(IMinifier minifier, IList`1 translators, IList`1 postProcessors, String[] ignorePatterns, CoreSettings coreConfig)
   at BundleTransformer.Core.Transformers.ScriptTransformer..ctor()
   at Gateway.Helpers.BundleConfig.RegisterBundles(BundleCollection bundles) in C:\work\git\UserOnboarding\UserOnboarding\xera\Gateway\Gateway\Helpers\BundleConfig.cs:line 21
   at Gateway.MvcApplication.Application_Start() in C:\work\git\UserOnboarding\UserOnboarding\xera\Gateway\Gateway\Global.asax.cs:line 83

Specifically, it looks like the AjaxJsMinifier is trying to use a version of Ajax Min, that as far as I can tell, has never existed (at least publicly). I'm 99% certain this is likely a configuration issue on my end, and not something wrong with the NuGet package itself.

All bundles are configured as follows:


var bundleJS = new CustomScriptBundle("~/bundles/bundleExampleJS");
bundleJS.Include"(~/Scripts/subfolder/foo.js");
bundleJS.Orderer = nullOrderer; // defined as `var nullOrderer = new NullOrderer()` 
bundles.Add(bundleJS); 

Thank you for any assistance on this.

RykerMunn commented 3 years ago

I was able to resolve this by completely uninstalling AjaxMin and installing the Ajax minifier module again My best guess is something else in the project also has AjaxMin as a dependency and that was the source of my issue.

Thanks!