473,770 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Override existing class name with custom assembly?

Hi!

I have a rather special question here. I'd like to write a wrapper
for a .NET assembly, and register that on my server so that the people on
my server call my assembly instead of the standard .NET assembly. Reason
is that I want to include some additional security checks in my assembly,
to prevent everybody from the calling the .NET assembly unchecked. So,
writing the wrapper is no problem, but I'm not sure how/if it is possible
to register my assembly on the server to be called *instead* of the
original assembly, using the original name. So, e.g. if the customer
creates an instance of System.Data.Ole Db.OleDbCommand , I want an instance
from *my* System.Data.Ole Db.OleDbCommand to be created (that in turn will
eventually create an instance of the real System.Data.Ole Db.OleDbCommand ,
granted the caller will pass my security checks). I don't want the customer
to have to call something like System.Data.MyC ustomOleDb.OleD bCommand,
since my class won't be available at their client computer when they create
their apps, and it will be just easier otherwise.
I remember that achieving the above was no probelm with COM, but is it
possible in .NET as well?

TIA,

Thomas
Jul 21 '05 #1
15 2294
Thomas,
My understanding is the security built into .NET prevents this from
happening for largely the opposite reason then you are wanting it to happen.

In that with .NET security I cannot introduce an assembly that reduces the
security of the standard assemblies.

I cannot replace the System.Data.Ole Db.OleDbCommand with an object that will
bypass the System.Data.Ole Db.OleDbPermiss ion permissions.

For a good starting point on articles on .NET security see:
http://msdn.microsoft.com/library/de...rksecurity.asp

Hope this helps
Jay

"Thomas Christmann" <th************ ***@online.de> wrote in message
news:5t******** *************** ****@40tude.net ...
Hi!

I have a rather special question here. I'd like to write a wrapper
for a .NET assembly, and register that on my server so that the people on
my server call my assembly instead of the standard .NET assembly. Reason
is that I want to include some additional security checks in my assembly,
to prevent everybody from the calling the .NET assembly unchecked. So,
writing the wrapper is no problem, but I'm not sure how/if it is possible
to register my assembly on the server to be called *instead* of the
original assembly, using the original name. So, e.g. if the customer
creates an instance of System.Data.Ole Db.OleDbCommand , I want an instance
from *my* System.Data.Ole Db.OleDbCommand to be created (that in turn will
eventually create an instance of the real System.Data.Ole Db.OleDbCommand ,
granted the caller will pass my security checks). I don't want the customer to have to call something like System.Data.MyC ustomOleDb.OleD bCommand,
since my class won't be available at their client computer when they create their apps, and it will be just easier otherwise.
I remember that achieving the above was no probelm with COM, but is it
possible in .NET as well?

TIA,

Thomas

Jul 21 '05 #2
Thomas,
My understanding is the security built into .NET prevents this from
happening for largely the opposite reason then you are wanting it to happen.

In that with .NET security I cannot introduce an assembly that reduces the
security of the standard assemblies.

I cannot replace the System.Data.Ole Db.OleDbCommand with an object that will
bypass the System.Data.Ole Db.OleDbPermiss ion permissions.

For a good starting point on articles on .NET security see:
http://msdn.microsoft.com/library/de...rksecurity.asp

Hope this helps
Jay

"Thomas Christmann" <th************ ***@online.de> wrote in message
news:5t******** *************** ****@40tude.net ...
Hi!

I have a rather special question here. I'd like to write a wrapper
for a .NET assembly, and register that on my server so that the people on
my server call my assembly instead of the standard .NET assembly. Reason
is that I want to include some additional security checks in my assembly,
to prevent everybody from the calling the .NET assembly unchecked. So,
writing the wrapper is no problem, but I'm not sure how/if it is possible
to register my assembly on the server to be called *instead* of the
original assembly, using the original name. So, e.g. if the customer
creates an instance of System.Data.Ole Db.OleDbCommand , I want an instance
from *my* System.Data.Ole Db.OleDbCommand to be created (that in turn will
eventually create an instance of the real System.Data.Ole Db.OleDbCommand ,
granted the caller will pass my security checks). I don't want the customer to have to call something like System.Data.MyC ustomOleDb.OleD bCommand,
since my class won't be available at their client computer when they create their apps, and it will be just easier otherwise.
I remember that achieving the above was no probelm with COM, but is it
possible in .NET as well?

