This project has moved. For the latest updates, please go here.

NullReferenceException in MsieJsEngine..ctor

Jan 25, 2014 at 4:59 PM
I'm trying to configure an MVC4 project to bundle LESS files using the MsieJsEngine, and am getting an exception when referencing the bundle at runtime. I have successfully set up a previous project, and can't spot any significant differences between that one and this one.

The stack trace is:
Server Error in '/' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[NullReferenceException: Object reference not set to an instance of an object.]
   JavaScriptEngineSwitcher.Msie.MsieJsEngine..ctor(MsieConfiguration msieConfig) +71
   JavaScriptEngineSwitcher.Msie.MsieJsEngine..ctor() +71

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   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) +113
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +83
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1136
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +128
   System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +55
   System.Reflection.Assembly.CreateInstance(String typeName) +22
   JavaScriptEngineSwitcher.Core.Utilities.Utils.CreateInstanceByFullTypeName(String fullTypeName) +539
   JavaScriptEngineSwitcher.Core.JsEngineSwitcher.CreateJsEngineInstance(String name) +151
   BundleTransformer.Less.Translators.<>c__DisplayClass1.<.ctor>b__0() +56
   BundleTransformer.Less.Compilers.LessCompiler..ctor(Func`1 createJsEngineInstance, CompilationOptions defaultOptions) +103
   BundleTransformer.Less.Translators.LessTranslator.Translate(IList`1 assets) +464
   BundleTransformer.Core.Transformers.TransformerBase.Translate(IList`1 assets, Boolean isDebugMode) +131
   BundleTransformer.Core.Transformers.CssTransformer.Transform(IList`1 assets, BundleResponse bundleResponse, VirtualPathProvider virtualPathProvider, HttpContextBase httpContext, Boolean isDebugMode) +149
   BundleTransformer.Core.Transformers.TransformerBase.Process(BundleContext context, BundleResponse response, Boolean isDebugMode) +574
   BundleTransformer.Core.Transformers.TransformerBase.Process(BundleContext context, BundleResponse response) +97
   System.Web.Optimization.Bundle.ApplyTransforms(BundleContext context, String bundleContent, IEnumerable`1 bundleFiles) +263
   System.Web.Optimization.Bundle.GenerateBundleResponse(BundleContext context) +355
   System.Web.Optimization.Bundle.GetBundleResponse(BundleContext context) +104
   System.Web.Optimization.Bundle.ProcessRequest(BundleContext context) +132
   System.Web.Optimization.BundleHandler.ProcessRequest(HttpContext context) +234
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +1132
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +114
My web.config is here: http://pastebin.com/AmtwHMvF

What am I doing wrong?
Coordinator
Jan 25, 2014 at 5:10 PM
Hello, Colonel32!

Try to reinstall a JavaScriptEngineSwitcher.Msie package or manually add to Web.config file the following code:
<configuration>
    <configSections>
        <sectionGroup name="jsEngineSwitcher">
            ...
            <section name="msie" type="JavaScriptEngineSwitcher.Msie.Configuration.MsieConfiguration, JavaScriptEngineSwitcher.Msie" />
            ...
        </sectionGroup>
    </configSections>
</configuration>
Jan 25, 2014 at 5:18 PM
Ah yes, now everything works!

Very very quick answer, thank you Taritsyn :)