Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2007

Tip: Looking for answers? Try searching our database.

InstanceDescriptor problem rendering Nullable<double> constructor parameters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nathan Alden - 05 Jan 2007 02:12 GMT
I have a class like so:

public class MyClass
{
   public MyClass(double? x, double? y)
   {
   }
}

I have created a type converter for this class that converts MyClass to an
InstanceDescriptor which renders a line of code like the following on a form
when x and y are null:

this.myComponent1.MyClassInstance = new MyClass(null, null);

The designer deserialization mechanism in Visual Studio is able to correctly
determine which constructor must be called on the MyClass class when
entering design mode.

However, if x and y are not null, and happen to have no decimal, the
following line of code is rendered:

this.myComponent1.MyClassInstance = new MyClass(2, 1);

This causes an exception when the form is designed with an error about a
constructor with Int32, Int32 signature not being found. It appears as
though there is no implicit conversion (for some reason) from Int32 to
Nullable<Double>.

So far I have not been able to find a way to cause the InstanceDescriptor to
render an explicit cast statement (double?) to ensure the constructor is
called successfully.

Has anyone experienced this problem before, and if so, how did you solve it?

Thanks.

-- Nathan
Alexander Malapheev[MCP] - 15 Jan 2007 06:12 GMT
Hi, Nathan

Maybe you can just add another one constructor?

public MyClass(int t1, int t2)
{
}

> I have a class like so:
>
[quoted text clipped - 34 lines]
>
> -- Nathan
Alexander Malapheev[MCP] - 15 Jan 2007 06:13 GMT
Hi, Nathan

Maybe you can just add another one constructor?

public MyClass(int t1, int t2)
{
}
> I have a class like so:
>
[quoted text clipped - 34 lines]
>
> -- Nathan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.