Click here to Skip to main content
16,020,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How I can clean the temporary Files in Visual Studio 2012 and how I can locate NullReferenceException in my project WebForms?
Posted

1 solution

you have two questions.

Q1: How do I clear the %tmp% folder in VS 2012?

Answer: VS 2012 has no temporary files that you can delete. You might have some being created by your program but that would be in VB.Net or C#. You have not told us which. Either way, you shouldn't.

The point of the %tmp% folder is that the files will only exist as long as they need to. As soon as the var that uses the file goes out-of-scope, then the GC will clean it up for you on the next pass.

Why do you ask? Are you having problems with temp files?

Q2: How do I locate a NullReferenceException?
There should be a Stack Trace with the error. This should tell you where the exception occurred, but it does not tell you what item was null. Usually it's obvious but sometimes it a little more obscure. I suggest you use the stack-track to locate the likely null candidate and add some error checking beforhand.

For example:

C#
//C#

//instead of
return somemethod().ToString();

//handle the error before it can occur
var myvar = somemethod();
if(myvar==null)
  return null;
return myvar.ToString();


This is how I handle any possible null value.
 
Share this answer
 
Comments
Member 11765235 15-Jun-15 6:29am    
this is the stack trace of my error:

[NullReferenceException: Object reference not set to an instance of an object.]
DBAccess.setConnString() +77
DBAccess..ctor() +140
_Default..ctor() +49
ASP.default_aspx..ctor() in c:\Users\DELL\AppData\Local\Temp\Temporary ASP.NET Files\root\7b316ac0\74a3eae4\App_Web_default.aspx.cdcab7d2.rcv9xm8p.0.cs:0
__ASP.FastObjectFactory_app_web_default_aspx_cdcab7d2_rcv9xm8p.Create_ASP_default_aspx() in c:\Users\DELL\AppData\Local\Temp\Temporary ASP.NET Files\root\7b316ac0\74a3eae4\App_Web_default.aspx.cdcab7d2.rcv9xm8p.1.cs:0
System.Web.Compilation.BuildResultCompiledType.CreateInstance() +30
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) +100
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +31
System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path) +37
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +346
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Andy Lanng 15-Jun-15 6:32am    
ok - your error is in DBAccess.setConnString() (line 77)

Post that line and I'll see if I can tell what the error is

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900