Skip to content

Attempting to Run WinForms Application Using dotnet run fails #51494

@Tiptup300

Description

@Tiptup300

Here's my code

#:sdk Microsoft.NET.Sdk
#:property UseWindowsForms=true
#:property TargetFramework=net10.0-windows
#:property OutputType=WinExe
#:property PublishTrimmed=false

using System;
using System.Windows.Forms;
using Microsoft.Web.WebView2.WinForms;

var form = new Form { Width = 800, Height = 600 };
Application.Run(form); 

Note that I had to add PublishTrimmed due to an error about trimming

Whenever I run this I receive an error

C:\Users\<redacted>\AppData\Roaming\Code\User\History\-158c9e5c\mtUP.resx : error MSB3103:
  Invalid Resx file. System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users<redacted>\AppData\
  Roaming\Code\User\History\Resources\<redacted file that is related to some totally other project>.pdf'.
     at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileSha
  re share, FileOptions options)
     at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare sha
  re, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
     at System.IO.File.OpenHandle(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, I
  nt64 preallocationSize)
     at System.IO.File.ReadAllBytes(String path)
     at Microsoft.Build.Tasks.ResourceHandling.MSBuildResXReader.AddLinkedResource(String resxFilename, Boolean pathsRel
  ativeToBasePath, List`1 resources, String name, String value)
     at Microsoft.Build.Tasks.ResourceHandling.MSBuildResXReader.ReadResources(Stream s, String filename, Boolean pathsR
  elativeToBasePath, TaskLoggingHelper log, Boolean logWarningForBinaryFormatter)

Whats odd is that the pdf file its trying to read is related to my work is not related, my assumption is something's maybe not setup for the process and it's just defaulting to the last .resx file it knows of in some form.

Metadata

Metadata

Assignees

Labels

Area-run-fileItems related to the "dotnet run <file>" effortneeds-info

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions