Visual Studio Debugger Tips You Need To Know

by Jon Davis 22. June 2009 17:45

Came across this article today. It's probably very old, as it's on an ASP Classic file and has no date.

 http://www.eggheadcafe.com/articles/20050511.asp

Good stuff, I didn't know or forgot about half of that stuff. IMO, using a debugger correctly (vs. constant logging and alert pop-ups) is huge when measuring one's productivity.

Incidentally, When looking for a "breakpoints window" I ended up being rather pleased to find that there's a right-click context menu in the breakpoint gutter after a breakpoint has been set in the text editor, revealing:

  • Location - Break execution when the program reaches this location in a file: File: [file path]; Line: [##]; Character: [##]; [checkbox] Allow the source code to be different from the original version
  • Condition - When the breakpoint location is reached, the expression is evaluated and the breakpoint is hit only if the expression is true or has changed. [checkbox] Condition: [textbox] [radio]: Is true; [radio]: Has changed
    • Yessss!! I've SO badly needed this one, I don't know how many times I've pounded F5 while staring at my Watch window waiting for some string to show up in a loop, or actually wrote inline code like
      if (condition && System.Diagnostics.Debugger.IsAttached)
          System.Diagnostics.Debugger.Break(); // my head open against the wall
  • Breapoint Hit Count - A breakpoint is hit when the breakpoint is reached and the condition is satisfied. The hitcount is the number of times the breakpoint has been hit. When the breakpoint is hit [drop-down]:
    • break always
    • break when the hit count is equal to [##]
    • break when the hit count is a multiple of [##]
    • break when the hit count is greater than or equal to [##]
  • Filter - You can restrict the breakpoint to only being set in certain processes and threads. Enter an expression to describe where the breakpoint should be set, or clear the expression to have the breakpoint set in all processes and threads. You can combine clauses using & (AND), || (OR), ! (NOT), and parentheses. Sample clauses:
    • MachineName = "machine"
    • ProcessId = 123
    • ProcessName = "process"
    • ThreadId = 123
    • ThreadName = "thread"
  • When Breakpoint Is Hit - Specify what to do when the breakpoint is hit.
    • [checkbox] Print a message:
      • sample: "Function: $FUNCTION, Thread: $TID $TNAME"
    • [checkbox] Run a macro: [macros drop-down]
    • Continue execution
Wow, that's some powerful breakpoint logic I didn't realize was right under my nose.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Software Development

Nail-biting success with Windows 7 Media Center and CableCard

by Jon Davis 22. June 2009 01:34

I got CableCard working today with Windows 7 Media Center. This is my first CableCard install. The install was not smooth, but it was successful. I'd heard a lot of horror stories about CableCard, but most of these stories were from two years or so ago. I expected the whole matter to be cleaned up by now. It has probably improved a lot, but I was surprised by how bumpy the ride was.

...

COX technicians really, genuinely, deeply hate CableCards. This was the first visit to install CableCard, but the second visit from COX in the last couple weeks where the subject of CableCards came up. These guys acknowledge that the idea behind CableCard is a sound one, but the problem is that they are so different, and the devices are so different, that it's really hard to get a successful install. [I think Microsoft can relate to this sort of experience, being that their software works with most any white box PC on the planet.] Today's installer had a nauseous-looking frown on his face consistently from the moment he climbed the outer stairs to my door until the minute he walked out the door.. although, he had a slight skip in his step when he left. I'm not sure if that's because he was glad the torture was over or if it was because it wasn't another failure.

More at: http://thegreenbutton.com/forums/thread/370299.aspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Electronics | General Technology | Pet Projects

IIS Subweb Applications Are Virtual Directories

by Jon Davis 21. June 2009 14:32

Microsoft never ceases to amaze me how they keep showing the most obscure error messages and support documentation for the simplest of causes.

HTTP Error 500.19 - Internal Server Error

Description: The requested page cannot be accessed because the related configuration data for the page is invalid.
Error Code: 0x80070005
Notification: BeginRequest
Module: IIS Web Core
Requested URL: http://www.mysite.com/myapp/
Physical Path: ~~
Logon User: Not yet determined
Logon Method: Not yet determined
Handler: Not yet determined
Config Error: Cannot read configuration file
Config File: ~~
Config Source:

   -1:

    0:
More Information... This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error.
 

I was getting IIS 7 error 500.19 on Windows Server 2008 over the weekend, and when I discovered it I spent hours on this error. Google didn't help; everyone pointed to invalid XML in the web.config or in applicationHost.config, or said that there must be an invalid DLL reference in applicationHost.config, or said that I need to add the proper users (IIS_IUSRs, Network Service, IUSR) to the directory and/or web.config. None of these solutions applied. There was nothing in my Windows event logs and enabling IIS tracing produced no log files.

It turned out to be a simple cause: the physical directory as configured in Basic Settings for the application was wrong. Why Microsoft did not include this rather obvious scenario in the Help file for this error is beyond me!!

In my case, my root web was working fine, but my subwebs were not working fine and I got this error for the subweb. The subweb was an individually configured ASP.NET application. I figured that this wasn't important because the root web was just a flat HTML file, but it mattered.

What happened in my case was that a few days ago I had relocated the root web, then updated IIS to point to the new directory. All of the subweb applications, however, were treated by IIS as virtual directories, each with its own physical directory mapping. So each had the stale path. More specifically, I moved "C:\dir\www.mysite.com" to "C:\dir\mysite.com", updated IIS for my site to point to \dir\mysite.com, and left it as such. The applications under ...\mysite.com were each pointing to the stale absolute path of C:\dir\www.mysite.com\[application] instead of picking up the relative path of their parent directory.

I had to update each subweb application's Basic Settings to point to the revised path, and the 500.19 error went away.

Hope this helps others like it would've helped me.

Jon

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Servers and Services | Web Development

SQL Server Is Not Case Sensitive!! (Traumatically Humbling Note To Self)

by Jon Davis 15. June 2009 22:29

I don't know if it's a good idea for me to post this. This is so humiliating and humbling that I'm scared that anyone who might actually read my blog would consider me genuinely, well, "one who rides the short bus". 

But SQL Server is not case sensitive. I didn't know that. I've been a web & app developer with SQL Server as my essential RDBMS for .. gosh, twelve years now. Yet, I've frequently used LOWER() and LIKE to try to nudge field/text comparisons to be case insensitive, yet this whole time I didn't need to. SQL is not C#.

This guy speaks my words precisely.

http://www.bennadel.com/blog/723-SQL-Server-Text-Matching-Is-Case-INSENSITIVE.htm

Down to detail. "I am officially retarded," indeed, that's exactly how I feel. Well maybe if more people would blog this then less of us would feel so awful.

How to make it case sensitive? Here's a sample: http://blog.sqlauthority.com/2007/04/30/case-sensitive-sql-query-search/

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

SQL Server

SQL Server Express Edition and Dynamic Ports

by Jon Davis 17. May 2009 14:13

While transferring to my new web host, I ran into a roadblock that had me stalled for a day or two while I tried to figure out what was going wrong. I like to use my own laptop here at home when managing SQL stuff, so I poked a special hole in the Windows Firewall on my new VPS instance to just allow my IP on port 1433, while enabling TCP/IP for SQL Server and restarting the service. But I could not connect!

I spent several hours poking at it, rebooting it, turning off the Windows firewall completely (temporarily), trying to get connected to that darn SQL Server instance I had installed on my new VPS, but it just would not connect. Then I noticed that the client tools (namely SSMS) on the VPS itself could not connect to ITSELF on the TCP/IP stack, it could only connect on Shared Memory or Named Pipes. What is going on?!! Could it be a bad OS image on the VPS?

Eventually it got resolved. The VPS hosting company was very helpful in assisting me on the matter, and at the same time I got some replies on a SQLServerCentral.com forum post that narrowed down to the same problem: Dynamic Ports.

This SQLServerCentral.com forum reply was the critical new knowledge for this weekend.

Hello Jon,

SQL Server Express (2005 & 2008) defaults to Dynamic Ports, whereas the Default Instance of other Editions listen on Static Port 1433 (by default). 

Having a Zero in the Dynamic Port configuration will have been overriding the Static Port that you entered, and therefore causing your connection problems.

Regards,

John Marsh 
 

I'd never heard of dynamic ports before. And the reason why I've never run into this issue before was because I've always used the full version of SQL Server that comes with MSDN licenses, and that version, by default, does not use dynamic ports by default, it uses Port 1433, which I expected SQL Server to default to in my case. But for both SQL Server 2005 and SQL Server 2008, the Express edition defaults to use Dynamic Ports when TCP/IP connections are enabled. So all my setting of Port 1433 in the Configuration Manager was completely ignored because it switched right back over to Dynamic Ports. To make things even more confusing, to enable Dynamic Ports, the setting is set to '0'. That's '0', as in the programmatic standard for FALSE, just not in this case, as is thoroughly documented in SQL Server documentation. Heh heh.

So with the Dynamic Ports' setting of '0' removed, I'm up and running. And now this blog (not to mention other, more legitimate sites I run [sic?]) is finally (as of Sunday afternoon) moved off my home PC and onto my new VPS.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Servers and Services | SQL Server

So Long, Farewell

by Jon Davis 15. May 2009 02:10

No I'm not killing off my blog. I am, however, going to stop being so cheap, and start hosting my IIS web apps, including this blog, on an external server for a change.

For years now I've been hosting my blog here behind a home cable modem. As I post this--indeed this'll be the last night that this will be the case--I have a cheap virtual dedicated Linux server with Apache proxying out to my home IP on an alternate port. COX only blocks port 80 (the web port, and some other ones like SMTP's), so I have my router at home rigged to redirect traffic on the alternate port back to port 80 and to my internal web server's IP address (this is the same server that "serves" me prerecorded shows on my HDTV via Vista Media Center). The proxy/router setup works, but then COX keeps killing off my Internet connection. I keep having to stand up, go to the back room where the cable modem is, disconnect the cable modem power and coax, wait for 5 seconds, and reconnect everything. (Yes, the coax, too. It doesn't resync unless I do that.)

My web site tends to go offline all day while I'm at work. I've noticed that the disconnects happen routinely at about 3:15 PM and at about 1:45 AM, but they also happen erratically and sporatically throughout the day, and it often stays offline until human intervention (manual shutoff and powerup). And, I am beginning to suspect that they are actually monitoring network traffic and they disconnect me when they see any normal flood of inbound HTTP requests that come from two or more visitors at a time. It might also be heat-related; the disconnects are suddenly much more frequent lately, and coincidentally it's suddenly a lot hotter around here in this Arizona climate.

So I'm finally caving in; short of tunnelling the proxied HTTP packets, I can't beat COX at this game. I'm going to try a VPS from http://www.automatedvps.com/about.php .. They look like an under-established outfit but so far they are not just affordable for Win2008 virtual dedicated hosting, the VPS I've already snagged feels quite performant. I'll have all the Windows play dough I could ask for, and I won't have to worry about my blog or any major web site I might be hosting going offline because COX wants to keep us from hosting stuff.

Incidentally, before signing up with AutomatedVPS.com, I tried Mosso.com's Site Cloud. I'd been slobbering over their Kool Aid for so long, I had to give them a shot. It was ugly, though. Their control panel behaves erratically, frequently showing multiples of new objects being added until you refresh or until a Live Chat support staff deletes the extras. I had to throw the whole thing out when I saw that I had NO control over IIS 7 and the subweb applications and application pools.

------

UPDATE: Ouch. Yeah, that took a lil more time than I expected to transfer everything (see next post re SQL Express and Dynamic Ports), but it's switched now. 

Currently rated 3.0 by 1 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Servers and Services | Web Development

My ‘Aha!’ Moment With Javascript

by Jon Davis 14. May 2009 01:25

For most people this goes back to Javascript 101 but it’s worth blogging, in my opinion. A lot of people truly have no idea how much power is available on the client side of web apps, and they actually think that Javascript is dying.

The true power of Javascript was not made known to me until I had my aha! moment. It was about two or three years ago, and I think I could sum up (profusely, with freeze-dried concentration) what triggered my realization when these two essential facts became clear:

Discovery #1:

var myFunc = function() { };
var myObj = new myFunc();

.. is to Javascript what this is to C# ..

public class MyClass 
{
	public MyClass() { } 
}
MyClass myObj = new MyClass();

That is to say, Javascript functions are functions (of course) but also “classes” (object prototypes) and constructors all rolled into one. So, for example, to accomplish this in C# ..

class MyClass {
	void DoSomething() {
		MessageBox.Show("something");
	}
}

... 

MyClass myObj = new MyClass();
myObj.DoSomething();

.. you could do this in Javascript ..

function myFunc() { }

myFunc.prototype.doSomething = function() {
	alert('something');
};

...

var myObj = new myFunc();
myObj.doSomething();

Or, you could assign the doSomething member function “at runtime” (dynamically appending the member to the object after the object has already been instantiated).

var myFunc = new function() {
	this.doSomething = function() {
		alert('something');
	};
};

var myObj = new myFunc();
myObj.doSomething();


// or even


myObj.doSomethingElse = function() { alert('something else'); };
myObj.doSomethingElse();

Note that ‘this’ is used to reference the object instance that the function instance is. Incidentally, you can ensure “this” works when calling other objects’ functions by using function_name.call(object, params);.

That said, these things point out the dynamic nature of Javascript object members – you can append properties and functions to an object at runtime by using syntax like [object].doSomething = function() { }. It also shows that members on an object are akin to a string-keyed hashtable.

And that hashtable-like behavior brings about the second part of my “aha!” moment.

Discovery #2:

All user-defined objects, including functions, are ultimately string-keyed hashtables. That is not a limiting behavior but an extra feature because they are still real objects.

But JSON (Javascript object notation) objects are extraordinarily handy as alternatives to functions because of the expressive way you can declare them.

var myNewObject = {
	member_A : "abc",
	member_B : 123
};

.. is akin to C#’s ..

Dictionary<string, object> myNewObject = new Dictionary<string, object>();
myNewObject["member_A"] = "abc";
myNewObject["member_B"] = 123;

And it’s even more powerful when you consider that the members can be functions.

myNewObject = {
	doSomething: function() {
		alert('something');
	}
};
myNewObject.doSomething(); // invoke

// or,

myNewObject = { };
myNewObject.doSomething = function() {
	alert('something');
};
myNewObject.doSomething(); // invoke

.. can be implemented in C# 3.0 like so ..

delegate void SimpleMethod();
public static void RunSnippet()
{
	var myNewObject = new Dictionary<string, object>();
	myNewObject["doSomething"] = (SimpleMethod)(() =>
		MessageBox.Show("something")
	);
	
	// .. 
	
	((SimpleMethod)myNewObject["doSomething"])(); // invoke
}

In fact, take a look at this old blog post I saw at Ajaxian.com: http://colinramsay.co.uk/diary/2008/04/02/javascript-generation-a-change-of-heart/

In return, comparing the two languages reveals the power of C# 3.0, as well. C# 4.0’s dynamic objects will be trying even harder to “be powerful like Javascript already was”.

*evil grin*

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Web Development | Software Development

Quickie Alarm

by Jon Davis 13. May 2009 23:39

I flew out to California on Friday night to visit my siblings, and when I arrived I rented a car and drove around in the middle of the night looking for a cheap place to sleep. After an hour of getting completely lost I finally found a Motel 6 (*shudder*), climbed into bed, and then realized that there’s no alarm clock in the room. Great.

So I threw together another alarm clock on my laptop. I went through the trouble of giving it a nice touch, so it took an hour or two rather than a minute or two, but it did the job and I was proud and still managed to sleep well.

And now I’m sharing it here online. This is freeware with source code included. (Uses free Developer Express controls.)

image

.. click ‘Go’ and ..

image

Download: http://www.jondavis.net/codeprojects/QuickieAlarm/QuickieAlarm.zip

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Open Source | Cool Tools | Pet Projects

Set Up IIS For An MVC App: When All Else Fails, Check View Config

by Jon Davis 29. April 2009 17:22

I got stumped today when trying to set up a CruiseControl.NET+RoboCopy powered development server deployment for an ASP.NET MVC web app. I set up MVC Framework (gets MVC into the GAC), did the wildcarding in the IIS app config, and everything worked fine, except for strongly typed views. I was confounded. The Event Viewer showed:

Exception information:
    Exception type: HttpParseException
    Exception message: Could not load type 'MyMvcApp.ViewPage<MyModel>'.

This turned out to be caused by a simple mistake. After cc.net compiles the app, RoboCopy copies all the .aspx files over to the web app, and ignores the .cs files, the .config files, etc., so that the .config files don’t get overwritten. I had manually deployed the main web.config file for the app, but I forgot that the Views directory also has a web.config.

Why there is a web.config in the Views directory, I don’t know yet. But the extra .config file in the Views directory is absolutely mandatory to get an MVC app working on IIS, or at least on IIS 6 anyway (haven’t tried 7).

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Web Development | Software Development

Visual Studio 2008 Crashes When Using ASP.NET MVC (Nasty, NASTY Bug!)

by Jon Davis 16. April 2009 10:05

Some people (like me) have had issues with Visual Studio 2008 suddenly disappearing without errors when the developer user opens up an .aspx file, a .master file, or some other code file in an ASP.NET MVC project.

Had this show stopping issue beat me black and blue over the last 24 hours. I finally got past it when I used the /safemode switch with devenv.exe, but that disables all my lovely add-ins like Resharper. :(

Finally, one of the team members pointed me to “NDP20SP2-KB963676-x86.exe”. He had the same issue and tried to run this hotfix and it worked for him.

It seems to be working so far for me, too. The hotfix is here:

https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=16827&wa=wsignin1.0

File for Windows XP: NDP20SP2-KB963676-x86.exe

More info here: http://www.google.com/search?q=KB963676

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Web Development | Software Development


 

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Jon Davis Jon Davis (aka "stimpy77") has been a programmer, developer, and consultant for web and Windows software solutions professionally since 1997, with experience ranging from OS and hardware support to DHTML programming to IIS/ASP web apps to Java network programming to Visual Basic applications to C# desktop apps.
 
Software in all forms is also his sole hobby, whether playing PC games or tinkering with programming them. "I was playing Defender on the Commodore 64," he reminisces, "when I decided at the age of 12 or so that I want to be a computer programmer when I grow up." 

Amazon Collection

Most Recent of Many Library Investments

Tag cloud

Calendar

<<  July 2009  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar