what i missing? | Newbie | | Join Date: Oct 2009
Posts: 8
| | |
on developer pc my app works great, wen i try to rum my app on others pc i have the same error report, to sent to microsoft. Sistem.io.filenotfoundexception!!! :(
| |
best answer - posted by tlhintoq |
That's fine. But you still have the same major issues: - You are trying to access a file that exists on your developer PC that doesn't exist on your other machines
- Your code is not robust enough to handle a situation that isn't perfect. It just assumes that the file is there and when it isn't the code doesn't recover gracefully.
I can make some suggestions. - Assume that everything is broken, or at least not ideal.
- Presume that the user is going to provide data in a format or manner that you just didn't expect. If you use a textbox for a number, the user will type "One".
- Assume that hardware breaks in the middle of what you are doing, so you have to recover.
- Take a few extra lines of code to get standards like the boot drive, the number thousands seperator etc. Don't assume that you have a C: drive or that a comma is the separator because not everyone is in America.
- Check that files/folders exist, even if you just did a call to make it: You may not have permissions.
- Don't assume the harddrive has room for what you are doing: They do fill up. Usually right in the middle of you writing to your log file.
- Get used to placing breakpoints and walking through the code line by line. Double check EVERYTHING on every line. Keep the "Locals" and "Autos" windows open so you can see your values.
- Put a breakpoint on line 1.
- When the code stops there, walk through line by line with F-10.
- Check the values of your assumptions.
- Stop. Breath. Relax. Then reason out the problem. Cut it down by sections or halves. "The value was good here, then at this method it wasn't. Where did it go between 'A' and 'B'?"
- Range check and validate values. Confirm that you didn't get a zero when you are only set to accept 1-10. Confirm your objects and values aren't null. Initialize them to a known default if possible. If a selection can be from 0-10, then initialize to -1: Now you have something to check for.
Example: - Graphics g = Graphics.FromImage(m_Undo);
Presumes that m_Undo must be good (not null)(actually exists)(not in use)(you have permissions)(doesn't time out when accessed). If that assumption fails so does your program, because you can't make anything from a file if the file is null. Get used to validating data and assumptions in your code if you want it to be robust. For example: - if (m_Undo != null)
-
{
-
bool bSuccess = false;
-
// Do your thing here
-
bSuccess = true;
-
// Hurray, your thing worked!
-
-
if (bSuccess)
-
{
-
// Then do this other thing if it worked
-
}
-
else
-
{
-
// Then do the failure recovery part / user failure message
-
}
-
-
return bSuccess; // If you want the calling method to know if it worked.
-
}
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,745
| | | re: what i missing? Quote:
filenotfoundexception
what i missing?
The file you are looking for. Quote: Sistem.io.filenotfoundexception wen i try to rum Along with ability to proofread your typing. I don't say this to be mean. Programming languages are picky and require exactness. "File" is different than "file". "Sistem" is not the same as "System". If you can't be bothered with paying attention to what you are doing/typing then you will just make a lot of extra work for yourself.
| | Newbie | | Join Date: Oct 2009
Posts: 8
| | | re: what i missing?
Excuse me,
I'm writing from my cell phone.
Error messege:
System.io.filenotfoundxception!
Regards,
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,745
| | | re: what i missing?
That's fine. But you still have the same major issues: - You are trying to access a file that exists on your developer PC that doesn't exist on your other machines
- Your code is not robust enough to handle a situation that isn't perfect. It just assumes that the file is there and when it isn't the code doesn't recover gracefully.
I can make some suggestions. - Assume that everything is broken, or at least not ideal.
- Presume that the user is going to provide data in a format or manner that you just didn't expect. If you use a textbox for a number, the user will type "One".
- Assume that hardware breaks in the middle of what you are doing, so you have to recover.
- Take a few extra lines of code to get standards like the boot drive, the number thousands seperator etc. Don't assume that you have a C: drive or that a comma is the separator because not everyone is in America.
- Check that files/folders exist, even if you just did a call to make it: You may not have permissions.
- Don't assume the harddrive has room for what you are doing: They do fill up. Usually right in the middle of you writing to your log file.
- Get used to placing breakpoints and walking through the code line by line. Double check EVERYTHING on every line. Keep the "Locals" and "Autos" windows open so you can see your values.
- Put a breakpoint on line 1.
- When the code stops there, walk through line by line with F-10.
- Check the values of your assumptions.
- Stop. Breath. Relax. Then reason out the problem. Cut it down by sections or halves. "The value was good here, then at this method it wasn't. Where did it go between 'A' and 'B'?"
- Range check and validate values. Confirm that you didn't get a zero when you are only set to accept 1-10. Confirm your objects and values aren't null. Initialize them to a known default if possible. If a selection can be from 0-10, then initialize to -1: Now you have something to check for.
Example: - Graphics g = Graphics.FromImage(m_Undo);
Presumes that m_Undo must be good (not null)(actually exists)(not in use)(you have permissions)(doesn't time out when accessed). If that assumption fails so does your program, because you can't make anything from a file if the file is null. Get used to validating data and assumptions in your code if you want it to be robust. For example: - if (m_Undo != null)
-
{
-
bool bSuccess = false;
-
// Do your thing here
-
bSuccess = true;
-
// Hurray, your thing worked!
-
-
if (bSuccess)
-
{
-
// Then do this other thing if it worked
-
}
-
else
-
{
-
// Then do the failure recovery part / user failure message
-
}
-
-
return bSuccess; // If you want the calling method to know if it worked.
-
}
| | Newbie | | Join Date: Oct 2009
Posts: 8
| | | re: what i missing?
thanks.
I think a found a peace of my problem.
On my InitializeComponent()
i write the following code, and the second messege never show on my PC. - public ControlAc()
-
{
-
MessageBox.Show("First messege");
-
InitializeComponent();
-
MessageBox.Show("Second Messege"); //this messege was never display.
-
}
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out. | | Newbie | | Join Date: Oct 2009
Posts: 8
| | | re: what i missing?
the exception trow the following messege!
Could not load file or assembly CrystalDecisions.Windows.Forms, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304'
I thinki'm close :(
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,745
| | | re: what i missing?
A) That is like a mile of code. Way beyond what is pertinent.
B) Looks like it is the automatically generated code by Visual Studio. If you didn't go behind the back of VS and make a bunch of changes, then it's safe to say this isn't where the problem is. What would be more relevant is the code that *you* wrote in your class(es) WHERE THE BREAK OCCURS Quote: - public ControlAc()
-
{
-
MessageBox.Show("First messege");
-
InitializeComponent();
-
MessageBox.Show("Second Messege"); //this messege was never display.
-
}
C) Its best to not try to do things before you even InitializeCompoents. After all, how can you do anything with anything if your parts don't exist yet? - Put a breakpoint on line "InitializeComponent();
- When the code stops there, walk through line by line with F-10 and/or F-11 as appropriate.
- Check the values of your assumptions.
| | Newbie | | Join Date: Oct 2009
Posts: 8
| | | re: what i missing?
thanks a lot,
I appreciate all your help!!!
My problem was that i missing all the DLL from crystalreports.
crystalreport.windowsform
crystalreport.share
etc.
regards,
|  | Similar C# / C Sharp bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,272 network members.
|