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



The information in this article applies to:

  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • 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 "Applies to" section.

MORE INFORMATION

Steps to reproduce the behavior

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

    You receive the error message that is mentioned in the "Symptoms" section.

REFERENCES

For more information about .NET Framework Visual Designers, visit the Microsoft Developer Network (MSDN) Web site:

Modification Type:MinorLast Reviewed:3/7/2006
Keywords:kbvs2005swept kbvs2005doesnotapply kbpending kbtshoot kbbug KB832924 kbAudDeveloper kbAudITPRO