Pixelord
Pixelord

Reputation: 641

Project cannot load image assets while running from visual studio IDE

I am porting an old visual studio C++ project. I have a data folder in the project directory that contains all the image assets. The project is build using an external make file.

My problem is, the project cannot load the asset files while running the executable from the VS IDE during debugging. However, if I execute the exe from bin folder, it can load the assets.I am assuming there are some kind of environment issue in the project, but could not figured it out.

Any clue?

Upvotes: 0

Views: 1766

Answers (1)

Yirkha
Yirkha

Reputation: 13848

My guess is that the program tries to access the assets using a relative path like ..\data\some.data. It works when you run it manually from the bin folder, because the current directory is set to the bin folder itself (the folder from where an application was launched) by default.

But when running projects from the Visual Studio IDE, parameters set under "Project properties > Debugging" tab apply instead. There is an option "Working directory", which defaults to $(ProjectDir), i.e. the folder where the project file resides.

Try changing that to the bin folder, or, if the resulting .exe file is placed directly there, easily just to the $(OutDir) variable.

Upvotes: 2

Related Questions