2

On VS2022, I open a solution that I downloaded from codeproject This solution used to be in .net framework 4.6.1 ; when I open it in VS2022 it was migrated to .net framework 4.8 Not sure above information are relevant. But when I try to start it (Project Win Form), I got issue because Application.ExecutablePath return an inconsistent string with back and forward slash. C:\HOMEWARE\Code\C#/BrainTeaser2/Demo/bin/Debug/Demo.exe Later, I have an external library which use this Property as follow Application.ExecutablePath.LeftOfRightmostOf("\\") So it gets the wrong path.

Does any one face same issue? Is there a way to have the Application.ExecutablePath to return this string instead: C:\HOMEWARE\Code\C#\BrainTeaser2\Demo\bin\Debug\Demo.exe

(I built a new Win Form project from my VS2022 in .NET 8 and the Application.ExecutablePath is well formatted. So I don't thing my problem will be reproducible by others. But if someone get any clue to go around my issue without to have to creating a new solution and re-creating all the projects, it will be great.)

2
  • Apparently this has always been a thing - even in 2013 - well before Framework 4.6.1 was released. Identical code, on near-identical machines, giving two different results. Commented May 13, 2024 at 2:19
  • @NPras Great thanks. You save my day. In the link you added there is the root cause of my problem. In my path there was indeed a hash (#). Changing the path fixed my issue Commented May 16, 2024 at 1:56

2 Answers 2

1

If you face the same issue. Try to move your project/solution in a folder path which has no weird character. In my case there was a hash (#). Moving in a different location allow me to launch my projects ;-)

More information can be found on this link

Sign up to request clarification or add additional context in comments.

Comments

0

Firstly: Both paths are perfectly valid. The mixed directory seperator is not an error, but you might call it an inconvenience.

The "external library" definitely has a bug, going by the code you posted. If you have any control over it, you should get that fixed, to work with both path separators correctly.

Also, you might want to look through your .csproj files for any paths to replace.

1 Comment

Thanks for your reply I agree this is not a bug ; but it is really painful and boring. I looked at .csproj and don't find anything incorrect. No one get a clue how this Property is built and any option to get a solution. I encountered such kind of issue 20 years ago and I am a bit disappointed that not standardization and not introducing a breaking change we are still facing such kind issue in 2024.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.