Welcome to MSDN Blogs Sign in | Join | Help

Browse by Tags

All Tags » .NetFramework   (RSS)

Getting where the exception is thrown in Windows Error Report for managed application without a dump

A while ago, an internal thread shows how to get where the exception is thrown in Windows Error Report for managed application without a dump. The thread is very insightful. Shared below: Subject: RE: How to investigate Windows Error Report from managed
Posted by junfeng | 0 Comments
Filed under:

Be careful about exception after resource allocation

The following is a common code pattern Resource resource = GetResource(); DoWork(); return resource; If DoWork() throws exception, the resource will be leaked. We need to guard against this. For example bool success = false ; Resource resource = GetResource();
Posted by junfeng | 6 Comments
Filed under:

Exception Filter

C# does not support exception filter. However, VB and IL support it. To add exception filter to C#, we can build a function in VB or IL, then call it in C#. The example below is one way we may implement the function to support exception filter. It asks
Posted by junfeng | 7 Comments
Filed under:

ThreadPool.BindHandle

I mentioned that we can use ThreadPool.BindHandle to implement asynchronous IO. Here are roughly the steps necessary to make it happen: 1. Create an overlapped file handle SafeFileHandle handle = CreateFile( filename, Win32.GENERIC_READ_ACCESS, Win32.FILE_SHARE_READ
Posted by junfeng | 8 Comments
Filed under:

ThreadPool.UnsafeQueueNativeOverlapped

CLR’s thread pool has two pools of threads. The first pool is used by ThreadPool.QueueUserWorkItem . The second pool is an IoCompletionPort thread pool used by ThreadPool.BindHandle and ThreadPool.UnsafeQueueNativeOverlapped . ThreadPool.BindHandle is
Posted by junfeng | 3 Comments
Filed under:

Conversion between System.String and char *

We can convert a char * to System.String with System.String’s constructor string str = new string((char*)p); And for the reverse: fixed(char *p = str){} Why do we care about conversion between System.String and char *? From this article , this is the
Posted by junfeng | 3 Comments
Filed under:

Managed ThreadPool vs Win32 ThreadPool (pre-Vista)

The following is a conversation between me and a CLR dev. The conversation is very informative so I quote it here. From: Sent: To: Subject: RE: ThreadPool.QueueUserWorkItem There might be some confusion here around the meaning of the term "I/O Thread."
Posted by junfeng | 5 Comments
Filed under:

Event Handles “leak”

On our stress run, we saw our process’ handle count steadily increases until certain point, then it stabilizes. However the number of handles is high. Most of those handles are Event handles. We are concerned about it. So we went off and did some investigation.
Posted by junfeng | 3 Comments
Filed under: ,

Consider Creating a new class for locking

C# provides keyword lock for synchronized access. A good practice is to create a private object for locking purpose. For example, public class LockExample { private object syncObject = new object (); public void SynchronizedMethod() { lock (syncObject)
Posted by junfeng | 5 Comments
Filed under:

A case study of a NullReferenceException

We are seeing a NullReferenceException in our stress program. The investigation process may be helpful to some folks. Thread 22 is showing a Watson dialog. This is a register corruption. 0:022> kp ChildEBP RetAddr 091bc9a0 76961220 ntdll!ZwWaitForSingleObject(void)+0x15
Posted by junfeng | 3 Comments
Filed under: ,

App Config’s root element should be namespace-less

The root element for Application config file is <configuration> <?xml version="1.0" encoding="utf-8" ?> <configuration > </configuration> The application config file is shared with CLR and Windows SxS. SxS dictates
Posted by junfeng | 0 Comments
Filed under: ,

Calculating the size of each GC generation

Sos.dll does not have a command to tell the size of each GC generation. However, you can calculate the size based on the output of !eeheap -gc. For example, 0:000> !eeheap -gc Number of GC Heaps: 1 generation 0 starts at 0x1da6c430 generation 1 starts
Posted by junfeng | 2 Comments
Filed under: ,

Figuring out object allocation graph from a managed memory dump

when debugging a managed memory dump, we can use Sos.dll to inspect managed objects inside the dump. for example, we can do !dumpheap to list the managed objects in GC Heap, we can also use !gcroot to figure out the reference path to a particular object.
Posted by junfeng | 2 Comments
Filed under: ,

Reverse P/Invoke and exception

P/Invoke is managed code executing a native function pointer. And Reverse P/Invoke is native code executing a managed delegate as a function pointer, mostly as a callback. When the native code executes the managed delegate function pointer, the call really
Posted by junfeng | 3 Comments
Filed under:

Assembly Loading and Authorization

CLR does not do anything special regarding authorization during assembly loading. It will try to access the file under the current user. However, if an assembly is already loaded, next time when the assembly is requested, CLR will return the assembly
Posted by junfeng | 0 Comments
Filed under: ,
More Posts Next page »
 
Page view tracker