473,396 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Extendind/hooking system dll's

Hello,

I am looking for a way to extend system classes (specifically I'm
talking about data provider connection classes such as
System.Data.SqlConnection, System.Data.OracleConnection).

What I need is to add custom pre-processing before call to some of teh
methods. I would like to minimize the code changes of the application
that uses these classes.

The problem is that these system classes are defnied as sealed so I
cannot simply extend them.

Do you have any idea how can I extended these classes and more
generally how can I hook system classes?

Regards,
Yair

Jul 22 '07 #1
4 1586
* ya*******@yahoo.com wrote, On 22-7-2007 16:08:
Hello,

I am looking for a way to extend system classes (specifically I'm
talking about data provider connection classes such as
System.Data.SqlConnection, System.Data.OracleConnection).

What I need is to add custom pre-processing before call to some of teh
methods. I would like to minimize the code changes of the application
that uses these classes.

The problem is that these system classes are defnied as sealed so I
cannot simply extend them.

Do you have any idea how can I extended these classes and more
generally how can I hook system classes?

Regards,
Yair
You could 'wrap' them. Implement IDBConnection, put a SqlConnection in
your class as private field and forward every call & property. This
also gives you a nice processing point.

Jesse
Jul 22 '07 #2
On Jul 22, 5:48 pm, Jesse Houwing <jesse.houw...@nospam-sogeti.nl>
wrote:
* yairin...@yahoo.com wrote, On 22-7-2007 16:08:


Hello,
I am looking for a way to extend system classes (specifically I'm
talking about data provider connection classes such as
System.Data.SqlConnection, System.Data.OracleConnection).
What I need is to add custom pre-processing before call to some of teh
methods. I would like to minimize the code changes of the application
that uses these classes.
The problem is that these system classes are defnied as sealed so I
cannot simply extend them.
Do you have any idea how can I extended these classes and more
generally how can I hook system classes?
Regards,
Yair

You could 'wrap' them. Implement IDBConnection, put a SqlConnection in
your class as private field and forward every call & property. This
also gives you a nice processing point.

Jesse- Hide quoted text -

- Show quoted text -
Hi,
I thought about that idea but I found the following drawbacks:

1. The database specific classes (e.g. SqlConnection,
OracleConnecitoon) may have database specific methods and wrapping
IDBConnection may cause loss of functionallity
2. My applicaiton currently work with SqlConneciton/OracleConection
classes. Since the new class is not superclass of these classes, I
cannot move it as arguments to methods that expect it. I could
implement casting and returning the private field but doing so will
bypass my wrapping.

What I am acutally need as a way to "bypass" the sealed...

Do you have any ideas?

Yair

Jul 22 '07 #3
Yair,

Quite simply, if the class is sealed, then you can't do anything. The
best thing you could do in the case of the provider classes is implement the
interface classes that all data providers use (IDbCommand, IDbConnection)
and code your app to use those. Then, you can basically host instances of
the sealed database classes inside of your interface implementations, and
perform the calls as you wish).

I am curious, what kind of interception do you need to perform?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ya*******@yahoo.comwrote in message
news:11**********************@g4g2000hsf.googlegro ups.com...
Hello,

I am looking for a way to extend system classes (specifically I'm
talking about data provider connection classes such as
System.Data.SqlConnection, System.Data.OracleConnection).

What I need is to add custom pre-processing before call to some of teh
methods. I would like to minimize the code changes of the application
that uses these classes.

The problem is that these system classes are defnied as sealed so I
cannot simply extend them.

Do you have any idea how can I extended these classes and more
generally how can I hook system classes?

Regards,
Yair
Jul 23 '07 #4
On Jul 23, 4:49 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Yair,

Quite simply, if the class is sealed, then you can't do anything. The
best thing you could do in the case of the provider classes is implement the
interface classes that all data providers use (IDbCommand, IDbConnection)
and code your app to use those. Then, you can basically host instances of
the sealed database classes inside of your interface implementations, and
perform the calls as you wish).

I am curious, what kind of interception do you need to perform?

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

<yairin...@yahoo.comwrote in message

news:11**********************@g4g2000hsf.googlegro ups.com...
Hello,
I am looking for a way to extend system classes (specifically I'm
talking about data provider connection classes such as
System.Data.SqlConnection, System.Data.OracleConnection).
What I need is to add custom pre-processing before call to some of teh
methods. I would like to minimize the code changes of the application
that uses these classes.
The problem is that these system classes are defnied as sealed so I
cannot simply extend them.
Do you have any idea how can I extended these classes and more
generally how can I hook system classes?
Regards,
Yair- Hide quoted text -

- Show quoted text -
Hi,

I guess that the solution you suggested will require mass code change.
For example - if currently my connection object is defined as
OracleConnection, I'll now have to change it to MyConnection.

I needed to add transparent logging capabiliies to the Open() of
DbConnection method. I wanted it to work with the need to change all
may apps.

Yair

Jul 23 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: hector | last post by:
We have a RPC based client/server hosting system (Wildcat!). Various RPC clients include FTP, TELNET, DIALUP as well as WEB server. Each use a RPC SDK/API to communicate with the central RPC...
3
by: Seth Gecko | last post by:
Hi I want to make an application (in C#) that can catch text written to a Richedit control in another application. Using Spy++ I can see that the message I want to intercept is called...
1
by: TMP | last post by:
Below is the code snippet that I'm having problems with, the hook seems to work (hookResult returns a value other than zero) but then explorer crashes.Also I'm aware of the fact that instead of...
2
by: Dave A | last post by:
I am stuggling with databinding a drop down list, hooking into the SelectedIndexChanged and attempting to avoid using the viewstate. The drop down list is quite large so I would prefer to avoid...
1
by: kmslick | last post by:
Hello all. Not sure which group this problem best relates to, so I'm posting to both with a follow up. I started learning C# and .NET last august for a project for my employer. The project...
12
by: pigeonrandle | last post by:
Hi, Is it possible to hook another application's WM_MOVE messages using c#? There seems to be some argument as to what messages you can hook and whether you can listen in on other app's messages...
8
by: pigeonrandle | last post by:
Hi, Has anyone had any experience with hooking messages in other application windows (like SPY++). I want to listen for WM_MOVE messages, but can only seem to find examples of Keyboard and Mouse...
0
by: joemango | last post by:
Hi everyone, I was just reading the following artilce titled: "Spy: A Windows CE API Interceptor" by Dmitri Leman in Dr. Dobbs Journal, September 02, 2003 located at ...
6
by: pigeonrandle | last post by:
Hi, I want to create a dll in Visual Studio 2003 that is suitable for hooking thread-specific messages. What sort of project do i need to create for this? Many thanks, James Randle.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.