Click here to Skip to main content
11,795,568 members (78,899 online)
Rate this: bad
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=, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Can not find the file.
File name: 'HttpService, Version=, Culture=neutral, PublicKeyToken=null'

did I miss anything?

any help would be highly appreciated.
Posted 3-Feb-13 3:29am
Rate this: bad
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.

Kishor Deshpande at 3-Feb-13 22:02pm
My 5
Sergey Alexandrovich Kryukov at 3-Feb-13 22:31pm
Thank you, Kishor.
Rate this: bad
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.

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.
Sergey Alexandrovich Kryukov at 3-Feb-13 13:43pm
Please see my answer for detail, it's more or less comprehensive...

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

  Print Answers RSS
0 Maciej Los 340
1 Sergey Alexandrovich Kryukov 316
2 OriginalGriff 285
3 Abhinav S 223
4 KrunalRohit 214
0 OriginalGriff 1,797
1 Maciej Los 1,415
2 KrunalRohit 1,240
3 CPallini 840
4 ppolymorphe 808

Advertise | Privacy | Mobile
Web02 | 2.8.151002.1 | 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