473,385 Members | 1,602 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,385 software developers and data experts.

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 1679
"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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?

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.