replacing system.data

  • Thread starter Thread starter gilad
  • Start date Start date
G

gilad

Hi,
I would like to add some code to system.data so I can trace calls to
SqlConnection class. I used ildasm.exe, got the il code, added some of
mine and used the ilasm.exe to get a new assembly.

The problem is that I cannot remove the old file using the gacutil.exe
.... it says that it is required by other applications ...

How is it possible to remove system.data.dll from the gac or get my
task done in a different way?

Thanks,
Gilad.
 
System.Data is core part of MS..NET Framework, you really cannot remove it
with removing whole .NET framework. The question is, why do yuo want to
remove it? Are you saying that you develop your own ".NET framework" and you
want to replace MS .NET framework with yours? Probably not. If you developed
something, which is based on System.Data/MS .NET framework (that is most
..NET development do), you do not throw those your product based on away, you
nedd them in order for your product to work. If your product is developed
correctly and ready to be placed into GAC, just place it in, and have your
other .NET projects to use it, rather than directly using System.Data (if
your stuff is indeed a replacement of System.Data, but I really doudt it,
sorry.).
 
Hi Gilad,

It's a bad idea to replace System.Data.

Instead, create a class that wraps SqlConnection and trace the calls in
that. You'll have to use your wrapper class instead of SqlConnection
throughout your application:

public class TracedSqlConnection : DbConnection
{
private readonly SqlConnection connection;
private readonly string id;

public TracedSqlConnection(string id, string connectionString)
{
this.id = id;
this.connection = new SqlConnection(connectionString);
}

public override void Open()
{
System.Diagnostics.Trace.WriteLine("Calling Open()",
"TracedSqlConnection: " + id);

connection.Open();

System.Diagnostics.Trace.WriteLine("Open() called",
"TracedSqlConnection: " + id);
}

// TODO: remaining method implementations here
}
 
thanks all. I'm actually looking for a general way to know which msil
are about to run, which classes, methods and in runtime update the code
so I can get notifications for start/end of methods I'm interested in.

When using third party, it is possible to use ildasm to get the il.
then update it and use ilasm to generate a new assembly. But when it is
system files ... like system.data it is a problem. I read about
profiling api but it has too much overhead and there can only be one
instance running.

Gilad.
 
I want to be able to give reports on some db products that we use - how
many connections they are using, time in db etc ... stuff to help
figure out some problems. To do this, I need to hijack some of the Sql
classes in the system.data.

I'm surprised there is not enough data on this issue. I'm sure I'm not
the first or the last that want to do this.

Gilad.
 
Hi Gilad,

I agree with Paul's suggestion. There are performance counters for managed
and unmanaged code that can be viewed using the Performance Console utility
(perfmon) or directly in managed code using the PerformanceCounter class in
System.Diagnostics.

"PerformanceCounter Class"
http://msdn2.microsoft.com/en-us/library/system.diagnostics.performancecounter.aspx

"Runtime Profiling" (perfmon)
http://msdn2.microsoft.com/en-gb/library/w4bz2147(VS.80).aspx

Also, the RDBMS that you use will most likely provide proprietary tools for
viewing connectivity, information about transactions and other uses of the
system. Sql Server 2000 and Sql Server 2005 both supply administrative
tools for doing exactly that. One of the more useful tools, which is
separate from Enterprise Manager and the Sql Server Management Studio, is
the Sql Server Profiler.

"Using SQL Server Profiler"
http://msdn2.microsoft.com/en-us/library/ms187929.aspx
 
Back
Top