Got a question? Get an answer here


So I tend to describe a lot of issues here, but we had some really great conversation in our blog chat.  So I thought I would ask for questions from everyone.  Feel free to ask anything you like.  If it is a simple, quick answer, I’ll answer here in this blog posting.  If it is more complex, I’ll create a posting just for your question.

So ask as many as you want, the harder, the better.  But please keep it to IIS, .NET or ASP.NET as I am not an expert in all areas.

If you have an additional answer to a question, feel free to post that as well.

Question 1 – submitted by: Eber Irigoyen

Is it possible to find out if a specific session id is still alive?

Answer

While it is possible to do, it would require some extra work.  For instance, you could create your own log file to write to or just write to the event log in the Session_Start and Session_End events.  But with default settings, you can’t tell if a session is still alive.

Follow-up question:

what about connecting a debugger to the process?

Is it possible to find out if a specific session id is still alive? (without making any code changes)

Answer

So you can get that information out, but the best way is to just look at the IIS logs.  You can see the session id’s there and see the time and compare it to your session timeout setting.  In a dump, it is rather difficult to pull out the session id’s.

Question 2 – submitted by: Vear

I’ve setup a Windows Server 2008 with IIS 7. I want to make sure that I can run Ajax and Futures, .Net 3.5 and silverlight. I’m not sure which version of what I should load. Should I be loading SDK’s?.

Answer

Windows Server 2008 with IIS 7 gives you the best setup to run all the latest things.  You are all set for running all of these things.  You just have to then install them on top of IIS.  You can get the install links at http://www.asp.net/downloads/

Question 3 – submitted by: Sean Patterson

I’ve heard the Enterprise Library for .NET finally did a similar library, but I haven’t had time to check it out. Have you had any similar experiences with Log4Net, Enterprise Logging, or any other tools for debugging your web apps?

Answer

There are a bunch of tools you can use for various types of troubleshooting.  The Enterprise Library for .NET is a very good tool that you can use.  But with some of the additions to .NET 2.0 SP1, you don’t need it for just looking at exceptions as they are logged to the Event Log by default.  Depending on how deep you want to go, you can look at capturing dumps or using a profiler.  You can also use ASP.NET Tracing.  It really depends on what you are trying to deal with.

Question 4 – submitted by: Doug

I used the template for a personal site and the site works as expected in the development and when I copy the files to the server it displays as it should. But when I login on the site, it seems that the database that stores the Login names and passwords is not loading into SQL. I would really like to know what could be wrong on the server end.

Answer

Most likely what happened was the database you got with the personal site isn’t being moved to the server.  You need to check your database connection string and see where it is trying to connect to.  If it is trying to connect to the local SQL Server, you will need to move that database to the production machine also.

Question 5 – submitted by: chittibabu

Please elaborate about architectures. 3 tier, 2 tier and n tier

Answer

Tiers refers to the number of machines that are used to serve the site.  For example, if you have a web server and another machine that holds your database, you are using a 2 tier architecture (one tier for the web server and one for the database).  If you separate your site where the web server calls a business application layer and that calls the database, you are then using a 3- tier architecture.  You can read more of an intro to these things on Multitier architecture

Question 6 – submitted by: Hazel

Is ASP.NET a version of .NET? Or are the terms .NET and ASP.NET interchangeable?

Answer

ASP.NET is a web component to .NET.  It is an addition to the base CLR.  So you have the .NET Framework which any application can use, ASP.NET is a web application that sits on top of .NET itself.

Question 7 – submitted by: Sherry

How do you include classes that were designed for a windows application into a web application?

Answer

Windows applications can be included as long as they are just classes and don’t do anything visually. It is also a good idea to stay away from System.Drawing on the web. You should be able to just add them to a project in Visual Studio and use them.

Question 8 – submitted by: Sherry

Also, if you are working with databases and you choose Access instead of SQLServer, what do you need to change in the code?

Answer

For access, you just need to change the connection string. Nothing else needs to be changed, depending on what client you are using. The SqlClient is only for SQL Server.

Question 9 – submitted by: Pradeep

For a single click on a collapsible panel control in Ajax it should expand, but its happening for the second click, is there any solution for that? Do I need to set any of the property there?

Answer

There shouldn’t be a property to set for that. Are you on the release version? Maybe it is a problem with the beta. Also, you could try checking out the video at:

http://www.asp.net/learn/ajax-videos/video-89.aspx

