1

I have a c# class library that I am calling from Classic ASP.

Is it possible to debug this using visual studio? Break points in the class don't work, which isn't surprising.

I am running this on iis7 in the browser, rather than through Visual Studio 2010 because of the fact that I'm using a classic ASP page. Do I need to get this running in Visual Studio in order for this to work?

I also tried to use Response.writes, but they result in: The name 'Response' does not exist in the current context

7
  • 1
    what a mess... why don't you create a normal ASP.NET web application and you get everything fine? Jun 17, 2011 at 12:04
  • Have you "attached" to the process? Jun 17, 2011 at 12:05
  • 1
    Is it yours? Is it compiled in /debug? Do you have the debug info file (*.PDB)? Jun 17, 2011 at 12:06
  • @Davide Piras - I have to integrate with a legacy Classic ASP system
    – Positonic
    Jun 17, 2011 at 14:48

5 Answers 5

1

You need to attach the debugger to the process (either IIS or another debugger that you are using to debug your classic ASP application) that is loading the assembly.

Under VS2010 go to Tools -> Attach to Process (probably the same under 2008 as well).

1
  • I have attached to w3wp process and can debug the classic asp part, but it won't step into the com component, which is what I need to debug.
    – Positonic
    Jun 17, 2011 at 14:53
1

try to add in the code of the lib: System.Diagnostics.Debugger.Break(); where you want to break. Also ensure the lib is compiled and deployed with the pdb symbols. When the code will reach the instruction, IIS will throw an exception. The system will ask you to attach a debugger, and you're on the way.

2
  • this may go without saying, but make sure "Allow Server-Side Debugging" is enabled in IIS :)
    – Matt H.
    Jun 22, 2011 at 7:17
  • @Matt H.: where do you check this setting ? In the .Net compilation screen in a web app ?
    – Steve B
    Jun 22, 2011 at 7:19
1

I actually wrote an article regarding this:

http://www.jameswiseman.com/blog/tag/visual-studio-2010/

From the article:

  1. Open Visual Studio 2010

    This is easy enough if you have it installed. Might be a bit tricky if you don’t ;-)

  2. Open your website in Visual Studio

    Again, easy enough.

  3. Fire up your web site. I.e. open your browser and navigate to the website.

  4. In Visual Studio, click ‘Debug’ Menu -> ‘Attach to process’

  5. You may need to tick the box labelled ‘Show processes from all users’
  6. ‘Inetinfo.exe‘ if application protection is low or ”dllhost.exe‘ if application protection is higher. You may get an ‘Attach Security Warning’ popup. If so, continue On. It’s a bit scary at first, but if it’s your own app on your own PC, then you’ll be ok. enter image description here

    If you’re worried about this, follow the advice on MSDN.

  7. Add a breakpoint to your code, and navigate to a location where you will hit it.

Troubleshooting - Registering pdm.dll

This worked on the first occasion that I tried it. Subsequent attempts were not so successful, and I found a few things that I had to do.

When trying to attach to ‘Script Code’ I got the following warning in the IDE.

Warning: Cannot debug script code. The correct version of pdm.dll is not registered. Repair your Visual Studio 2010 installation, or run ‘regsvr32.exe “%CommonProgramFiles%\Microsoft Shared\VS7Debug\pdm.dll”‘.

Just follow these instructions.

Troubleshooting - Restart IIS

This also helped on one occasion. Can’t really say why.

1
  • Thanks James, I have come across your article before. For some reason attaching to the processes you recommend don't work for me. I never hit the breakpoints. But I can and do attach to the w3wp process, but as I mentioned above. I do hit the classic asp break points, but I can't step into the actual com component.
    – Positonic
    Jun 17, 2011 at 14:55
0

You will make your life much easier all round if you wrap you .net classes in a web service then call the web service from the classic asp pages.

0

For debugging, attach the debugger to the process as described in other answers.

For tracing, I find very handy the combination between System.Diagnostics.Trace.Writeline() in the class library and an OutputDebugString listener like DebugView.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.