Yesterday I wrote about my Connection pooling tests and I had good comment from Marto Kulov about application domains.
It was easy so I wrote the following code to create new application domain and execute two forms from different assemblies in order to test if they share same connection pool
1: AppDomain domain = AppDomain.CreateDomain("myNewDomain");
2:
3: Form frm1 = domain.CreateInstanceFromAndUnwrap("WindowsApplication1.exe", "WindowsApplication1.Form1") as Form;
4: Form frm2 = domain.CreateInstanceFromAndUnwrap("WindowsApplication2.exe", "WindowsApplication2.Form1") as Form;
5:
6: frm1.Show();
7: frm2.Show();
And the answer is Yes, They share same connection pool. Both forms executed same for loop and opened 10 connections each to the MS SQL Server. And on the SQL Server side was only one connection alive.
So this is the way to share a connection pool between two processes - put them in one process and in one application domain.