Microsoft KB Archive/832924

= BUG: You receive a visual designer error message when you use a control that includes a double array in Visual Studio .NET 2003 =

Article ID: 832924

Article Last Modified on 3/19/2007

-

APPLIES TO


 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Academic Edition

-





SYMPTOMS
In Microsoft Visual Studio .NET 2003, when you use a control that includes a double array, you receive the following visual designer error message:

At least one element in the source array could not be cast down to the destination array type



CAUSE
This behavior occurs because the visual designer generates incorrect code.



WORKAROUND
To work around this behavior, use one the following methods:
 * Encapsulate the double array in a custom type. Then, implement an ISerializable interface on that type. The type will be persisted into the resource file and the Microsoft .NET Framework visual designer will generate the code to retrieve the serialized information.
 * Use a custom collection of double data types instead of an array. Then, attach a custom serializer to the collection to generate the correct code.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to reproduce the behavior
 Start Visual Studio .NET. On the File menu, point to New, and then click Project. Under Project Types, click Visual C# Projects. Under Templates, click Windows Application. In the Name box, type Q832924, and then click OK. On the File menu, click Add New Item.</li> In the Add New Item dialog box, click User Control, and then click Open.</li> On the View menu, click Code.</li>  In the UserControl1.cs file, add the following code. double[] _ArrayOfDoubles = new double[5]; public double[] ArrayOfDbl {   get {       return _ArrayOfDoubles; }   set {       _ArrayOfDoubles = value; } } </li> On the Build menu, click Build Solution.</li> On the View menu click Toolbox.</li> In the Form1 design view, add a UserControl control to the Form1 form.</li> On the Build menu, click Rebuild Solution.

You receive the error message that is mentioned in the &quot;Symptoms&quot; section.</li></ol>

<div class="references_section">