I
Israel
I've run into this odd issue that I've never seen before. I have code
that has worked fine for a few years using .NET 1.1 and then when we
switched to .NET 2.0 it started not working. There were no code
changes related to this class or anything uses it.
I have a class which has a data member that's holding on to a delegate
that was set at one point and then later it is compared against what
was set and for some reason the Equal() method thinks it's different
even though I know they're the same. The hash codes are the same for
the delegates. The hash codes of the internal targets are the same
and all data members I can see in the debugger show that they are
absolutely identical.
Secondly I do this hundreds of times through out our product and all
other instances seem to work but for some reason this one just stopped
working.
Basically it comes down to this:
Class Dummy
{
void MethodA()
{
m_Handler = new XXXXHandler(TheHandler);
}
void MethodB()
{
MethodC(new XXXXHandler(TheHandler));
}
void MethodC(XXXXHandler handler)
{
if (m_Handler != handler)
{
throw new Exception("Ouch quite it!"); // this always
throws
}
}
void TheHandler(object sender, XXXXEventArgs args)
{
}
XXXXHandler m_Handler;
}
that has worked fine for a few years using .NET 1.1 and then when we
switched to .NET 2.0 it started not working. There were no code
changes related to this class or anything uses it.
I have a class which has a data member that's holding on to a delegate
that was set at one point and then later it is compared against what
was set and for some reason the Equal() method thinks it's different
even though I know they're the same. The hash codes are the same for
the delegates. The hash codes of the internal targets are the same
and all data members I can see in the debugger show that they are
absolutely identical.
Secondly I do this hundreds of times through out our product and all
other instances seem to work but for some reason this one just stopped
working.
Basically it comes down to this:
Class Dummy
{
void MethodA()
{
m_Handler = new XXXXHandler(TheHandler);
}
void MethodB()
{
MethodC(new XXXXHandler(TheHandler));
}
void MethodC(XXXXHandler handler)
{
if (m_Handler != handler)
{
throw new Exception("Ouch quite it!"); // this always
throws
}
}
void TheHandler(object sender, XXXXEventArgs args)
{
}
XXXXHandler m_Handler;
}