Monday, March 26, 2012

ASP.net AJAX and precompilation

I often will precompile an application so that I can get better performance on my production servers. However when I mix it with AJAX, it goes bad.

I run from a VS.net Command Window:

aspnet_compiler -p "C:\documents and settings\mandreko\my documents\visual studio 2005\websites\ajax_maillist" -v /maillist c:\maillist

I then copy the c:\maillist to my websiteroot/maillist and get this error:

Server Error in '/maillist' Application.

Object reference not set to an instance of an object.

Description:Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror 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 thecurrent web request. Information regarding the origin and location ofthe exception can be identified using the exception stack trace below.


Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.Script.Services.WebServiceData.GetWebServiceData(HttpContext context, String virtualPath, Boolean failIfNoData, Boolean pageMethods) +368
System.Web.Script.Services.PageClientProxyGenerator.GetClientProxyScript(HttpContext context, IPage page, Boolean debug) +46
System.Web.UI.ScriptManager.RegisterServices() +748
System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e) +242
System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +2012740
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1566

If I run the non-precompiled version of the code, it works perfectly on my production server, however when trying to precompile it, it causes this. Any ideas on this? Are they not compatible? Am I missing something?

Hi,

I'm still learning about AJAX, but it could be that your problem is do to the way caching is handled in each instance. Perhaps the precompiled version is using cached data, while the on-demand model is getting fresh data. I do know that caching is a concern for AJAX enabled applications, and that just turning cahing off is not a workable solution.

For a pretty good run down on how the two development models (Websites, and Web Application Projects), handle compilation, take a look at this learning video from the Learn tab here at asp.net:http://asp.net/learn/videos/view.aspx?tabid=63&id=16 This vid covers the WAP add-in (which is no longer needed as an add in after you do the VS 2005 SP1 install). Towards the end there's a good slide showing compilation choices and paths.

Hope it helps BRN..


Actually after searching some more, I found it. Looks like it's a known problem:

http://forums.asp.net/thread/1499979.aspx

At least now I know I'm not crazy.


Hi,

Glad you found out what was causing the issue - hope the thread provided a solution or work around. BTW, did you do the VS 2005 SP1 install yet? I was wondering if that would address the problem you ran across.

So, you think one problem explained proves you're not crazy? Hummm. Let's hope your right! As an admitted lunatic, I wouldn't worry about it in any event. BRN..


VS 2005 SP1 didn't fix anything unfortunately. I did have that.

It matches my problem description, and even got ScottGu posting about it, so I'm confident they'll have it fixed in the next release.

No comments:

Post a Comment