Drop 500 lb mirror on Software, you are nuts?
DLL hell time for .NET!
----- Message d'origine -----
De : Matt Morgan
Envoyé : vendredi 20 septembre 2002 22:04
À : professional vb
Objet : [pro_vb] Re: StrPtr function
I Agree, but can somebody come drop a 500 lb mirror on my in laws?
----- Original Message -----
From: "Yehuda Rosenblum" <Yehuda@I...>
To: "professional vb" <pro_vb@p...>
Sent: Friday, September 20, 2002 2:22 PM
Subject: [pro_vb] Re: StrPtr function
Just a note. I myself have also worked with this and it is extremely
unstable. In some cases it worked nicely and some places it caused the
program to suddenly die without warning. I agree with Marco. I have
had my share of unstable Dlls enough, without adding this in.
-----Original Message-----
From: Marco Straforini [mailto:marco.straforini@c...]
Sent: Friday, September 20, 2002 4:19 PM
To: professional vb
Subject: [pro_vb] Re: StrPtr function
Dear Andy,
Indeed you can use ObjPtr to store the address of an object and later
use CopyMemory to copy the address into a temporary copy of the object.
In this way, you can use the object without creating a circular
reference, and also... without COM having the knowledge that you do it.
Does it sound bad? Well, I am taking a big deep breath here
before continue. Please you all out there, do not get offended.
It is not safe. Sure, you make it working, but for how long? All it
takes
is just a minor change in the code, or adding another library or third
party component that does its own subclassing and you are in GPF hell,
with no possibility to debug. VB is so tight bound to COM that cheating
is not easy. Do it at your own risk. Or, to say it different, do it at
your customers risk. How does this sound.
A small example. You wife walks in the living while you are reading
you favorite book, asking you to hang a picture of your in-laws. She
was kind enough to find a nail for you. Do you walk to the garage
to get a hammer or you just look around to find an heavy substitution
for it? It is only a 5x7, right? (PS I love my wife and my in-laws, and
I
have their picture in the living room). What about a thirty-pound glass
mirror on top of the fireplace? I spent a whole day at the local
hardware store to find the best way to hang it safely, and I had two
friends
for dinner to help me lifting that elephant up...
Even Appleman says that you can do subclassing in VB, but the
subclassing
control his company is selling is written in C++. I am old enough that
I do not want to take risks anymore: only the right tool for the job,
basta.
Here is how it fails. Your component uses an object with the 'wrong'
reference count. What if the 'real' object goes out of scope? COM
does not know that you are going to use it, it decreases its reference
count, and because it is now zero it releases it (atta boy). Now your
component uses the address of an object that does not exist anymore.
And because you do not have control on the order that COM in VB
releases the objects, you can't do anything for it.
I started writing this hours ago and I just finished it because I am in
the
middle of a dll's hell right now. Isn't this job wonderful?
To summarize: do cheat with COM, but at your own risk. Because my risk
is to make a customer unhappy, I do not do it.
Marco
> Hi Marco,
> The whole subject of pointers and direct memory access is one that I
would
l> ike know more about, so I've been reading this thread with interest.
I
n> ow want to ask about using pointers to avoid circular refernces - so
I'll
u> nderstand if you don't want to answer ;-)
---
Visual C# - A Guide for VB6 Developers
This book will make it easy to transfer your skills
from Visual Basic 6 to C#, the language of choice
of the .NET Framework.
http://www.wrox.com/ACON11.asp?ISBN=1861007175&p2p0059
---
Visual C# - A Guide for VB6 Developers
This book will make it easy to transfer your skills
from Visual Basic 6 to C#, the language of choice
of the .NET Framework.
http://www.wrox.com/ACON11.asp?ISBN=1861007175&p2p0059
---
Visual C# - A Guide for VB6 Developers
This book will make it easy to transfer your skills
from Visual Basic 6 to C#, the language of choice
of the .NET Framework.
http://www.wrox.com/ACON11.asp?ISBN=1861007175&p2p0059
to unsubscribe send a blank email to Profitez pleinement du Web. Téléchargez gratuitement MSN Explorer :
http://explorer.msn.fr/intl.asp#fr