Visual studio 2013 为什么这个Typescript接口在运行时绑定中导致空异常?
我在VS2013中启动了一个新的MVC Razor测试web项目。今天,我将所有NuGet软件包更新为最新版本,并开始包括来自另一个项目的TypeScript插件进行测试。其中一个插件导致此运行时错误: 堆栈跟踪出错: reorder.ts 母版页_LayoutHome.cshtml: 基本上,构建JS输出/捆绑包的代码似乎在使用函数声明我的接口时崩溃,但我找不到一个模式 完整的插件在以前的web应用程序中运行良好,因此我怀疑其中一个NuGet/VS工具已经更改。Visual studio 2013 为什么这个Typescript接口在运行时绑定中导致空异常?,visual-studio-2013,nuget,typescript,bundling-and-minification,Visual Studio 2013,Nuget,Typescript,Bundling And Minification,我在VS2013中启动了一个新的MVC Razor测试web项目。今天,我将所有NuGet软件包更新为最新版本,并开始包括来自另一个项目的TypeScript插件进行测试。其中一个插件导致此运行时错误: 堆栈跟踪出错: reorder.ts 母版页_LayoutHome.cshtml: 基本上,构建JS输出/捆绑包的代码似乎在使用函数声明我的接口时崩溃,但我找不到一个模式 完整的插件在以前的web应用程序中运行良好,因此我怀疑其中一个NuGet/VS工具已经更改。reorder.js输出文件显然
reorder.js
输出文件显然是空的,因此看起来可能是TypeScript解析
我希望堆栈跟踪(上图)和日志(下图)能提供线索。我希望这是我在声明中明显遗漏或做错的事情
输出日志(由于SO大小限制的最后一部分):
答:确保您始终引用.js文件(而不是.ts)!
希望这个问题和答案对其他犯了我犯过的同样愚蠢错误并得到同样无用错误信息的人有用
我无意中引用了.ts
文件,而不是捆绑包中的.js
文件。。。只需要一个插件(坏掉的那个)。我所有的改变都没有解决现在显而易见的问题
哦!:)
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:
Line 39: @Scripts.Render("~/bundles/jquery")
Line 40: @Scripts.Render("~/bundles/bootstrap")
Line 41: @Scripts.Render("~/bundles/ListView")
Line 42: @RenderSection("scripts", required: false)
Line 43: </body>
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.Ajax.Utilities.JSParser.ParseUnaryExpression(Boolean& isLeftHandSideExpr, Boolean isMinus) +298
Microsoft.Ajax.Utilities.JSParser.ParseExpressionStatement(Boolean fSourceElement) +125
Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean fSourceElement, Boolean skipImportantComment) +1552
Microsoft.Ajax.Utilities.JSParser.ParseBlock() +164
Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean fSourceElement, Boolean skipImportantComment) +498
Microsoft.Ajax.Utilities.JSParser.ParseLabeledStatement(Lookup lookup, Boolean fSourceElement) +543
Microsoft.Ajax.Utilities.JSParser.ParseExpressionStatement(Boolean fSourceElement) +226
Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean fSourceElement, Boolean skipImportantComment) +1552
Microsoft.Ajax.Utilities.JSParser.ParseBlock() +164
Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean fSourceElement, Boolean skipImportantComment) +498
Microsoft.Ajax.Utilities.JSParser.ParseBlock() +164
Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean fSourceElement, Boolean skipImportantComment) +498
Microsoft.Ajax.Utilities.JSParser.ParseStatements(Block block) +159
Microsoft.Ajax.Utilities.JSParser.InternalParse() +1011
Microsoft.Ajax.Utilities.JSParser.Parse(DocumentContext sourceContext) +123
Microsoft.Ajax.Utilities.JSParser.Parse(DocumentContext sourceContext, CodeSettings settings) +54
Microsoft.Ajax.Utilities.Minifier.MinifyJavaScript(String source, CodeSettings codeSettings) +987
System.Web.Optimization.JsMinify.Process(BundleContext context, BundleResponse response) +310
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.BundleResolver.GetBundleContents(String virtualPath) +254
System.Web.Optimization.AssetManager.DeterminePathsToRender(IEnumerable`1 assets) +252
System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] paths) +75
System.Web.Optimization.Scripts.RenderFormat(String tagFormat, String[] paths) +292
System.Web.Optimization.Scripts.Render(String[] paths) +51
ASP._Page_views_shared__LayoutHome_cshtml.Execute() in e:\HiTechMagic\iCollectIt\iCollectIt.CloudServices\iCollectit.Collector.WebApplication\Views\Shared\_LayoutHome.cshtml:41
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +271
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +120
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +145
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer) +41
System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +335
System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +42
System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, HelperResult content) +45
System.Web.WebPages.WebPageBase.Write(HelperResult result) +53
System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +178
System.Web.WebPages.WebPageBase.PopContext() +347
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +154
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +695
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +382
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +431
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +39
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +116
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +106
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +321
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +185
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9688704
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
bundles.Add(new ScriptBundle("~/bundles/ListView").Include(
"~/Scripts/Vero/reorder.ts"));
module Plugins
{
export interface IReorderOptions
{
onChange: { (): void; }; // Function to call after update
}
}
<!DOCTYPE html>
<html>
[SNIP]
<body>
[SNIP]
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/bundles/ListView")
@RenderSection("scripts", required: false)
</body>
</html>
@{
ViewBag.Title = "Home Page";
Layout = "~/views/shared/_layoutHome.cshtml";
}
'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8d1fcf70\6d8beac0\App_Web_2rxc12vp.dll'.
'iisexpress.exe' (CLR v4.0.30319: /LM/W3SVC/44/ROOT-1-130403001817617541): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Dynamic\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Dynamic.dll'. Cannot find or open the PDB file.
A first chance exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in Microsoft.CSharp.dll
A first chance exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in Microsoft.CSharp.dll
'iisexpress.exe' (CLR v4.0.30319: /LM/W3SVC/44/ROOT-1-130403001817617541): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8d1fcf70\6d8beac0\App_Web_fivluysz.dll'.
A first chance exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in Microsoft.CSharp.dll
A first chance exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in Microsoft.CSharp.dll
A first chance exception of type 'System.NullReferenceException' occurred in WebGrease.dll
A first chance exception of type 'System.NullReferenceException' occurred in WebGrease.dll
A first chance exception of type 'System.NullReferenceException' occurred in System.Web.Mvc.dll
A first chance exception of type 'System.NullReferenceException' occurred in System.Web.Mvc.dll
'iexplore.exe' (Script): Loaded 'Script Code (Windows Internet Explorer)'.
The program '[6296] iexplore.exe' has exited with code 0 (0x0).
The program '[11616] iisexpress.exe' has exited with code 0 (0x0).