Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 08-02-2004, 03:02 AM   #1 (permalink)
Banned from being Banned
 
Location: Donkey
Anyone notice how .net still runs code after you hit "stop"?

(Sorry, worded the subject wrong... should be "the Visual Studio .net 2003 Debugger" instead of plain ol' ".net")

What's up with this?

Say you breakpoint a line and have some code underneath that inserts a few records into a table in a database.

Lines go somewhat like this:

init variables
open db connection
insert records
close db connection

If you breakpoint on the init variables part and step through the code and realize "oh, I just spotted an error in my code" and hit stop, all the code beyond that is still executed, or in this case, records will be inserted into the table.

Why does it do this? Isn't that potentially dangerous in the sense that even though you spotted the error and hit stop, your code will still follow through?

Basically it kinda sucks for me right now because I need to run this app and breakpoint it to see how data will look before going in, but in order to prevent it from actually executing the SP, I have to rename it on the server so when it's called, it errors out.
__________________
I love lamp.

Last edited by Stompy; 08-07-2004 at 10:22 AM..
Stompy is offline  
Old 08-03-2004, 02:00 AM   #2 (permalink)
Psycho
 
Location: I think my horns are coming out
I know for a fact that VB 6, nor VC++ 6 did not do that.

So I guess this is another testament to how badly .Net sucks. Why do you use .Net BTW?
__________________
Do not confuse altruism with kindness, good will or respect for the rights of others. These are not primaries, but consequences, which, in fact, altruism makes impossible. The irreducible primary of altruism, the basic absolute, is self-sacrifice - which means: self-immolation, self-abnegation, self-denial, self-destruction - which means: the self as a standard of evil, the selfless as a standard of the good.
The Phenomenon is offline  
Old 08-03-2004, 10:17 AM   #3 (permalink)
Banned from being Banned
 
Location: Donkey
How would that be a testament to how bad .net sucks? The Visual Studio Designer is making this error, not the framework.

I use .net because it's a great development platform and is better than anything I've used before (and I've used all of em, including java)
__________________
I love lamp.
Stompy is offline  
Old 08-05-2004, 06:37 AM   #4 (permalink)
Psycho
 
Location: the hills of aquafina.
Quote:
Originally posted by Stompy
What's up with this?

Say you breakpoint a line and have some code underneath that inserts a few records into a table in a database.

Lines go somewhat like this:

init variables
open db connection
insert records
close db connection

If you breakpoint on the init variables part and step through the code and realize "oh, I just spotted an error in my code" and hit stop, all the code beyond that is still executed, or in this case, records will be inserted into the table.

Why does it do this? Isn't that potentially dangerous in the sense that even though you spotted the error and hit stop, your code will still follow through?

Basically it kinda sucks for me right now because I need to run this app and breakpoint it to see how data will look before going in, but in order to prevent it from actually executing the SP, I have to rename it on the server so when it's called, it errors out.
I've been writing apps similar to what your describing for about a year now with VB.NET, and I've never experienced what you are describing. When I stop the exe, especially at a breakpoint, the code stops...nothing more, nothing less.
__________________
"The problem with quick and dirty, as some people have said, is that the dirty remains long after the quick has been forgotten" - Steve McConnell
cartmen34 is offline  
Old 08-05-2004, 01:11 PM   #5 (permalink)
Crazy
 
I've been working with the .NET framework since it was in beta (off and on) and I've never seen that in VS 2K2 or 2K3. Are you sure you are stopping the code? If it's really a problem you can just comment out the line that does the DB insert while you are debugging.
twister002 is offline  
Old 08-05-2004, 01:21 PM   #6 (permalink)
Banned from being Banned
 
Location: Donkey
I'll make a quick example once I have a few extra minutes to do so.

I'm surprised no one else has experienced this. The other programmers I work with have also experienced this.
__________________
I love lamp.
Stompy is offline  
Old 08-06-2004, 03:22 AM   #7 (permalink)
Upright
 
I assumed garbage collection would run after you stopped your code, but for your code to keep executing after you hit stop just doesnt make sense.

Are you sure your stopping where you think your stopping? Place a break point near the start of execution and step through your code to make sure you are where you think you are.
hex1848 is offline  
Old 08-06-2004, 06:25 AM   #8 (permalink)
Banned from being Banned
 
Location: Donkey
Load up a new asp.net project.

Add a button to the default webform and add the following code to the click event (don't forget to include "using System.Data.SqlClient;" at the top):

Code:
		private void Button1_Click(object sender, System.EventArgs e)
		{
			SqlConnection conn = new SqlConnection("server=127.0.0.1;uid=sa;pwd=mypass;database=Northwind");
			SqlCommand cmd = new SqlCommand("INSERT INTO	dbo.Categories (CategoryName) VALUES (@CategoryName)", conn);
			
			cmd.CommandType = CommandType.Text;

			cmd.Parameters.Add(new SqlParameter("@CategoryName", SqlDbType.NVarChar, 15));
			cmd.Parameters["@CategoryName"].Value = "test";

			conn.Open();
			cmd.ExecuteNonQuery();

			cmd.Dispose();
			conn.Dispose();
		}
Breakpoint the line "cmd.ExecuteNonQuery();"

When the debugger reaches that point, hit stop. Look in your northwind database and you will see a category called "test". Even if you breakpoint on conn.Open(), the category is added.

This does it on all of my development machines (4), so I don't think it's a botched install.

[edit]
I just tried this in a plain old windows forms application and there is no bug, so perhaps it's an error in the asp.net worker process.
__________________
I love lamp.

Last edited by Stompy; 08-06-2004 at 06:32 AM..
Stompy is offline  
Old 08-07-2004, 08:52 AM   #9 (permalink)
Crazy
 
What happens if you comment out the line "cmd.ExecuteNonQuery();"

Have you put a trace on the database using SQL profiler and see what code is being sent?
twister002 is offline  
Old 08-07-2004, 10:21 AM   #10 (permalink)
Banned from being Banned
 
Location: Donkey
Quote:
Originally posted by twister002
What happens if you comment out the line "cmd.ExecuteNonQuery();"

Have you put a trace on the database using SQL profiler and see what code is being sent?
If you comment it out, nothing will happen, of course, since that's the statement that actually executes the SQL code. I mean, you won't see proof of code still executing unless you check connection logs to see that the db connection was in fact opened, but code is still being executed regardless.

And I'm not sure about what you're asking regarding the trace... the same exact code is being sent as if you were to execute the click event without any breakpoints.

The designer is basically ignoring the fact that you hit "stop" and is executing the code regardless.

Did any of you try it? If so, what were the results?
__________________
I love lamp.

Last edited by Stompy; 08-07-2004 at 10:24 AM..
Stompy is offline  
Old 08-07-2004, 04:48 PM   #11 (permalink)
Crazy
 
I'll try it Monday at work (I only do WinForm development here at home. Just little applications for myself). But I do that exact kind of code almost every day and I've never had a problem with code executing after I've hit "stop" in the debugger. You say "If you comment it out, nothing will happen, of course," but if you hit stop when you have a breakpoint set on that line that line shouldn't execute of course. This tells me that you're doing something differently than I do when I'm debugging. So you set a breakpoint and the code stops, do you hit F5 then or click the "stop" button in the debugger? If you set a breakpoint at the event handler declaration "private void Button1_Click(" and then run the code, stopping when you get to the event handler, does the SQL statement still get executed? How are you stopping execution of the code? When you hit the breakpoint and step through the code using F11 what happens? I'm taking you through the same kinds of steps I would use if I ran into this problem.

You can use the SQL Profiler to start a trace and watch the activity on a specified database. That'll show you the SQL being executed against the database and when it is executed.
twister002 is offline  
Old 08-07-2004, 07:44 PM   #12 (permalink)
Banned from being Banned
 
Location: Donkey
If you breakpoint the conn.Open() AND the cmd.ExecuteNonQuery() statements, once you hit stop in the debugger (by clicking the "stop" button on the toolbar), the code will still execute. To me, this shows that it's something in the background, and since it only happens on asp.net projects... I can only assume the worker process.

I had a friend of mine try this on his machine and it does the same thing to him.

It's funny that no one has experienced this, because I've been dealing with this issue for AGES now and I'm starting to get pretty fed up with it
__________________
I love lamp.

Last edited by Stompy; 08-07-2004 at 07:47 PM..
Stompy is offline  
Old 08-10-2004, 05:24 PM   #13 (permalink)
Banned from being Banned
 
Location: Donkey
Anyone try the code example yet?

... or are you just as stumped?
__________________
I love lamp.
Stompy is offline  
Old 08-10-2004, 07:28 PM   #14 (permalink)
Crazy
 
argh, I've been in meeting hell for the past two days! Tomorrow I'm chaining myself to my desk though so I'll try it then. I saw a post on a blog somewhere today talking about this exact problem (was it you?) and the solution was some setting like "debug unmanaged code = true" which seemed odd to me since I thought the ASP.NET process was all managed code.

I'll try it out and try debugging it with WinDbg to see if I see the same behavior.
twister002 is offline  
Old 08-14-2004, 10:02 PM   #15 (permalink)
Tilted
 
Location: So. Cali
wow, when I first read this i thought you were on crack..but tried it on a project that I am working on and it definitely happens... If i break on my connection.open statement and hit stop then the query isnt executed..but if i step past that to the next line (cmd.connection = conn) and stop, it continues on and executes the query... very odd.
__________________
Tell me what we’re fighting for— I don’t remember anymore, only temporary reprieve.
And the world might cease if we fail to tame the beast;
from the faith that you release comes an atheist peace.
f00sion is offline  
Old 08-16-2004, 07:12 PM   #16 (permalink)
Insane
 
This is just another part of server-side programming.

I've written plenty of scripts in the past that looped longer than I wanted. Even when I hit stop, the server was still going.

The problem lies within the engine over on the server. If you are legitimately stopping your app and the server is still crunching numbers, then I'd say something is definately up with .NET (this would not surprise me at all)
dunkelhelmut is offline  
Old 08-17-2004, 07:42 AM   #17 (permalink)
Banned from being Banned
 
Location: Donkey
It's on the same machine (local XP Pro). I'm not doing remote debugging or execution of any kind.
__________________
I love lamp.
Stompy is offline  
 

Tags
code, hit, net, notice, runs, stop


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 08:15 PM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360