TIA,

Thomas

Jul 21 '05 #3
> I cannot replace the System.Data.Ole Db.OleDbCommand with an object that will
bypass the System.Data.Ole Db.OleDbPermiss ion permissions.


Is there a good reason why not? Is it strictly not possible, or is it just
that OleDbPermission s relies on OleDbCommand being there, and being named
like that? In which case I could maybe replace OleDbCommand as well...

Maybe I should clear this up a bit: My aim is not to really replace OleDb
completely, I just would like to have all ASP.NET calls to everything below
System.Data.Ole Db to be "routed" to *my* version of System.Data.Ole Db.*
(which would act like a proxy to the real System.Data.Ole Db). So, I don't
want to replace it, I just want to "hijack" it's name, system wide. In COM
this was easily acheived by just going to the registry and replacing the
value of the ProgID key of the old component with something like
"component. old" and giving your new component the original name of the old
component, in the same key, respectively. The new component would then
reference the old one by calling component.old, and system wide, the new
component would replace the old component (and would act like a proxy).
THIS I would like to achieve with .NET assemblies. Possible? If no, why
not? :-)

Thanks,

Thomas

Jul 21 '05 #4
> I cannot replace the System.Data.Ole Db.OleDbCommand with an object that will
bypass the System.Data.Ole Db.OleDbPermiss ion permissions.


Is there a good reason why not? Is it strictly not possible, or is it just
that OleDbPermission s relies on OleDbCommand being there, and being named
like that? In which case I could maybe replace OleDbCommand as well...

Maybe I should clear this up a bit: My aim is not to really replace OleDb
completely, I just would like to have all ASP.NET calls to everything below
System.Data.Ole Db to be "routed" to *my* version of System.Data.Ole Db.*
(which would act like a proxy to the real System.Data.Ole Db). So, I don't
want to replace it, I just want to "hijack" it's name, system wide. In COM
this was easily acheived by just going to the registry and replacing the
value of the ProgID key of the old component with something like
"component. old" and giving your new component the original name of the old
component, in the same key, respectively. The new component would then
reference the old one by calling component.old, and system wide, the new
component would replace the old component (and would act like a proxy).
THIS I would like to achieve with .NET assemblies. Possible? If no, why
not? :-)

Thanks,

Thomas

Jul 21 '05 #5
JD
> Is there a good reason why not? Is it strictly not possible, or is it just
that OleDbPermission s relies on OleDbCommand being there, and being named
like that? In which case I could maybe replace OleDbCommand as well...
Security.

If someone was using an existing method in OleDB type that did this:

Begin SomeMethod
Demand Permissions
If Demand OK Then do secure action
End SomeMethod

Now you replace the assembly and SomeMethod with your own version:

Begin SomeMethod
do secure action
End SomeMethod

This is a security breach, no?

Not to mention when .NET applications are built, the resulting manifest
contains which assemblies its dependent upon, along with versions, along
with public key tokens.

The better thing to do is have your clients rely on the standard data
provider interfaces instead, use the factory pattern which can be configured
to pass back your objects or OleDB objects.
"Thomas Christmann" <th************ ***@online.de> wrote in message
news:9n******** *************** *****@40tude.ne t...
I cannot replace the System.Data.Ole Db.OleDbCommand with an object that will bypass the System.Data.Ole Db.OleDbPermiss ion permissions.


Is there a good reason why not? Is it strictly not possible, or is it just
that OleDbPermission s relies on OleDbCommand being there, and being named
like that? In which case I could maybe replace OleDbCommand as well...

Maybe I should clear this up a bit: My aim is not to really replace OleDb
completely, I just would like to have all ASP.NET calls to everything

below System.Data.Ole Db to be "routed" to *my* version of System.Data.Ole Db.*
(which would act like a proxy to the real System.Data.Ole Db). So, I don't
want to replace it, I just want to "hijack" it's name, system wide. In COM
this was easily acheived by just going to the registry and replacing the
value of the ProgID key of the old component with something like
"component. old" and giving your new component the original name of the old
component, in the same key, respectively. The new component would then
reference the old one by calling component.old, and system wide, the new
component would replace the old component (and would act like a proxy).
THIS I would like to achieve with .NET assemblies. Possible? If no, why
not? :-)

