G
Guest
Having classes as below:
-------------------------------------------------------
class X<T> where T : Y, new()
{
public void Test()
{
throw new Exception("XXXX");
}
}
class Y
{
int a;
}
class Z : Y
{
int b;
}
-------------------------------------------
and executing code:
-------------------------------------------
X<Z> variable = new X<Z>();
try
{
variable.Test();
}
catch (Exception ex)
{
Stream writer = new MemoryStream();
IFormatter formatter = new BinaryFormatter();
formatter.Serialize(writer, ex);
writer.Close();
}
---------------------------------------
I've got an error trying to serialize exception (generic parameter don't
meet contraints).
It happens alway when trying to serialize exception thrown from generic
class when generic parameter is constrained with inheritance.
If you remove where contraint exception is serialized succesfully.
I use VS 2005 beta 2.
Is it .NET framework bug or I'm missing something important?
-------------------------------------------------------
class X<T> where T : Y, new()
{
public void Test()
{
throw new Exception("XXXX");
}
}
class Y
{
int a;
}
class Z : Y
{
int b;
}
-------------------------------------------
and executing code:
-------------------------------------------
X<Z> variable = new X<Z>();
try
{
variable.Test();
}
catch (Exception ex)
{
Stream writer = new MemoryStream();
IFormatter formatter = new BinaryFormatter();
formatter.Serialize(writer, ex);
writer.Close();
}
---------------------------------------
I've got an error trying to serialize exception (generic parameter don't
meet contraints).
It happens alway when trying to serialize exception thrown from generic
class when generic parameter is constrained with inheritance.
If you remove where contraint exception is serialized succesfully.
I use VS 2005 beta 2.
Is it .NET framework bug or I'm missing something important?