473,473 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Object instantiation notification, AppDomain, Reflection

I am inquiring about the feasability of being able to determine when an
object of a certain type is instantiated.

I have a base type that I want to be able to determine when each instance is
created in an assembly. Can this be done using Reflection or AppDomain?

I'm trying to detect these instances automatically for some security settings.
Any help would be greatly appreciated.
Jul 21 '05 #1
7 1683
"Dave L" <Dave L@discussions.microsoft.com> wrote in message
news:80**********************************@microsof t.com...
I am inquiring about the feasability of being able to determine when an
object of a certain type is instantiated.

I have a base type that I want to be able to determine when each instance
is
created in an assembly. Can this be done using Reflection or AppDomain?

I'm trying to detect these instances automatically for some security
settings.
Any help would be greatly appreciated.


You could put this checking code in the default constructor of the base
type, couldn't you?

John Saunders
Jul 21 '05 #2
The ultimate goal would to put something in the constructor of the base class
so that I could hook into the assembly from an outside security module that
would look for or monitor this "something" in the base class constructor or
just detect when an object of the base class type is created in any assembly.

I don't want to probe the assembly for an object reference to the base class
type, I want the instantiation of the base class to be discovered
automatically in the monitored assembly.

"John Saunders" wrote:
"Dave L" <Dave L@discussions.microsoft.com> wrote in message
news:80**********************************@microsof t.com...
I am inquiring about the feasability of being able to determine when an
object of a certain type is instantiated.

I have a base type that I want to be able to determine when each instance
is
created in an assembly. Can this be done using Reflection or AppDomain?

I'm trying to detect these instances automatically for some security
settings.
Any help would be greatly appreciated.


You could put this checking code in the default constructor of the base
type, couldn't you?

John Saunders

Jul 21 '05 #3
"Dave L" <Dave L@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com...
The ultimate goal would to put something in the constructor of the base
class
so that I could hook into the assembly from an outside security module
that
would look for or monitor this "something" in the base class constructor
or
just detect when an object of the base class type is created in any
assembly.

I don't want to probe the assembly for an object reference to the base
class
type, I want the instantiation of the base class to be discovered
automatically in the monitored assembly.
Ok, let's break this down a bit.

You have a "security module" that wants to monitor things. You've got a base
class which is the base type for all of the things to be monitored, am I
right?

I presume that you want the "security module" to be able to run in a
separate AppDomain from the instances of the classes derived from the base?
The "security module" should be able to monitor instances from multiple
AppDomains? Possibly even from remote AppDomains?

Have you looked into the System.Management namespace? This sounds a lot like
WMI.

John Saunders

"John Saunders" wrote:
"Dave L" <Dave L@discussions.microsoft.com> wrote in message
news:80**********************************@microsof t.com...
>I am inquiring about the feasability of being able to determine when an
> object of a certain type is instantiated.
>
> I have a base type that I want to be able to determine when each
> instance
> is
> created in an assembly. Can this be done using Reflection or
> AppDomain?
>
> I'm trying to detect these instances automatically for some security
> settings.
> Any help would be greatly appreciated.


You could put this checking code in the default constructor of the base
type, couldn't you?

John Saunders

Jul 21 '05 #4
"Dave L" <Dave L@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com...
The ultimate goal would to put something in the constructor of the base
class
so that I could hook into the assembly from an outside security module
that
would look for or monitor this "something" in the base class constructor
or
just detect when an object of the base class type is created in any
assembly.

I don't want to probe the assembly for an object reference to the base
class
type, I want the instantiation of the base class to be discovered
automatically in the monitored assembly.


P.S. See
http://msdn.microsoft.com/library/en...management.asp