Thanks,

Thomas

Jul 21 '05 #6
> Begin SomeMethod
Demand Permissions
If Demand OK Then do secure action
End SomeMethod

Now you replace the assembly and SomeMethod with your own version:

Begin SomeMethod
do secure action
End SomeMethod

This is a security breach, no?
Well, yes, I understand this would be a security breach, but I was looking
more for why it isn't allowed. Technically, I mean. What prevents it? CAS?
Something deep inside the assembly itself?
Not to mention when .NET applications are built, the resulting manifest
contains which assemblies its dependent upon, along with versions, along
with public key tokens.
Ah okay, key tokens, that I understand. Okay, thats a reason it wouldn't
work, true.
The better thing to do is have your clients rely on the standard data
provider interfaces instead, use the factory pattern which can be configured
to pass back your objects or OleDB objects.


Well, I can't really use OleDB. See, the scenario is that I host ASP.NET
applications on my server, but I don't want to run full trust.
Unfortunately OleDB only works with full trust. So, an article on the MS
website explained that you could write a wrapper around some OleDB
functionality, then register that in gac (to be run under full trust), and
call the (full trusted, globally available) assembly from ASP.NET
applications running under partial trust. Now, this works just fine, I bet,
but the ultimate goal would be to give my clients the convinience of not
having to use my stuff, but the MS stuff instead (from their point of
view).

Ciao,

Thomas
Jul 21 '05 #7
Thomas,
I'm not sure what the full reason is. Nor if you really can or cannot do
it.

I believe you missed my point, one very good reason to prevent it is
security, as JD explained, and I attempted to explain. What you are
attempting to do is how one might bypass security.

Just a thought
Jay

"Thomas Christmann" <th************ ***@online.de> wrote in message
news:9n******** *************** *****@40tude.ne t...
I cannot replace the System.Data.Ole Db.OleDbCommand with an object that will bypass the System.Data.Ole Db.OleDbPermiss ion permissions.
Is there a good reason why not? Is it strictly not possible, or is it just
that OleDbPermission s relies on OleDbCommand being there, and being named
like that? In which case I could maybe replace OleDbCommand as well...

Maybe I should clear this up a bit: My aim is not to really replace OleDb
completely, I just would like to have all ASP.NET calls to everything

below System.Data.Ole Db to be "routed" to *my* version of System.Data.Ole Db.*
(which would act like a proxy to the real System.Data.Ole Db). So, I don't
want to replace it, I just want to "hijack" it's name, system wide. In COM
this was easily acheived by just going to the registry and replacing the
value of the ProgID key of the old component with something like
"component. old" and giving your new component the original name of the old
component, in the same key, respectively. The new component would then
reference the old one by calling component.old, and system wide, the new
component would replace the old component (and would act like a proxy).
THIS I would like to achieve with .NET assemblies. Possible? If no, why
not? :-)

Thanks,

Thomas

Jul 21 '05 #8
Thomas,
Oh! another reason to prevent it, your assembly could introduce
instabilities in the framework.

I can here the calls to MS Support now. I'm using OleDbCOmmand on my machine
and it works fine, I deploy it to my ISP and I get a Argument Out Of Range
exception. (as your wrapper had a slight flaw in it, that you did not
catch...)

If you find it documented how to do it, I hope you will post here.

Just another thought
Jay

"Thomas Christmann" <th************ ***@online.de> wrote in message
news:9n******** *************** *****@40tude.ne t...
I cannot replace the System.Data.Ole Db.OleDbCommand with an object that will bypass the System.Data.Ole Db.OleDbPermiss ion permissions.
Is there a good reason why not? Is it strictly not possible, or is it just
that OleDbPermission s relies on OleDbCommand being there, and being named
like that? In which case I could maybe replace OleDbCommand as well...

Maybe I should clear this up a bit: My aim is not to really replace OleDb
completely, I just would like to have all ASP.NET calls to everything

