Click here to Skip to main content
15,891,762 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My Program does not work on other computers I see this error CLR20r3 System.IO.DirectoryNotFound
I made breakpoint via message box and finally I found the error in the program.cs  

Application.Run(new Mainform());


What I have tried:

How I can fix this error in the source of my program?
Posted
Updated 22-Oct-18 21:20pm

Directory not found is pretty clear.
1) log your exception and see where in your code it is.
2) either create the directory on start up (i.e. Program.cs) or check if it exists with Directory.Exists() before using it.
 
Share this answer
 
Comments
[no name] 23-Oct-18 3:44am    
My program works well in my pc but when I move that into the server it's missing a DLL and cash shows this error could not load file or assembly
Mehdi Gholam 23-Oct-18 10:26am    
Make sure you copy the file needed to your other machines also.
Application.Run is the code which executes your whole program - it's not just a single line of code that that performs, it's a huge number!

You need to start logging what is going on in your MainForm - start with the constructor and the obvious Event handlers Load and Shown. The idea is to "narrow down" where in yoru code the exception is being caused, so at its most basic use File.AppendText[^] to add "I got this far" messages to a file so you can review after teh crash and work out where it didn't get! When you know the rough area, you can start to focus in using more detailed logging statements until you get it down to a reasonable chunk of code.

Then you can start working out which folder is missing, and why.
But we can;t do any of that for you!
 
Share this answer
 
Comments
[no name] 23-Oct-18 3:50am    
as I told My program works well in my pc but when I move that into the server it's missing DLL or library and try cach shows this error could not load file or assembly

I am sure that file is in reference but this program does not work in another computer
why
OriginalGriff 23-Oct-18 4:00am    
:sigh:
Why not give us the full error message to start with?
When you say "it gave me System.IO.DirectoryNotFound" then that is what we assume the problem is related to.

"Missing DLL or library" is different - it means you haven't installed all the prerequisites for your app when you installed it on the other computer.

It's a bit like buying a second hand car from an advert, and assuming that it will come with a full tank of gas, a years insurance, and a full driving licence! It won't - the price includes the car and whatever is inside it at the time, nothing else. To get the rest, you need to negotiate with the appropriate people: teh vendor to get the gas tank filled, your insurance company to get your insurance transferred, and your government to pass a driving test and get a licence.

Software is the same: and EXE file is just the code you wrote - it doesn't include the appropriate .NET framework, or any of the DLL's your code references unless some other application has already installed them.

To get the appropriate DLL's installed, you need to create a setup or deployment project which will create installation media to add what is needed when your app is installed.
[no name] 23-Oct-18 4:05am    
try
{
Application.Run(new Mainform());
}
catch (Exception ex)
{

MessageBox.Show(ex.Message);
}


//////////////////////////
that try cach shows this error

Could not load file or assembly 'mtapiservice ', version=1.0.28.0, culture=neutral,publickeyToken='fe39c8c11cabcd1e'or one of its dependencies. the systen cannot find the file specified

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900