Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I just finished my application, but when I moved the exe on my desktop I got this error:
SQL
System.IO.FileNotFoundException: Could not load file or assembly 'HttpService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Can not find the file.
File name: 'HttpService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'


did I miss anything?

any help would be highly appreciated.
Posted

The reasons can be different.

Please see my two comprehensive answers which explain how to work with all kinds of paths:
How to find my programs directory (executable directory),
How to find my programs directory ("special folders", working directory).

I want to reiterate that there are no situation when using any hard-coded file path can be useful. In all cases, paths should be calculated during run time based on user input, configuration files, etc, based on the methods I described above.

—SA
 
Share this answer
 
v3
Comments
Kishor Deshpande 3-Feb-13 22:02pm    
My 5
Sergey Alexandrovich Kryukov 3-Feb-13 22:31pm    
Thank you, Kishor.
—SA
Hi Maxbre,

You are probably using a relative path to a file (which file?) that is found relative to the Debug folder, but not in the same relative path to the Release folder.

Cheers,
Edo
 
Share this answer
 
Comments
maxbre 3-Feb-13 9:57am    
Ok thanks, I saw that the application is looking for C:\Users\Max\Documents\Visual Studio 2012\Projects\HttpService\bin\Release\HttpService.exe. I have a reference to a windows service that is hosting a wcf service. The httpService.exe is supposed to be runned as a Windows Service on a server while the HttpClient.exe is running on other computers. How can I keep the reference without the HttpService.exe in the same directory?
Joezer BH 4-Feb-13 0:47am    
What I usually do is keep a config file with such params.
The config can be set on the Visual Studio to be copied to the output folder on compilation.
Sergey Alexandrovich Kryukov 3-Feb-13 13:36pm    
Using relative path is as bad as using absolute path.
The problems are using 1) any hard-coded path at all, 2) using working directory based on assumption that the user never changes it.
—SA
Sergey Alexandrovich Kryukov 3-Feb-13 13:43pm    
Please see my answer for detail, it's more or less comprehensive...
—SA

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