Click here to Skip to main content
11,409,801 members (57,920 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Hi, I just finished my application, but when I moved the exe on my desktop I got this error:
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 3-Feb-13 4:29am
maxbre338
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
v3
Comments
Kishor Deshpande at 3-Feb-13 22:02pm
   
My 5
Sergey Alexandrovich Kryukov at 3-Feb-13 22:31pm
   
Thank you, Kishor.
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
maxbre at 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?
Edo Tzumer at 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 at 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 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 270
1 OriginalGriff 255
2 Maciej Los 138
3 Andy Lanng 115
4 Sascha Lefévre 85
0 Sergey Alexandrovich Kryukov 8,731
1 OriginalGriff 6,895
2 Maciej Los 3,332
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web03 | 2.8.150414.5 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100