It may be inside another object that is affecting that also.

Question 10 – submitted by: Fanweixiao

Too many exceptions could makes CPU high? why? because of the GC?

Answer

Yes exactly. It is expensive to create them, gathering the callstacks and all the data, and it is also CPU expensive as they take up a lot of room and then the GC has to clean them up.

Question 11 – submitted by: Fanweixiao

Virtual bytes is larger than private bytes, means there are too much fragmentation? If it is, where are they from? Does it makes high CPU?

Answer

It is hard to tell without getting a dump. When .NET grows, we will reserve an entire segment and, on 64-bit for example, this can be a large allocation. So it could just be that. For example, if you have multiple processors, we will allocate one segment for each processor at start-up which can cause a large difference between private and virtual.

Question 12 – submitted by: Chrnico

I have an AJAX-intensive project that has recently been upgraded to the 3.5 framework (the Ajax control toolkit has been updated as well). Everything is functioning correctly but I now have mysterious postback flickers occurring in my ModalPanels and TabContainers. Any idea if this is a known bug?

Answer

Not that I’m aware of.  I looked and didn’t find anything with a quick search either.

Question 13 – submitted by: P

I am looking for asp.net feature, whenever a new record is inserted in a database table, I have to get an alert in the application. like ticker, like gmail chat. but I should not have plug-ins or client-side software to install.

I will be happy if you have some way in asp.net AJAX or some other ways. please let me know if you have written any article on this, and please do share the link where I can get your guidelines.

Answer

There isn’t any samples that I can find that do this, but you could use AJAX to do this.  Just setup a timer with an interval that is good for you and have it check the database for updates.  It can then update the UI accordingly.

Question 14 – submitted by: Pat

I have a question about IIS.  I’m trying to start a project in VB ASP.NET web form.  I have downloaded the IIS manager 7.0 and I’m running WinXP with the updates.  When I try to start the new project I can’t put in a URL of my PC.  Is IIS not running?  I’m not sure how to check as I’m new to ISS and ASP.NET.

Answer

You can try running inetmgr from the run command and you can see in the MMC if it is running.  You can also try browsing to http://localhost and see if that works.

Question 15 – submitted by: Jim

The URL is an html file that uses an iframe tag to another server at mail2.eweb-tracker.com. All works just IE when I put my cursor in the UI I get a dialog error: access denied. I have look for help but all I get is IE does not allow cross domains. But Firefox works great. What can I do.

Answer

If you are using AJAX, you can do the solution here or here.

Question 16 – submitted by: Baka

What’s the difference between WCF Vs ASMX (web serivice) if any? Also, some test data or comparisons would be nice.

Answer

Great question.  You can find the differences here.

Question 17 – submitted by: Muhanned

how can I convert the html base web pages into .aspx file I have problem to convert 100 .html pages into .aspx

Answer

The easiest way to just convert them is to do a find and replace and just rename them that way.

Question 18 – submitted by: Basheer

Please try to introduce a complete web  site application from plan to deploy as a guided in pdf format.

Answer

This isn’t exactly what you are looking for, but there is an amazing sample along with lots of data around it at http://www.dinnernow.net

Question 19 – submitted by: Rohit

hi can one please tell me that, I have one single web page made in vs2008 with 2 dropdown, with their autopostback property=true and each has two items in it. Now problem is when I access that site from remote machine through url after every 10 server trip it gives error, page does not render completely. weird it may sound but its true, if any one knows the reason please help

Answer

You would have to give more.  What is the error it gives?

Question 20 – submitted by: Pradeep

I want to create a User control called "PageNavigation" that contains Page Numbers (linkbuttons) and next and previous buttons. 

The problem I am facing is that the click event of these linkbuttons inside the user controls are fired after the events on the container in which this user control is used.

I want the new page number in the container so that I can fetch the records from the DB based on the new page number. But the new page number is generated only in the user control which cannot be passed to the parent page.

I tried to fix this problem in the page render event control, but it is causing problems with other functionality.

Do you have any idea how we can implement this?

Answer

You should be able to disable the bubbling of events up.  Check the Internet for disabling event bubbling.

Question 21 – submitted by: Venkata

I am looking for some guidelines, to make configuration changes to machine.config file on production server to boost the asp.net 2.0 application performance. While I can find lot of topics on Internet but none of them are specific to .Net 2.0. You help is highly appreciated.

Answer