below System.Data.Ole Db to be "routed" to *my* version of System.Data.Ole Db.*
(which would act like a proxy to the real System.Data.Ole Db). So, I don't
want to replace it, I just want to "hijack" it's name, system wide. In COM
this was easily acheived by just going to the registry and replacing the
value of the ProgID key of the old component with something like
"component. old" and giving your new component the original name of the old
component, in the same key, respectively. The new component would then
reference the old one by calling component.old, and system wide, the new
component would replace the old component (and would act like a proxy).
THIS I would like to achieve with .NET assemblies. Possible? If no, why
not? :-)

Thanks,

Thomas

Jul 21 '05 #9
JD
> What prevents it? CAS?

Yep.
Unfortunately OleDB only works with full trust.
No kidding. I never realized this or ran into a problem because of it.

"Thomas Christmann" <th************ ***@online.de> wrote in message
news:53******** *************** *******@40tude. net...
Begin SomeMethod
Demand Permissions
If Demand OK Then do secure action
End SomeMethod

Now you replace the assembly and SomeMethod with your own version:

Begin SomeMethod
do secure action
End SomeMethod

This is a security breach, no?


Well, yes, I understand this would be a security breach, but I was looking
more for why it isn't allowed. Technically, I mean. What prevents it? CAS?
Something deep inside the assembly itself?
Not to mention when .NET applications are built, the resulting manifest
contains which assemblies its dependent upon, along with versions, along
with public key tokens.


Ah okay, key tokens, that I understand. Okay, thats a reason it wouldn't
work, true.
The better thing to do is have your clients rely on the standard data
provider interfaces instead, use the factory pattern which can be configured to pass back your objects or OleDB objects.


Well, I can't really use OleDB. See, the scenario is that I host ASP.NET
applications on my server, but I don't want to run full trust.
Unfortunately OleDB only works with full trust. So, an article on the MS
website explained that you could write a wrapper around some OleDB
functionality, then register that in gac (to be run under full trust), and
call the (full trusted, globally available) assembly from ASP.NET
applications running under partial trust. Now, this works just fine, I

bet, but the ultimate goal would be to give my clients the convinience of not
having to use my stuff, but the MS stuff instead (from their point of
view).

Ciao,

Thomas

Jul 21 '05 #10

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

Similar topics

18
4761
by: Robin Becker | last post by:
Is there a way to override a data property in the instance? Do I need to create another class with the property changed? -- Robin Becker
7
6449
by: Dave Y | last post by:
I am a newbie to C# and am having trouble trying to override a ListView property method. I have created a new class derived from the Forms.Listview and I cannot figure out the syntax to override ListView.Items.Add(), . I see that it is a virtual method so it should be easy to do. If anyone can help I would appreciate it greatly. I can do what I need to do in a different way this would just make everything significantly cleaner and eaasier...
11
1800
by: songie D | last post by:
Does c# support overriding by name and not signature For instance I am building a custom collection class, that ca only take a certain type of object For this, I have added an override for add from the class view and changed it fro public int Add(object value t public int Add(MyItemClass value This seems to work, but it generates a warning 'the new specifier is needed
3
2298
by: Kishore Gopalan | last post by:
Hi, I have the following class. Assembly: A.dll public class Customers { public Customer customer; } public class Customer { public string name;
6
1405
by: Dave | last post by:
We have developed a few .NET components. The application access these components through well defined interface IOurInterface. The application list display name of each component in the dialog, so user can choose which one he wants to use. To display list of available components we have to associate human redable display name with each component. To get that display name of component we added the method GetDisplayName to IOurInterface.
3
12181
by: Michael Bøcker-Larsen | last post by:
Hi I'v been stuck on this problem for ages now. I have found that I'm not the only one with this problem, by looking through the different newsgroups. Hope you can help me! I know there is a lot of information, but if you need more (e.g. the code) please write michael@mblarsen.dk. The problem is this error messages (the code is build just fine; no errors):
13
381
by: Thomas Christmann | last post by:
Hi! I have a rather special question here. I'd like to write a wrapper for a .NET assembly, and register that on my server so that the people on my server call my assembly instead of the standard .NET assembly. Reason is that I want to include some additional security checks in my assembly, to prevent everybody from the calling the .NET assembly unchecked. So, writing the wrapper is no problem, but I'm not sure how/if it is possible to...
0
9617
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10257
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10099
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10037
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.