[RESOLVED] [2008] Error, application targeted for any CPU works on mine, but not 64bit?
I am using windows xp pro, 32 bit.. my app is set to target AnyCpu (under advanced compiler options in project properties), my friend's computer is Vista Ultimate 64 bit, but it errors, but works on mine..
My installer was set to target x86 (32 bit), would that cause an error in MY application?
It did install...
Cheers
Icyculyr
Re: [2008] Error, application targeted for any CPU works on mine, but not 64bit?
Is there some policy on this forum that I don't know about where you're not allowed to post error messages? There seems to be an epidemic of people posting that they get an error but not providing any information about the error. Error messages are ALWAYS relevant. Even if they don't specifically tell us what the issue is at least we will know what it's not. Otherwise the best we can do is guess and that's just a waste of everyone's time.
Re: [2008] Error, application targeted for any CPU works on mine, but not 64bit?
Lol what I thought you couldn't post them! (jk)
I targeted installer for 64 bit, no change..
Error:
Code:
--Begin--Wednesday, September 24, 2008 - 11:59:37 PM--
Error: Length cannot be less than zero.
Parameter name: length
Stack Trace: at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at Neflaria_Stat_Calc.Form1.Monster..ctor(String sMName, Int32 iMStats, Int32 iMExp, Int32 iMGold, Int32 iMIc)
at Neflaria_Stat_Calc.Form1.LoadZoMon()
at Neflaria_Stat_Calc.Form1.Form1_Load(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
---End---------------------------------------------------------
It appears to be from my custom class Monster.. my Monster / Zones don't load..
(Works on mine, not his)
Cheers
Icyculyr
Re: [2008] Error, application targeted for any CPU works on mine, but not 64bit?
That error message and call stack is telling you specifically that you're trying to get a substring whose length is less than zero in your Monster class constructor. So, what did you find out when you looked in the Monster constructor that might cause that?
Re: [2008] Error, application targeted for any CPU works on mine, but not 64bit?
Couldn't figure out if it meant a class or not..
These lines: (Thank you jm)
Code:
sStats = iMStats.ToString("N")
sStats = sStats.Substring(0, sStats.Length - 3)
However they are not less than 0..
Cheers
Icyculyr
Re: [2008] Error, application targeted for any CPU works on mine, but not 64bit?
Quote:
Originally Posted by Icyculyr
Code:
sStats = iMStats.ToString("N")
sStats = sStats.Substring(0, sStats.Length - 3)
Given the error message I would say that that is most likely the culprit.
Quote:
Originally Posted by Icyculyr
However they are not less than 0.
How do you know? Have you actually checked what sStats is after that first line on his system? It's most likely that this has nothing to do with his system being 64-bit but rather that his regional settings are different and the "N" format produces a different result on his system than yours. There's an easy way to find out: just stick a MessageBox.Show call in there and it will show you what sStats contains. Don't ever ASSUME that a variable contains what you think it contains, especially when the app is crashing at that point. TEST.
Re: [2008] Error, application targeted for any CPU works on mine, but not 64bit?
I tested on my computer,
How can I add comma's to make 10000 10,000, but for any number
Cheers
Icyculyr
Re: [2008] Error, application targeted for any CPU works on mine, but not 64bit?
Nevermind, I've solved this (the comma's) thank you very much for your help JM, I've learned an important lesson today O_O
Cheers
Icyculyr
Re: [RESOLVED] [2008] Error, application targeted for any CPU works on mine, but not 64bit?
The reason you use standard format strings like "N" is because you want to respect the choices that each user has made in their own regional settings, whatever they may be. You can never make any assumptions about those formats other than they are what the user themselves has chosen.
If you want to force a specific format regardless of the user's regional settings then you must use a custom format string. To force numbers to be displayed with group separators you would use "#,###". Note that, even though you use a comma in the format string, the numbers will be displayed using the appropriate group separator for each user's culture. That means that if the user has set a culture that uses a dot as a group separator and a comma as a decimal separator then the format string "#,####.00" would display the number 1000 as "1.000,00".
Having said all that, that may still not be the problem. It may just be that iMStats is less than 100, in which case sStats would be two characters long and Length-3 would be -1.
Re: [RESOLVED] [2008] Error, application targeted for any CPU works on mine, but not
Great so
iInt.ToString("#,###") would produce 1,000 on my computer? if those are the numbers I supplied, that's great, thanks =)
Cheers
Icyculyr