Calling delegates using BeginInvoke, Invoke, DynamicInvoke and delegate

I wanted to write about delegates this month. There are different ways in which you can invoke delegates to get either a synchronous or an asynchronous behavior. But from what I noticed, the delegate model provides you very less control when you invoke it asynchronously. The caller cannot easily abort or terminate the operation.  …


Posting from word

I was cutting and pasting from word till now to post. It was long in my list to try and use word and see how that works and it works great. Column1 Column2 Column3 Row2 Row2 Row2   I look forward to using this.


Why is generic constructor not allowed?

Generic argument is not allowed in the constructor. When I compile the code below I get a compilation error saying:   error CS1519: Invalid token ‘(‘ in class, struct, or interface         member declaration   The reason is simple. You can have a class Foo<T> and a class Foo as described in my previous post….


Same name for a generic and non-generic class

  I was writing a sample to do something and I noticed that when I declare and instantiate a generic class, I had to pass the generic type in two places: 1.  Foo<Int32> fooGenericInstance; 2.  FooGenericInstance = new Foo<Int32>();   First I was not sure why I had to pass the type is two places….


New role within Microsoft

After almost two years with the CLR team I have decided to move on and take new challenges. I have joined the Exchange Hosted Services team as a Development Lead starting today. I will continue to blog about what I understand and know about the CLR. I will also blog about what I learn in…


MSDN article about COM Connection Points and managed client

I wrote my second article in MSDN which got published in the September issue. This article is about “COM Connection Points“. It gives an overview of COM connection points and explains how to use the same managed code. You can find the article here.


Managed C++ and C#

I tried writing a sample to use managed C++ to interact with managed code and here is my learning. I created the following managed C++ code to wrap existing FLAT API’s in a class that can be called form C#. Managed C++ code: #using <mscorlib.dll> #include <vcclr.h> using namespace System; #include <stdio.h> #include <wchar.h>  …


How to control the version of .NET Framework your application runs against?

Let us look at a small sample that illustrated how this configuration entry works. using System; class Sample {     public static void Main()     {         Console.WriteLine(“This is a sample”);     } }   Let us copy this code to RequireRuntime.cs and compile it. Let us now add a configuration file RequiredRuntime.exe.config which has…


Debugging load problems using fusion log

Fusion log comes in very handy when you want to understand or debug binding behaviors. Let us take the sample code below. Copy the code to DomSample.cs and compile it. Let us assume for now that the code tries to load some arbitrary assembly “Foo” which does not exist. If you run this code you…


PInvoke-Reverse PInvoke and __stdcall – __cdecl

I came across this issue yesterday and thought that I will blog about the same. The example below demonstrates a simple PInvoke and Reverse PInvoke through delegates. The initial call was defined to use the __cdecl convention. As you can notice when executing the code the stack gets corrupted and the for loop ends prematurely….