Patching into New?

  • Thread starter Thread starter Rob Nicholson
  • Start date Start date
R

Rob Nicholson

Is it possible to patch into the memory allocation mechanism in .NET (VB.NET
specifically). Maybe a call-back everytime an object is created on our
application.

For example, when I do...

Dim MyObj1 As New MyObj()

.....it calls a application wide function to carry out a little more common
initialisation?

Cheers, Rob.
 
Create your own base object which implements the application-wide
functionality in its constructor(s), and inherit all your other objects from
it. In your other objects, be sure that the base object constructor gets
called.

Tom Dacon
Dacon Software Consultingh
 
I don't believe so...
Except *maybe* if you use the low-level Runtime hosting and/or debuging
interface.

Otherwise what about having the object which you're interested in derived
from a common base class which would do the work in its constructor?
 
Tom Dacon said:
Create your own base object which implements the application-wide
functionality in its constructor(s), and inherit all your other objects
from it. In your other objects, be sure that the base object constructor
gets called.

I don't know in VB.NET
but at last in C++ & C# the base constructor is always call by the runtime
automatically for you 1st.
that's the reason why, if you want to call the base constructor with some
specific parameter you've got this option only on the first line!
 
Otherwise what about having the object which you're interested in derived
from a common base class which would do the work in its constructor?

Actually, we do have a base object the problem is more getting to the
system-wide global variable. Ahh, light dawns... I know how I can do this
now, didn't when I started VB.NET

Thanks all, Rob.
 
Back
Top