KoenV

February 2008 - Posts

Quick Attach and Detach Debugger

Here's a trick I often use in Visual Studio to speed up the trial-and-error process.

A disadvantage of using an ASP.NET Web Application Project instead of an ASP.NET Web Site is that you cannot edit code behind files (or basically any code file in your web project) while you are debugging. So to edit just minor things there, you need to stop the debugger (which closes the browser typically), edit, compile and start the debugger again, which could take some time.

I have written (recorded and adjusted) a small VS macro that attaches the debugger for me. It will actually look if the VS built-in webserver is active. If not it will attach to IIS.

Sub AttachDebugger()

  Try

    Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger

    Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")

    Dim dbgeng(1) As EnvDTE80.Engine

    dbgeng(0) = trans.Engines.Item("Managed")

 

    Dim proc2 As EnvDTE80.Process2

    Try

      proc2 = dbg2.GetProcesses(trans, "").Item("WebDev.WebServer.EXE")

    Catch ex As Exception

      proc2 = dbg2.GetProcesses(trans, "").Item("w3wp.exe")

    End Try

 

    proc2.Attach2(dbgeng)

  Catch ex As System.Exception

    MsgBox(ex.Message)

  End Try

End Sub

Copy this in one of your Macro modules and it should compile. The script could be a bit different on Windows XP, because the ASP.NET process is called "aspnet_wp" there...

And then assign shortcuts to your macro. For detaching you don't need a macro, it's a built-in command. My shortcut's are Ctrl+Shift+A for attaching and Ctrl+Shift+D for detaching.

Now you can detach your debugger (leaving the browser open), edit the code, build it (only build what you changed), attach and refresh the browser...

Checkboxes in Windows Explorer

Here's a Vista feature some people have asked me about, the mysterious checkboxes... (Total Commander users: continue reading at your own risk :o)

Details view with checkboxes

Medium icon view with check boxes

 How does it work?

  • The checkboxes appear when you have selected a file/folder or when you hover it
  • When you click on the file/folder name or icon, the selection changes to that file/folder (clearing the previous selection)
  • When you click the checkbox, the file/folder is added to the current selection (without holding Ctrl or Shift)
  • Works in any view mode (details, list, icons, thumbnails,...) although I haven't seen it in the command prompt...

Where to get it?

  • Go to the Folder Options (can't think of the easiest way to get there but you should have it by now)
  • Go to the View tab
  • Scroll to the bottom
  • Check this one: Use check boxes to select items
    Folder options > View tab

Now you'll never have to drop your sandwich again to hold the shift key!

Posted: Feb 13 2008, 09:38 PM by koevoeter | with 2 comment(s)
Filed under:
CS0426: The type name 'Web' does not exist in the type 'ASP....

I've been having this problem with ASP.NET themes that block my web applications from working. I always get this error when opening any page: CS0426: The type name 'Web' does not exist in the type 'ASP.Foo'.

When I set the default language to vb (web.config > compilation tag), the exception message is even more cryptic: BC30002: Type 'Foo.Web.WebControls.MyWebControl' is not defined.

The problem was that I always use the following project setup:

  • Foo.Web: class library project containing web controls, base master pages, base pages, base user controls,...
  • Foo.WebApplication: web application project that references Foo.Web. I also register the controls globally in web.config (<pages><controls><add tagPrefix="foo" assembly="Foo.Web" namespace="Foo.Web.WebControls" />...) but the problem is also there if you register your controls locally.
  • Then in Foo.WebApplication I have defined a theme named "Foo" (in the App_Themes folder). I configure this theme globally in web.config (<pages styleSheetTheme="Foo">) but that shouldn't matter where it is configured.
  • In that theme I have a skin file (or several) that style one of my web controls from the Foo.Web project.

The problem is that at runtime the theme Foo is compiled in a namespace ASP.Foo, and then it will look for the namespaces Web.WebControls below that one, which isn't what I want. The only solution that I found is renaming the theme to something different, e.g. FooStyle.

I'm not sure whether this problem can also occur if you have an ASP.NET website, but I guess

Posted: Feb 12 2008, 06:03 PM by koevoeter | with 1 comment(s)
Filed under:
More Posts