Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / November 2006

Tip: Looking for answers? Try searching our database.

replacing system.data

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gilad - 26 Nov 2006 13:29 GMT
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.
Norman Yuan - 26 Nov 2006 15:35 GMT
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,
> I would like to add some code to system.data so I can trace calls to
[quoted text clipped - 9 lines]
> Thanks,
> Gilad.
Dave Sexton - 27 Nov 2006 04:07 GMT
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
}

Signature

Dave Sexton

> Hi,
> I would like to add some code to system.data so I can trace calls to
[quoted text clipped - 9 lines]
> Thanks,
> Gilad.
gilad - 27 Nov 2006 07:28 GMT
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.
Dave Sexton - 27 Nov 2006 07:52 GMT
Hi Gilad,

Out of curiousity, why do you want this functionality?

Signature

Dave Sexton

> 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
[quoted text clipped - 7 lines]
>
> Gilad.
gilad - 27 Nov 2006 08:35 GMT
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.
Paul - 27 Nov 2006 11:55 GMT
What's wrong with the Management tools that perfmon gives you for doing
this?

>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
[quoted text clipped - 5 lines]
>
> Gilad.
Dave Sexton - 27 Nov 2006 16:06 GMT
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

Signature

Dave Sexton

>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
[quoted text clipped - 5 lines]
>
> Gilad.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.