日期:2014-05-18  浏览次数:21184 次

控制台程序不能生成,提示说一个.tmp文件不是有效的资源文件,大家帮帮我啊。
刚刚学习C#,昨天碰到一个问题,下面的这段代码应该没有问题吧(就是应该肯定在语法,拼写没问题,能生成的),但是昨天晚上第一次生成时就没有成功,提示:C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\ConsoleApplication1\ConsoleApplication1\obj\Debug\CSC17.tmp 不是有效的Win32资源文件,然后我重新生成,还是这个问题,不过CSC17.tmp名字就变了,但都是.tmp文件。网上找了一圈没找到答案。今天早上还是这个程序,原封不动,就生成成功了,这是什么问题啊,还请高手帮我解答一下,新手一共有100积分,我全放上了呵呵。





using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
  class Program
  {
  enum orientation : byte
  {
  north = 1,
  south = 2,
  east = 3,
  west = 4
  }
  static void Main(string[] args)
  {
  orientation myDirection;
  byte myByte;
  for (byte i = 1; i < 6; i++)
  {
  myByte = i;
  try
  {
  Console.WriteLine("Converting myByte:{0} to myDirection.", i);
  myDirection = checked((orientation)myByte);
  Console.WriteLine("Successful Conversion,myDirection is {0}", myDirection);
  }
  catch 
  {
  Console.WriteLine("This conversion is not allowed.");
  }
  finally
  {
  Console.WriteLine();
  }
  }
  }
  }
}


------解决方案--------------------
代码本身是没有问题的,有可能你在运行程序时又再次重新生成了,所以会导致临时文件的破坏,这时候只要删除临时文件再生成一次一般就可以了.
------解决方案--------------------
try to modify userName in <processModel> in machine.config to "SYSTEM"

or give ASPNET permssions to read/write C:\WINDOWS\TEMP\

or if there is anti-virus program running on the server, disable it
------解决方案--------------------
有些时候vs 就会出现这些问题,  解决办法 重新打开vs 就可以了