我如何清理Visual Studio 2012中的临时文件? [英] How I can clean the temporary Files in Visual Studio 2012?

查看:304
本文介绍了我如何清理Visual Studio 2012中的临时文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何清理Visual Studio 2012中的临时文件以及如何在我的项目WebForms中找到NullReferenceException?

How I can clean the temporary Files in Visual Studio 2012 and how I can locate NullReferenceException in my project WebForms?

推荐答案

你有两个问题。



Q1:如何清除VS 2012中的%tmp%文件夹?



答案:VS 2012没有您可以删除的临时文件。你可能有一些是由你的程序创建的,但那可能是在VB.Net或C#中。你还没告诉我们哪个。无论哪种方式,你都不应该。



%tmp%文件夹的重点是文件只在需要时才存在。一旦使用该文件的var超出范围,那么GC将在下一次传递时为您清理它。



为什么要问?你有临时文件的问题吗?



Q2:我如何找到NullReferenceException?

应该有一个堆栈跟踪错误。这应该告诉您异常发生的位置,但它不会告诉您哪个项目为null。通常这很明显,但有时候会更加模糊。我建议你使用堆栈轨道找到可能的空候选者并添加一些错误检查。



例如:



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#

//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.


这篇关于我如何清理Visual Studio 2012中的临时文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