Hello @謝,
Welcome to Microsoft Q&A forum and thank you for sharing us the detailed error messages.
To narrow down this issue, I suggest you create another new WinForm project, check if this error also appears in this newly created project.
=> If the same error doesn’t appear, the issue should be related to the specific project.
Firstly, please close Visual Studio, navigate to your project folder, remove the bin, obj and the hidden .vs folder. Launch VS and rebuild your project, see if this error disappears.
The error message indicates that there are illegal characters in the path, but don’t mention which path is. I suggest check your code and the project settings. Especially, the custom things such as custom controls, custom configuration files and form’s constructor(do you have any code which cannot be executed in design time, like database access, files access …?).
Also, please open and check the XXXXX.Designer.cs
file, make sure that there are no errors(red squiggly lines).
=> If the same error appears, the issue should be caused by Visual Studio or system environment.
Try to repair Visual Studio from Visual Studio Installer => More => Repair. Reinstall the ".NET desktop development" workload in Visual Studio Installer. And manually download and install the .NET SDK from here: Download .NET.
By the way, can this project be built correctly?
Feel free to contact us.
Best Regards,
Tianyu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.