.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Invalid Cast

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
197 Views, 3 Replies

Invalid Cast

At runtime I am getting an Invalid Cast error at the following line. I am creating a Dimstyle which works on except for the following. I have used the Getvalue for some string information like "ARIAL" with success, so I know my string to the KEY works. thanks ahead of time.

dsr.Dimtxt = (double)Microsoft.Win32.Registry.GetValue(("HKEY_CURRENT_USER\\Software\\VB and VBA Program Settings\\Jobs\\" + job), "rTextsize", null);

The value of rTextsize is 0.09375.
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Try to compile this line of code, and see what the
compiler tells you:

double d = null;

Shouldn't it be obvious that because GetValue()
returns its second argument if the registry entry
is not present, that the second argument must
be a value can be assigned to a double ?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5594292@discussion.autodesk.com...
At runtime I am getting an Invalid Cast error at the following line. I am creating a Dimstyle which works on except for the following. I have used the Getvalue for some string information like "ARIAL" with success, so I know my string to the KEY works. thanks ahead of time.

dsr.Dimtxt = (double)Microsoft.Win32.Registry.GetValue(("HKEY_CURRENT_USER\\Software\\VB and VBA Program Settings\\Jobs\\" + job), "rTextsize", null);

The value of rTextsize is 0.09375.
Message 3 of 4
Anonymous
in reply to: Anonymous

I see what you are saying, so I set the second value to 1.0, but I am still getting the same error. also the HKEY..... text line came for a .reg file that I loaded so I know it exists and has a value. Once I get it working I intended to set the second (default value) to something I can use for error trapping.
Message 4 of 4
Anonymous
in reply to: Anonymous

When you have a runtime error like that you use the debugger
to see what's happening.

In this case, change the type of the variable that the result of
GetValue() is assigned to, from double to 'object', and then
step through the code with the debugger and look at the value
of the variable to see what is actually returned by GetValue().


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5594350@discussion.autodesk.com...
I see what you are saying, so I set the second value to 1.0, but I am still getting the same error. also the HKEY..... text line came for a .reg file that I loaded so I know it exists and has a value. Once I get it working I intended to set the second (default value) to something I can use for error trapping.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost