0

I can add an image to a form no problem, and it builds with no errors. Then, when I relocate the project, there is the error 'does not support code parsing or generation because it is not contained within a project that supports code' when I reopen the project from the new file location. This can be resolved by removing the form and adding it again, however this would have to be done every time the project is opened after being moved, and for anyone trying to open it from a new location.

I've tried adding the image in various ways, and I've tried adding different images. Every time, images are added with no issues in the original project location, however as soon as the project is moved this error keeps occurring.

How can I add an image to a C# project in Visual Studio 2019 while retaining the ability to move the project to a different location without resulting in errors whenever the project is reopened?

*EDIT I'm now wondering if this occurs after a certain amount of time that the project is copied, instead of because of adding an image. I have started to get the error again after I have copied the project about 10 times, which is around when I started to get the error when I was working with an image included in the project.

**EDIT I have rephrased the question here: After I have copied a C# project in Visual Studio 2019 about 10 times or so, I get an error when I reopen the project

GBN
  • 1
  • 4
  • "I've tried adding the image in various ways." Please describe the various ways. – John Wu Jun 03 '19 at 08:51
  • Basically all the ways described here: https://stackoverflow.com/questions/6560105/change-pictureboxs-image-to-image-from-my-resources – GBN Jun 03 '19 at 09:58

2 Answers2

0
  • Remove Special characters from Project folder Name.
  • Amend Project file paths in solution File.
  • Delete .vs Hidden folder or .sou file

I recently had a similar experience where i would get the error when trying to open the designer in VS after i moved my project.

to give some context i moved a project from TFS to GIT source control. I created a project in azure devops and the project name contained a space.

the clone url then escaped the space character as %20, when Cloning this repository from the command line without renaming the destination folder I ended up with a folder name containing %20 in its name, instead of a space. my solution file then had the same naming conventions containing the %20 in the project path.

0

This https://social.msdn.microsoft.com/Forums/en-US/cadde249-3fa9-46de-aa23-37ceae612e8c/form-not-contained-wiithin-a-project-that-supports-code?forum=winformsdesigner helped me:

Close the solution. go to the solution's file folder and delete the solution's .SUO files. Then reload the solution in Visual Studio. In the solution file explorer, right click on the targeted form source and select the "View code"(not "View Designer"). When the source file is opened, then right click over the source text and select View in designer.

Shmulik b
  • 19
  • 4