Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
InvalidCastException when icon is set in autogenerated form designer code #163
Crash at runtime where icon is set as follows in autogenerated form designer code
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
Following exception is thrown when running using dotnet CLI or vscode
No crash, form icon is set. Crash does not happen and icon is set when debugging via Visual Studio 2019 preview.
This problem you're seeing is caused by Microsoft/msbuild#2221. The reason it works when building in VS is because VS uses .NET Framework MSBuild, which does not suffer from the above issue, which is specific to .NET Core MSBuild. I opened Microsoft/msbuild#3819 to try to fix this, but it hasn't been reviewed since I fixed the remaining test failures three weeks ago. Until we get that PR merged (and the version of .NET Core MSBuild you're using is updated to include the fix) there's not much you can do about this other than build using VS. Sorry about this!