G
Guest
What has been changed in version 2.0 ?
I read this article :
http://msdn.microsoft.com/security/.../library/en-us/dnnetsec/html/seccodeguide.asp
and there is a section named Boxed Value Types. I checked an example from
this article and I noticed that described problem exists only in Framework
1.1.
class bug
{
public object m_Property;
public Object Property
{
get { return m_Property; }
}
public static void m1(ref int j)
{
j = Int32.MaxValue;
}
public static void m2(ref ArrayList j)
{
j = new ArrayList();
}
}
public static void Main(String [] args)
{
{
bug b = new bug();
b.m_Property = 4;
Object[] objArr = new Object[] { b.Property };
Object[] objArr = new Object[] { b.Property };
typeof(bug).GetMethod("m1").Invoke(null, objArr);
Console.WriteLine(b.m_Property);
Console.WriteLine(objArr[0]);
}
{
bug b = new bug();
ArrayList al = new ArrayList();
al.Add("element");
b.m_Property = al;
Object[] objArr = new Object[] { b.Property };
Console.WriteLine( ((ArrayList)(b.m_Property)).Count);
typeof(bug).GetMethod("m2").Invoke(null, objArr);
Console.WriteLine( ((ArrayList)(b.m_Property)).Count);
Console.WriteLine( ((ArrayList)(objArr[0])).Count);
}
Output from .NET 1.1:
4
2147483647
2147483647
1
1
0
Output form .NET 2.0
4
4 <- !!
2147483647
1
1
0
What is the difference in boxing between vesion 1.1 and 2.0 of Framework?
I read this article :
http://msdn.microsoft.com/security/.../library/en-us/dnnetsec/html/seccodeguide.asp
and there is a section named Boxed Value Types. I checked an example from
this article and I noticed that described problem exists only in Framework
1.1.
class bug
{
public object m_Property;
public Object Property
{
get { return m_Property; }
}
public static void m1(ref int j)
{
j = Int32.MaxValue;
}
public static void m2(ref ArrayList j)
{
j = new ArrayList();
}
}
public static void Main(String [] args)
{
{
bug b = new bug();
b.m_Property = 4;
Object[] objArr = new Object[] { b.Property };
Object[] objArr = new Object[] { b.Property };
typeof(bug).GetMethod("m1").Invoke(null, objArr);
Console.WriteLine(b.m_Property);
Console.WriteLine(objArr[0]);
}
{
bug b = new bug();
ArrayList al = new ArrayList();
al.Add("element");
b.m_Property = al;
Object[] objArr = new Object[] { b.Property };
Console.WriteLine( ((ArrayList)(b.m_Property)).Count);
typeof(bug).GetMethod("m2").Invoke(null, objArr);
Console.WriteLine( ((ArrayList)(b.m_Property)).Count);
Console.WriteLine( ((ArrayList)(objArr[0])).Count);
}
Output from .NET 1.1:
4
2147483647
2147483647
1
1
0
Output form .NET 2.0
4
4 <- !!
2147483647
1
1
0
What is the difference in boxing between vesion 1.1 and 2.0 of Framework?