Reputation: 68
I'm getting this error:
Could not copy the file "obj\x86\Debug\TitleGenerator.exe" because it was not found.
When I try to compile, but it doesn't make any sense. The only thing I changed was to add the following lines of code to help me debug an issue:
#if DEBUG
if( title.Culture == null || title.Religion == null )
{
}
#endif
If I remove those lines, it compiles with no issue. If I change the if statement to if ( true ) {}
it compiles fine.
Restarting Visual Studio doesn't help. I've also tried restarting my PC. As far as I can tell, the .Net framework, and Visual Studio are both up to date.
I'm using Visual Studio 2012, a target framework of 3.5, with the Default language level, CSS version 3.0
[Edit] It's now started working again. All I did was to remove output of title.TitleID from the output to the log.
Meaning I changed things like Log( " --Title in Ignore List: " + title.TitleID );
to Log( " --Title in Ignore List" );
The contents of title
are decided during runtime, and it's the object of a foreach
loop over a list.
Even more strangely, if I add this class to the project:
public class DebugBreak
{
[Conditional("DEBUG")]
public static void TitleIDBreak( Title title, string id )
{
if ( title.TitleID == id )
System.Diagnostics.Debugger.Break();
}
}
But don't even do anything with it, then it works. I don't even have to call the method. Just changing the build action of the file from None to Compile makes it work.
Upvotes: 1
Views: 3116
Reputation: 166
This is commonly caused by Avast.
If you are running that antivirus, add an exclusion for your project folder.
I've searched for this several times in the past. Its a file access issue, so it may not be your code at all.
Upvotes: 1
Reputation: 13972
There's nothing wrong with the code you have written based purely on what you've posted.
One thing you can try is to use a Conditional attribute for your debugging. Something like:
[Conditional("DEBUG")]
static void TitleCheck(Title title)
{
if( title.Culture == null || title.Religion == null )
{
System.Diagnostics.Debugger.Break();
}
}
private void MyProductionFunction(Title title)
{
// Do some stuff
TitleCheck(title); //<< This function call will be omitted completely if 'debug' conditional isn't met.
// Do more stuff
}
Upvotes: 0
Reputation: 70523
What type is title? Is it even defined? Statements are checked for semantics even if DEBUG is not defined.
I'm guessing your code is not compiling.
C# does not use a "pre-processor" like early C compilers where the file was changed before the compiler even saw it.
Upvotes: 0