Deployed application can't find its resources c# Visual Studio 2010

10,072

Solution 1

Well I found the answer to this issue after a while of struggling.. You have to erase the "..\..\" before the Resource folder in the "settings" while you are about to publish otherwise the deployed application can not find its resources thus they will not be at the same folder as described. But remember if you want to continue working on your project you must put back "..\..\" for debugging the program otherwise debugging will not work!!! I was not allowed to publish the image to show you here because of I don't have earned "10" reputations yet.. :)

Solution 2

I had the same problem, You can do the following:

  1. Open the .resx file
  2. Just above the file, there is a access modifier listbox. if it is set to "No code generated" , Select public from the list

Build,

Hopefully, problem solved.

Solution 3

In Visual Studio 2010 professional open your project open the project properties select Web Under Servers set the Virtual Path as your deployed website virtual path.

If you set the virtual path to /BookStore You need to update all the resources references

Look like the following from

src="../../img/picture.png"

to

src="/BookStore/./img/picture.png"

Solution 4

I had the same issue, I assume it is suppose to be that way with two different paths. This is what I did so I no longer had to edit the file paths when going from debugging to production.

Public RP As String = IO.Path.GetFullPath(My.Resources.ResourceManager.BaseName)
Public filePath As String = RunOrInstall(RP)

'Checks to see if debugging or installed and returns correct path
Private Function RunOrInstall(RP)

    Dim pathing As String

    If RP.ToString().IndexOf("bin") = -1 Then
       pathing = RP.Substring(0, RP.LastIndexOf("\")) & "\Resources\"
    Else
        pathing = RP.Substring(0, RP.LastIndexOf("bin")) & "Resources\"
    End If

    Return pathing

End Function
Share:
10,072
CSR
Author by

CSR

Full stack Developer

Updated on June 04, 2022

Comments

  • CSR
    CSR almost 2 years

    I have an big issue when publishing my application on another machine. The apps resources as pictures and sounds can't be found anywhere thou they actually are installed somewhere I really don't know where.. I'm talking about oneClick Deployment! I have put the files in separate folders in the Resource folder in the Solution explorer and the path is a string path inside Settings like this ....\Resources\Images\Cards\ and ....\Resources\Sounds\ Whatever I do the program can't find its resources so what is the basic issue here? I believe it's something wrong with the path because I see when the program gets installed it installs everything (same amount of MB). Any suggestions anybody? C# Visual Studio 2010 Black Jack Game