Most of the performance gains are already implemented in 2.0 by default.  The only other performance gains you can get by following the steps outlined here and determining what is best in your situation.  You can also follow some of the blog entries I have to help narrow down what is happening.  You can also call Microsoft and have us help if you need it.

Question 22 – submitted by: Pedro

How can I use !savemodule to dump a dynamic assembly? I know you’ve talked about this on the chat, but I didn’t know your blog back then and I can’t seem to find any transcript (and "savemodule dynamic assembly" surprisingly doesn’t get me anything in google but your blog!)

Also, are dumped assemblies well-formed executables? I ask this because I’m getting a "couldn’t find runtime version" (or something of the sorts; it’s in Portuguese and has been badly translated) when I try to run it.

Answer

So !savemodule will write out the assembly and it will be a well-formed file.  The way to look at the file is to use a reflector, such as Reflector for .NET

Question 23 – submitted by: Crprajan

I have developed a data entry page in my ap.net application. I have a textbox where i need to enter an emailid.(e.g crp@gmail.com). Besides the textbox i have one button control. When i click the button control after entering the emailid it should search for the userid in the usertable and if it is there it should alert the user with "The user already exist. Pls give another emailid".

How to achieve this? Can anybody pls help me out?

Answer

You should be able to use a CustomValidator and just check for a good email address and then update accordingly.

Question 24 – submitted by: Adam

I was wondering if there was a way to allow developers read-only access to remotely view, via IIS 6 Manager, how a site is configured?

Developers have read-only access to various hard drives, event logs and service lists to aid diagnostics of live systems but the bit that eludes us is IIS configuration.

The only solutions I’ve come across are; 1. export the metabase and restore on another machine 2. write a web app that exposes the state of IIS (not sure where to start here, WMI?)

Any hints?

Answer

The easiest way is to upgrade to IIS7. With Server 2008 you can do just that and even let them just have access to some parts of the console. Otherwise, writing your own using the IIS API’s would be your best bet.

Question 25 – submitted by: Raji

I have a problem, when I use a master page & try to add a tree view links in the left side of the master page. but the content of the links are getting from dB . I need to know how this is possible in using Ajax update panel & tree view.

Answer

You should be able to do this exactly like you would on a normal page, using the update panel inside the master page.  Just don’t put it in a ContentPlaceHolder section so it is always on the pages.

Question 26 – submitted by: Francois

I don’t know if that fits in IIS/.NET/ASP.NET, since this is a wider scope question, so feel free to reject it:

I’ve been wondering for a long time: the guidance’s from Microsoft on how to do web apps (without MVC) in ASP.NET have come from the WCSF, using the MVP pattern and, among other things, the Object Container Datasource, which is great, but not part of stock ASP.NET

This is all great and nice, but what would you be your suggestion on a good pattern to make clean, well separated and easy to maintain enterprise level ASP.NET application using only the stock controls and libraries? Maybe a way to use the stock Object Datasource while still using MVP would be nice…

Answer

I’d suggest looking at the ASP.NET Quickstarts as they provide a great way to create things using the stock objects.

Question 27 – submitted by: Miguel

I read somewhere a few weeks back that you guys are working on adding VBScript/Classic ASP intellisense back into Visual Studio 2008. Do you know if this has been released yet? Is it still being worked on?

Answer

What I can tell you can be found here.  According to that, the suggested advice is to keep 2005 installed to edit VB Script.  They also said there that it will be supported in the next roll-up patch/Service Pack.

kick it on DotNetKicks.com

