tags:

views:

104

answers:

7

I`m a new guy to c# and I try to add a some code to a certain class in my c# project in order to remove some characters from a string. These lines of codes are not executed at run time and the debugger steps over it.So,

1) How to make the new lines added to an existing project execute?

2) Is there a property in Visual studio 2005 that prevents developers from changing existing code?

3) Is it some Property related to the c# project that specifies a privilege of code change?

+1  A: 

you should try cleaning your project and rebuilding it, sometimes visual studio is stupid and does not rebuild all the assemblies. i find that this fixes this problem about 80% of the time (if it's not my code, that is)

Muad'Dib
How to clean a C# project and there is not tool under Build Menu to do so?
Davideg
Right-click on the project (or the solution file) in the Solution Explorer. There should be a "clean" option there.
Anna Lear
you can use that tool, or you can use the OS to delete the obj and bin folders. deleting these folders is more aggressive, and should only be done AFTER trying the built-in tool. also, there are powershell scripts around the interwebs that can be used.
Muad'Dib
+1  A: 

1) Just rebuild entire solution

2) No, as far as I know

3) No, as far as I know

DixonD
A: 

Check to make sure you are not returning the a value before the added lines. If you hit a return prior to getting to those new lines that will exit the function and your new code will never execute.

antonlavey
This is not happening. I make changes on any existing code, but the changes is not executed at runtime. That`s it my friend.
Davideg
try this: Copy your bin folder to another location and then delete the contents of it. then rebuild your project. Check the bin folder to make sure all your components were compiled and then run the debugger and see what happens. If the build fails your bin folder will not have all your dll's. Oh an restarting the computer never hurt either (=.
antonlavey
A: 

Since you mentioned string, are you assigning the output back to the variable?

E.g.

string aStr = "   abcdefg   ";
aStr = aStr.Trim();

If you only do aStr.Trim(), you won't see the "update".

Cambium
I have my code like this:string sMailMsg = eMailMsg.ToString();I change it to:string sMailMsg = eMailMsg.ToString().Replace("\0", string.Empty);
Davideg
Why don't you use the debugger and tell us what the old value (i.e. eMailMsg.ToString() ) is?
Cambium
The old value of eMailMsg.ToString() is: \r\nTest\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\r\n"
Davideg
A: 

Thanks Guys for your quick response. To be more clear. C# environemenT IS: Microsoft Visual C#.Net 2003

Rebuild All Solution is not exist under Build Menu, There are only 'Build Solution' & 'Rebuild Solution'.

Davideg
This needs to be edited into your original question.
Jay Riggs
Try clean, and then build
Cambium
How to clean a solution in such an environement where there is no Clean tool under any menu?
Davideg
Try renaming the bin folder, as antonlavey suggested. That way a whole new set of binaries will be created.
Jivlain
A: 
Jivlain
The sintex of the code is not my problem. my problem is that. Any change to my code is not executed at runtime.
Davideg
A: 

Hey David, can you post the output after you built your program? You can copy the content from the Output window.

HJ