Patching into New?

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.
 
T

Tom Dacon

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
 
L

Lloyd Dupont

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?
 
L

Lloyd Dupont

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!
 
R

Rob Nicholson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top