John Saunders
Jul 21 '05 #5
Yes, you have the senario correct. I will have this security module (.dll)
running by the host application (.exe) that needs to monitor other known
modules (.dll's) in the scope of the AppDomain, and look for instantiations
of this particular base type. Then apply some permissions to the base types
interface on whether or not the current user has permission to use this base
type.

I'm not familiar with System.Management and I will read more, thanks for
your help John.

"John Saunders" wrote:
"Dave L" <Dave L@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com...
The ultimate goal would to put something in the constructor of the base
class
so that I could hook into the assembly from an outside security module
that
would look for or monitor this "something" in the base class constructor
or
just detect when an object of the base class type is created in any
assembly.

I don't want to probe the assembly for an object reference to the base
class
type, I want the instantiation of the base class to be discovered
automatically in the monitored assembly.


Ok, let's break this down a bit.

You have a "security module" that wants to monitor things. You've got a base
class which is the base type for all of the things to be monitored, am I
right?

I presume that you want the "security module" to be able to run in a
separate AppDomain from the instances of the classes derived from the base?
The "security module" should be able to monitor instances from multiple
AppDomains? Possibly even from remote AppDomains?

Have you looked into the System.Management namespace? This sounds a lot like
WMI.

John Saunders

"John Saunders" wrote:
"Dave L" <Dave L@discussions.microsoft.com> wrote in message
news:80**********************************@microsof t.com...
>I am inquiring about the feasability of being able to determine when an
> object of a certain type is instantiated.
>
> I have a base type that I want to be able to determine when each
> instance
> is
> created in an assembly. Can this be done using Reflection or
> AppDomain?
>
> I'm trying to detect these instances automatically for some security
> settings.
> Any help would be greatly appreciated.

You could put this checking code in the default constructor of the base
type, couldn't you?

John Saunders


Jul 21 '05 #6
"Dave L" <Da***@discussions.microsoft.com> wrote in message
news:1C**********************************@microsof t.com...
Yes, you have the senario correct. I will have this security module
(.dll)
running by the host application (.exe) that needs to monitor other known
modules (.dll's) in the scope of the AppDomain, and look for
instantiations
of this particular base type. Then apply some permissions to the base
types
interface on whether or not the current user has permission to use this
base
type.

I'm not familiar with System.Management and I will read more, thanks for
your help John.


If they're all going to be in the same AppDomain, then they should be able
to communicate with static objects exposed by static properties. You can
even create static events. Your security module could listen for a
NewInstanceConstructing event from the base class, which could pass the
constructor parameters to the event. If you derive the EventArgs from
CancelEventArgs, the security module would be able to set e.Cancel = true to
tell the base class not to permit the instanitation.

It also seems to me that you could do something with remoting, I'm just not
quite sure what.

John Saunders

P.S. Of course, remember that if you're going to use static data, you have
to protected it from multi-threaded access.
Jul 21 '05 #7
I can't believe I overlooked static events. This solution worked perfectly
for this application, thanks John.

"John Saunders" wrote:
"Dave L" <Da***@discussions.microsoft.com> wrote in message
news:1C**********************************@microsof t.com...
Yes, you have the senario correct. I will have this security module
(.dll)
running by the host application (.exe) that needs to monitor other known
modules (.dll's) in the scope of the AppDomain, and look for
instantiations
of this particular base type. Then apply some permissions to the base
types
interface on whether or not the current user has permission to use this
base
type.

I'm not familiar with System.Management and I will read more, thanks for
your help John.


If they're all going to be in the same AppDomain, then they should be able
to communicate with static objects exposed by static properties. You can
even create static events. Your security module could listen for a
NewInstanceConstructing event from the base class, which could pass the
constructor parameters to the event. If you derive the EventArgs from
CancelEventArgs, the security module would be able to set e.Cancel = true to
tell the base class not to permit the instanitation.

It also seems to me that you could do something with remoting, I'm just not
quite sure what.

John Saunders

P.S. Of course, remember that if you're going to use static data, you have
to protected it from multi-threaded access.

Jul 21 '05 #8

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

Similar topics

4
by: stu_pb | last post by:
I am designing a plugin system for a window application using .NET(C# specifically). One of the requirements of the plugin system is to be able to dynamically load/unload plugins. My initial...
4
by: Mark | last post by:
I wan't to be able to deserialize a class from an assembly that is not in the application domain. To do that I must have the Type from the Assembly. How do you get a Type from an assembly that is...
16
by: Elad | last post by:
Hi, I have an application that is made up of several executables. I need all these executables to use the same instance of an object. What is the best, most efficient way to approach this? ...
4
by: Woland | last post by:
Hi, I have many virtual directory with my web app. I'd like to create one exe appliaction to administrating these web apps. Is it possible to access Application object of web appliaction from...
7
by: Dave L | last post by:
I am inquiring about the feasability of being able to determine when an object of a certain type is instantiated. I have a base type that I want to be able to determine when each instance is...
4
by: Søren M. Olesen | last post by:
Hi Is it (any way) possible using reflection to set an indicator (property, variable, attribute,..). on an object before it actually instantiated, so that this indicator can be used in the...
4
by: Chris Marsh | last post by:
All Good day to everyone! I am developing a system which interfaces with various external systems. The set of external systems will change and grow over time. I will produce a new class to...
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
7
by: joproulx | last post by:
Hi, I was wondering if there was a way with Reflection to find dynamically if an object was referencing indirectly another object. A simple example would be: Object1 | --Object2 |
0
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,...
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...
1
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
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...
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,...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.