Showing posts with label vb.net. Show all posts
Showing posts with label vb.net. Show all posts

Sunday, April 21, 2013

clr20r3 P9 system.componentmodel.win32 : Handling unhandled exceptions

The problem : An Application that doesn't start


Happened to come across an older (read dot net 2.0) application which , due to some reason started to misbehave. whenever it is started it said "App has encountered a problem and needs to close. We are sorry for the inconvenience". There are no other details and the only point of hope was the windows log which said.

EventType clr20r3, P1 app_name.exe, P2 1.1.2.0, P3 4f1ea58b, P4 system, P5 2.0.0.0, P6 4889de7a, P7 3839, P8 131, P9 system.componentmodel.win32, P10 NIL.

I was also told by the dev guys that the application is having its own error log which does not show any entry of this error and also the infamous excuse of "It worked yesterday."   and "It is working fine on my machine."


The source


Going through the source code , found that all the methods had try catch blocks with exception logging configured to log everything including stack trace. Even all the line of codes inside the static Main() were enclosed in a try catch.


The Solution


Since there was no handler for unhandledexception written, the same was added just inside the Main()

           AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(delegate(object sender, UnhandledExceptionEventArgs e)
                {
                  if (e.IsTerminating)
                  {
                      object o = e.ExceptionObject;
                      MessageBox.Show(o.ToString()); // use EventLog instead
                  }
                }
            );



This snippet makes sure that no exceptions are unhandled from your side. [On a lighter note, the root cause here in this case was revealed to be an error log which grew out of size]
I suggest the usage of this handler for trapping any exception that stays unhandled.


Understanding the error log [Watson buckets]



For Breaking up the windows error log entry
EventType clr20r3, P1 app_name.exe, P2 1.1.2.0, P3 4f1ea58b, P4 system, P5 2.0.0.0, P6 4889de7a, P7 3839, P8 131, P9 system.componentmodel.win32, P10 NIL.
The entries P1 ,P2 ,P3 etc are the details collected by the system regarding the exception that went unhandled. They are known as Watson buckets. They include the following information


  1. Executable
  2. Assembly version number
  3. File Stamp
  4. Full assembly name
  5. Faulting assembly version
  6. Faulting assembly timestamp
  7. Faulting assembly method def
  8. IL Offset within the faulting method
  9. Exception type




Hopes this helps someone, someday, some time...
Happy Programming...



Thursday, December 8, 2011

Map Network Drive using C# / Vb.net code

This post will show you an easier way to map a network drive using dot net code. you are free to use any .net language of your choice. I will be mostly sticking to C# though.

We will be relying on COM Interop for this and we will be referencing the Windows Script Host Object Model for this task. Lets get going....

  • Step 1.
Open your choice of application project. In this case I am opening a new Windows Forms Application in C#. And you are there on the default form :Form1.

  • Step 2.
Add a new reference.
In Solution Explorer, right click on References and Click on Add reference.

Select the COM tab.

Scroll down and select Windows Script Host Object Model
Now the solution explorer will look like this with an IWshRuntimeLibrary added.

Now you are ready to go.

  • Step 3.
Write Code.
Go to the code window. select your required event [button click or form load or just anything].
Create an instance of the class IWshNetwork_Class
Call the MapNetworkDrive method and you are done.

  • Sample Code
IWshNetwork_Class network = new IWshNetwork_Class();
network.MapNetworkDrive("k:",@"\\192.168.20.35\MyShare", Type.Missing, "user1", "password1");

you can use the following code to UnMap or remove the mapping.

network.RemoveNetworkDrive("k:");

Hope this saves some time for you....
Happy Programming...

Monday, June 8, 2009

Coolite : ExtJS + ASP.Net

Every one agrees that using Ajax in ASP.Net is cool. And even cooler if you can use third party javascript/Ajax frameworks. A number of people had asked me whether there is an easy solution to use extJs framework in ASP.Net. So I thought of writing something about that here.

ExtJS is an excellent framework by itself , But a cooler way to integrate it with ASP.Net exists. Enter Coolite Toolkit. Coolite toolkit is A suite of professional ASP.NET AJAX Web Controls
built on the ExtJS JavaScript Framework. The project is in development phase and the current release [as of June 2009] is version 0.8. The control kit is dual licensed and is available in GPL and also with a commercial license.

The Library consists of a vast collection of UI components starting from buttons and datepickers to treeviews, Grid panels , Messageboxes and a Desktop control. You can see them live at Coolite Example Explorer. The controls are easy to use [you need to have a look at their examples to know how to use them and better if you can find time to read the documentation] and intuitive and they offer community help through their forum also.

Another interesting thing that i found with the library is the use of [AjaxMethod] Attribute . By using it you can call any server side method from a javascript function without any flicker/postback and the same is done using Ajax and JSON.

Do find some time to explore this toolkit.