Comments (58)

  1. You’ve been kicked (a good thing) – Trackback from DotNetKicks.com

  2. You can submit any question you have around .NET, IIS, or ASP.NET to me at my blog and I’ll answer the

  3. wisemx says:

    Thanks.

    Something that would be handy straight from the team is how to handle ASP.NET (2 and later) form events when a Master page is added after the fact.

    Say for example a contact page with a button event to submit, but once a Master page is added the contact page lost it’s form to the Master page.

  4. is it possible to find out if a specific session id is still alive?

  5. Vear says:

    I’ve setup a Windows Server 2008 with IIS 7. I want to make sure that I can run Ajax and Futures,  .Net 3.5 and silverlight. I’m not sure which version of what I should load. Should I be loading SDK’s?.

    Thanks

    Vear

  6. Greetings!

    Whenever I think of debugging, I think of this and have been meaning to get info from you guys, though it may not be considered debugging in the proper sense.

    I’ve been using Log4Net now as a great debugging tool for my web apps. Any exceptions that are caught are logged and the end user sees a friendly error page. From there I can use a web tool I created to view the error log and see where to proceed. When things get really crazy, I crank up the logging level to get individual details of variables and such.

    I’ve heard the Enterprise Library for .NET finally did a similar library, but I haven’t had time to check it out. Have you had any similar experiences with Log4Net, Enterprise Logging, or any other tools for debugging your web apps?

  7. Francois Ward says:

    I don’t know if that fits in IIS/.NET/ASP.NET, since this is a wider scope question, so feel free to reject it:

    I’ve been wondering for a long time: the guidances from Microsoft on how to do web apps (without MVC) in ASP.NET have come from the WCSF, using the MVP pattern and, among other things, the Object Container Datasource, which is great, but not part of stock ASP.NET

    This is all great and nice, but what would you be your suggestion on a good pattern to make clean, well separated and easy to maintain enterprise level ASP.NET application using only the stock controls and librairies? Maybe a way to use the stock Object Datasource while still using MVP would be nice…

    Do you understand what I mean? (if not, I’ll happily try and clarify).

  8. chittibabu says:

    please elaborate about architectures. 3 tier, 2 tier and n tier

  9. Hazel says:

    A naive question from a non-techy…..

    Is ASP.NET a version of .NET? Or are the terms .NET and ASP.NET interchangeable?

    Sorry to be so basic!

  10. tomchris says:

    Keep the questions coming if you got them.

  11. Bill says:

    Hi,

    I have a strange problem that I can’t seem to fix.  I’ve been doing development on an ASP.Net project for several months using VS 2005. Last Friday I did a compile and everything was fine.  I got up Sat and without making any changes the compile failed with and error that Microsoft.Web.Extensions.dll could not be found while trying to create a UpdateProgress control.  I know the Microsoft.Web.Extensions.dll was used on the AJax Beta which I have never used on this machine. Some of the pages were orginally developed using the Beta release but they were all converted using the 1.0 release.  I gave up trying to fix it some I copied the project to another machine and the problem went away.  I then decided to uninstall/reinstall VS 2005 and the AJax Extensions.  The uninstall goes fine but after reinstall problem persist.  I don’t think the uninstall really uninstalls everything because when I try to reinstall the VS2005 service pack it says its already installed and when I open VS all the most recent project are displayed in the start page.  Am I missing something on the uninstall?  Do you know of a solution to the Beta dll  problem? I’m about ready to format the drive and start over, but really don’t want to.

  12. tomchris says:

    Bill,

    After unistalling it, you can try deleting the files that AJAX uses.  That may help.  You can always call support.  We can assist in fully removing the files and not needing to format the machine.

  13. Here is a question that was asked on my posting trying to invite questions, Got a question- Get an answer

  14. Prashanthganathe@gmail.com says:

      I am looking for asp.net feature, whenever a new record is inserted in a database table, i have to get a alert in  the application. like ticker, like gmail chat. but i should not have a plugins or clientside software to install.

    I will be happy if you have some way in asp.net AJAX or some other ways. please let me know if you have written any article on this, and plz do share the link where i can get you guidelines.

  15. Jonah says:

    How can I store large amount of article exceeding 8000 caharacters in SQL server?

  16. Pat says:

    I have a question about IIS.  I’m trying to start a project in VB ASP.NET web form.  I have downloaded the IIS manager 7.0 and I’m running WinXP with the updates.  When I try to start the new project I can’t put in a URL of my PC.  Is IIS not running?  I’m not sure how to check as I’m new to ISS and ASP.NET.

    Thanks,

    Pat

  17. Jim Lawton says:

    The URL is an html file that uses an iframe tag to another server at mail2.eweb-tracker.com. All works just IE when I put my cursor in the UI I get a dialog error: access denied. I have look for help but all I get is IE does not allow cross domains. But Firefox works great. What can I do.

  18. rocket5725 says:

    How to handle form events after adding a master page to an existing page

  19. Baka says:

    What’s the difference between WCF Vs ASMX (web serivice) if any? Also, some test data or comparisions would be nice.

    Thanks

    Baka

  20. BASHEER says:

    Please try to introduce a complete web  site application from plan to deploy as a guided in pdf format.

  21. how can i convert the html base web pages into .aspx file i have problum to conert 100 .html pages into .aspx

    send me the complete answer on my email

    m.s.kworld81@hotmail.com

  22. rohit says:

    hi can one please tell me that, i have one single web page made in vs2008 with 2 dropdown, with their autopostbox property=true and each has two items in it. Now problem is when i access that site from remote machine through url after every 10 server trip it gives error, page does not render completely. weired it may sound but its true, if any one knows the reason please help

  23. venkata rao swarna says:

    Hi,

      I am looking for some guidelines, to make configuration changes to machine.config file on production server to boost the asp.net 2.0 application performance. While I can find lot of topics on internet but none of thema re specific to .Net 2.0. You help is highly appreciated.

  24. PradeepTP says:

    hello Tom

    I want to create a User control called "PageNavigation" that contains Page Numbers (linkbuttons) and next and previous buttons.  

    The problem I am facing is that the click event of these linkbuttons inside the user controls are fired after the events on the container in which this user control is used.

    I want the new page number in the container so that I can fetch the records from the DB based on the new page number. But the new page number is generated only in the user control which cannot be passed to the parent page.

    I tried to fix this problem in the page render event control, but it is causing problems with other functionilty.

    Do you have any idea how we can impelment this?

    -pradeeptp

  25. Pedro d'Aquino says:

    Hi, Tom!

    How can I use !savemodule to dump a dynamic assembly? I know you’ve talked about this on the chat, but I didn’t know your blog back then and I can’t seem to find any transcript (and "savemodule dynamic assembly" surprsingly doesn’t get me anything in google but your blog!)

    Also, are dumped assemblies well-formed executables? I ask this because I’m getting a "couldn’t find runtime version" (or something of the sorts; it’s in Portuguese and has been badly translated) when I try to run it.

    Thanks a lot!

    Pedro

  26. what about connecting a debugger to the process?

    Is it possible to find out if a specific session id is still alive? (without making any code changes)

  27. Miguel says:

    Hi Tom

    I read somewhere a few weeks back that you guys are working on adding VBScript/Classic ASP intellisense back into Visual Studio 2008. Do you know if this has been released yet? Is it still being worked on?

    Thank you

  28. Pedro says:

    Tom,

    I have a problem getting WinDbg to break on CLR exceptions. I’ve tried it on 4 different machines (XP & Vista; WinDbg 6.8 & 6.7; .NET 3.5).

    In all of them I’ve tried entering: ‘sxe clr’, ‘sxe clrn’ or manually going into debug/event filters and setting both CLR and CLR notifications to enable (or output)/handle before the CLR loads, and yet it doesn’t break on anything, nor does it print any message.

    I can only assume I _must_ be doing something wrong. Do you have any idea of what the issue might be?

  29. tomchris says:

    Pedro,

    What exception are you trying to break on?  sxe clr should break on a managed exception.  Are you seeing a message in the debugger saying an exception happened?  If you see that, you can use the number listed in that and just do ‘sxe <number>’

  30. Pedro says:

    I’m trying to break when the CLR loads, or when a module loads.

    No, I don’t see any exception on the debugger. I’ve written a stupidly simple program to try and isolate the issue, and this is what I get on the debugger:

    CommandLine: "C:Documents and SettingsPedroDesktopteste.exe"

    Symbol search path is: SRV*c:websymbols*http://msdl.microsoft.com/download/symbols

    Executable search path is:

    ModLoad: 00400000 00408000   teste.exe

    ModLoad: 7c900000 7c9b4000   ntdll.dll

    ModLoad: 79000000 79046000   C:WINDOWSsystem32mscoree.dll

    ModLoad: 7c800000 7c8ff000   C:WINDOWSsystem32KERNEL32.dll

    (ec0.594): Break instruction exception – code 80000003 (first chance)

    eax=00251eb4 ebx=7ffde000 ecx=00000000 edx=00000001 esi=00251f48 edi=00251eb4

    eip=7c901230 esp=0012fb20 ebp=0012fc94 iopl=0         nv up ei pl nz na po nc

    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000202

    ntdll!DbgBreakPoint:

    7c901230 cc              int     3

    0:000> sxe clr; sxe clrn; sx

    (…)

    clr – CLR exception – break – handled

    clrn – CLR notification exception – break – handled

    (…)

    0:000> g

    ModLoad: 77f50000 77ffb000   C:WINDOWSsystem32ADVAPI32.dll

    ModLoad: 77db0000 77e42000   C:WINDOWSsystem32RPCRT4.dll

    ModLoad: 77f20000 77f31000   C:WINDOWSsystem32Secur32.dll

    ModLoad: 77ea0000 77f16000   C:WINDOWSsystem32SHLWAPI.dll

    ModLoad: 77e50000 77e97000   C:WINDOWSsystem32GDI32.dll

    ModLoad: 7e360000 7e3f0000   C:WINDOWSsystem32USER32.dll

    ModLoad: 77bf0000 77c48000   C:WINDOWSsystem32msvcrt.dll

    ModLoad: 76360000 7637d000   C:WINDOWSsystem32IMM32.DLL

    ModLoad: 79e70000 7a3ff000   C:WINDOWSMicrosoft.NETFrameworkv2.0.50727mscorwks.dll

    ModLoad: 78130000 781cb000   C:WINDOWSWinSxSx86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.1433_x-ww_5cf844d2MSVCR80.dll

    ModLoad: 7c9c0000 7d1de000   C:WINDOWSsystem32shell32.dll

    ModLoad: 773b0000 774b3000   C:WINDOWSWinSxSx86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03comctl32.dll

    ModLoad: 5d510000 5d5aa000   C:WINDOWSsystem32comctl32.dll

    ModLoad: 790c0000 79bf6000   C:WINDOWSassemblyNativeImages_v2.0.50727_32mscorlib32e6f703c114f3a971cbe706586e3655mscorlib.ni.dll

    ModLoad: 774c0000 775fd000   C:WINDOWSsystem32ole32.dll

    ModLoad: 79060000 790b6000   C:WINDOWSMicrosoft.NETFrameworkv2.0.50727mscorjit.dll

    eax=76360000 ebx=00000000 ecx=7e360000 edx=77c41ae8 esi=7c90e88e edi=00000000

    eip=7c90eb94 esp=0012fc28 ebp=0012fd24 iopl=0         nv up ei pl zr na pe nc

    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246

    ntdll!KiFastSystemCallRet:

    7c90eb94 c3              ret

    Any insights? This is beginning to drive me mad!

    Thanks a lot for your help :-)

  31. tomchris says:

    So sxe clr will only break when a managed exception occurs.  If you want to break when the CLR loads, the easiest way is to use the sx command for breaking on a module load.  So you can do:

    sxe ld mscorwks.dll

  32. Pedro says:

    Oh, I see (althogh this contradicts what is said on !help faq). But should it break when a class loads?

    Actually my goal is to break on the Main method of my app, but for this to work I need to add a deferred breakpoint. I’ve tried setting it as soon as mscorwks and sos loads, doing:

    0:000> !bpmd teste.exe teste.Program.Main

    Adding pending breakpoints…

    But it’s no use; the debugger doesn’t break on anything. This was the root of me suspecting the debugger wasn’t being properly notified of things, as I suppose it needs to be notified that the class has been loaded and the method JITted.

    The text that appears on !help bpmd has a guidance for setting breakpoints on the Main method, but it doesn’t work (starting by using sxe -c "" clrn to break when the CLR loads).

    Thanks a LOT again!

  33. tomchris says:

    sxe clrn should break with .NET is loaded, but 2.0 doesn’t usually load mscorlib so I don’t think that will work.  I think that is useful for 1.x only.

    If you want it on a managed exception, take a look at http://blogs.msdn.com/tom/archive/2008/02/25/howto-capture-a-dump-on-a-specific-managed-exception.aspx

    You are right about it not being JIT’ed yet.  You can break on when your managed dll loads.  And then find your MethodTable of your class and run !dumpmt -md <method table> and find the MethodDesc of the function and do !bpmd -md <method desc>.  You can also use !bpmd [<module name> <method name>] and it should wait for it to be loaded.  Assuming you typed in the class and everything correctly.

  34. Pedro says:

    Tom,

    Thanks a lot for the links and your kind help.

    I don’t have a managed dll (the application I’m trying to debug is completely managed), so I can’t really stop when it is loaded.

    I’ve tried follwing Thottam R. Sriram’s instructions (using his code, compiling from the command line, running the same commands as him etc.) on both WinDbg 6.8 and 6.7 and on both of them the debugger wasn’t able to resolve the breakpoint and didn’t stop when it should. I’ve also tested it on a colleague’s computer, to no avail.

    Mr. Sriram breaks after mscorwks.dll loads and sets the breakpont on Main. For me, that doesn’t work. However, if I stop just after mscorjit has been loaded (sxe ld mscorjit.dll), I’m able to set the breakpoint -and it actually works! By then the CLR has already started and all the data structures seem to be in place, so I can use all commands (!dumpdomain, !dumpmodule etc) freely. The debugger tells me the code has not yet been JITted, but at least it finds the MethodDescriptor (which it never had before); when Main is in fact JITTED it prints a message, and soon after breaks.

    If you stop to set the breakpoint on any other previous module load (on my computer the one before mscorjit is ole32), it doesn’t work.

    Is this the expected behavior? I’ve reproduced it on a colleague’s PC.

    Again, thanks a lot. Your help – and speed – has been outstanding!

  35. tomchris says:

    Yeah, you have to wait until the managed structures are initialized before you can do anything.

    Remember bpmd is case sensative so you have to be careful.  Both methods should work, but you just have to verify that everything is entered perfectly.

  36. Pedro says:

    Yes, I’m sure I’ve entered everything perfectly :/ It just doesn’t work. Should I file a bug somewhere (at least a doc error?)?

    I don’t mean to abuse your patience, so let me just ask this one last, unrelated question: is there anyway for me to do !savemodule on a dynamically loaded assembly? Whenever I try to do it I get “Fail to read memory”

  37. tomchris says:

    Pedro,

    No worries about my patience :)

    I’ll see if I can repro this and let you know what I find out.

    As for dynamic assemblies, !savemodule should work as long as there is a module.  You can check running !dumpmodule -mt <module address> and see if that returns data.

  38. Miguel says:

    Hi,

    I am sorry for the long explanation below, but in order to understand the question I feel it best to provide you with some background information.

    Here is our scenario:

    We are using Client Certificates and forms authentication  for our client’s website. The idea was to provide a kind of fallback authentication so that if the User currently accessing the web site could not provide a valid certificate a login form would be shown where the user could enter his login data manually, otherwise the system would login the user with data obtained from the certificate. (This is all internal CAs).

    The site subdirectory is configured to Accept (not require) Client Certificates and IIS 5 is being used.

    If the user press cancel when being prompted by IE 6 to "choose a digital certificate" then ASP.NET can properly check that no certificate is present and then render the login controls; if on the other hand a valid certificate is provided then ASP.NET logins the user correctly and everything works fine. The problem arises when the users selects a Revoked or Expired certificate from IE 6; in this case IIS intercepts the error and does not allow ASP.NET the chance to execute any checking, event if we change the site custom errors to a aspx page we can’t get back to a normal behavior once a "wrong" certificate has been selected, the only option seems to be to close the IE 6 instance and open a new one.

    The question is then: Is there any way of making IE 6 and IIS restablish a SSL session, so that the user can be given the alternative to select a different client certificate, or can this error be trapped in any way from ASP.NET so that the SSL session be established as if no client certificate has been presented (in the same way it happens when the user clicks on cancel)?

  39. tomchris says:

    Miguel,

    Can you tell me the error you are seeing?  A 401?  What happens when the invalid certificate is presented?

  40. Pedro says:

    Tom,

    !dumpmodule -mt <address> works fine, and I can browse through all the data structures (methodtables etc.) without a glitch. This is what I get when I try to dump the module:

    0:000> !savemodule 00925aa0 C:test.dump

    4 sections in file

    section 0 – VA=2000, VASize=3664, FileAddr=1000, FileSize=4000

    section 1 – VA=6000, VASize=b3, FileAddr=5000, FileSize=1000

    section 2 – VA=8000, VASize=800, FileAddr=6000, FileSize=1000

    section 3 – VA=a000, VASize=c, FileAddr=7000, FileSize=1000

    Fail to read memory

    This assembly has been dynamically loaded like this:

    Assembly.Load(stream.ToArray());

    where stream is an instance of a MemoryStream which contains the assembly (which used to be a resource – this executable was packed with .NETZ)

    Do you happen to know the reason for this failure? Thanks in advance, for the millionth time!

  41. tomchris says:

    Pedro,

    It is hard to say based on that.  Can you show me the output from !dumpmodule?  Also, it would be easiest if I could take a look at the dump.  Would that be possible?

  42. Miguel says:

    Hi Tom,

    Thanks for the interest. I get the expected 403.13 error when the user sends a Revoked Client Certificate; the problem is that we are unable to redirect the user to any other HTTPS page within the site afterwards, if I try a redirect you get the same error page in every case; I never get a chance to "reestablish the SSL session", that is I can’t make the application proceed as if no Certificates were provided or make Internet Explorer present the "Choose certificate" dialog box again.

    Best regards

  43. tomchris says:

    And Pedro, when you execute the savemodule command, you are using .dll right?  You put:

    !savemodule 00925aa0 C:test.dump

    You meant:

    !savemodule 00925aa0 C:test.dll

    Right?

  44. tomchris says:

    Pedro,

    I got the files, won’t post the comment you left.  But I’ll let you know what I find out.

  45. tomchris says:

    Pedro,

    So I was able to reproduce this and see what is happening.  I also see what would need to be changed.  But SOS doesn’t change very often so this will probably have to wait until the next Service Pack or something.

  46. tomchris says:

    Miguel,

    Sounds like it’s by design and makes sense. If a new TCP connection is established, will IE just resend the same cert silently under the covers. If killing the TCP connection works, then a filter listening for the error could force the TCP connection closed. (can’t you just do this in a custom error page?) Another option would be to redirect to a non-SSL page to do the forms submission. That would implicitly cause a different TCP connection to be used, and you could then POST to an SSL URL to maintain security. Also, instead of using a redirect for the custom error page, how about a static HTML error page that contains client-side script to initiate a new connection, or otherwise contains text that gives the user instructions on what to manually do next. As for the filter option, you’d be looking for either the send response or end of request notifications and look at the http status.

  47. cnc says:

    I am trying to figure out a way to debug a windows forms control logic that is in a dll that was put into an aspx web page html object element, passing data between the user control and web page it is on.

    The windows forms control was created in its own solution.  The dll was copied to the aspx web page root level.  The dll was referenced in the aspx web page html object element, with passing data between the windows control and the aspx web page using paramaters and properties.  The windows control has textboxes and buttons.  The button logic accesses databases, etc.

    I need to debug the windows control while debugging the aspx web page.

    I have tried a lot of things but have not been successful.  I need to do this ASAP!  Any clues!

    cnc

  48. tomchris says:

    cnc,

    If you have the source for the control, you can add a Debug.Break command in there and so when you run it under a debugger, it will stop at that point.  Why are you wanting to use a windows form control on a web page.  That is normally not something you want to do.

  49. Is ultracet addictive. Ultracet.

  50. Michael Webb says:

    Has anyone ran into issue when debugging ASP.NET (VS 2005). New at a company and am the first with Vista laptop. What should happen is I sign in to the website from a URL as client or demo client to obtain login. Then go to VS run the application in debug to check my work. Well when I login into the URL It looks like it passes the login ASP page ok with permission as it call the Admin page I get a promt to login with a Window type dialog login. looks like its does this as it loads the client list grid.

    The Idea is to login through the ASP login page then a page comes up to select which Client you want to login as then select where you want to go in the application. Which it does not matter we are just wanting to obtain login status. Then we can go to VS and start debugging.

  51. tomchris says:

    Michael,

    You can check the IIS logs or a network trace to see what type of authentication is being passed.  Maybe the grid is using AJAX or something like that and has to make a request to another machine.  If you log in there, does it work correctly?

  52. Christopher says:

    I have a appliaction that uses Master Pages. Also I am also using a theme (in my web.config). There are some aspx pages in the application that have additional style requirements so is it possible to add a .css to an aspx. I do not want it in the theme because I do not want to carry the extra syle around with every page.

  53. tomchris says:

    Christopher,

    Yes you can add a .css file, it is the same as you would for a .htm file.

    Let me know if you have any questions.

  54. Bill says:

    I’ve a strange issue that just came up. I have a web site that I’ve created. I’ve done maintenance to it for over a year.

    Recently, I got a pop-up when starting to debug the code (f5) in VS 2005 with the latest service pack. The pop-up is the login screen for a SQL Server DB similar to when I configure a datasource object.

    I use the role and membership provider and handle authentication in code on a login page for this web app.

    Stranger still the default information was for an old configuration going to a DB I no longer use. I’ve searched the whole project and can’t find a reference anywhere to this old db instance.

    If I delete the Temporary ASP.NET File for this site and then run it, its fine for debugging till I get an exception in the debugger.

    Right after that, the next time I start to debug, I get the pop-up again. Clear the files, it goes away.

    Any suggestions on how I can PERMANENTLY fix this?

  55. Nice post. Just couldn’t stop reading it till finished. Was very helpful in removing the patches from my older applications. Keep posting. Will be visiting soon.