I thought i had read that we can package scripts with dotnet core 3.1 and Powershell 7.0 while using forms in the script. But so far, even creating a basic script from scratch this does not work. the build completes, but the resulting exe gives me this.
Add-Type -AssemblyName System.Windows.Forms
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot find path ‘C:\Users\jeffc\Desktop\testApp\out\System.Windows.Forms.dll’ because it does not exist.
This is exactly what’s been happening to me as well. I’ve tried it using VS Code as well as Visual Studio 2019 with the same results.
Isn’t the resulting EXE supposed to contain any DLLs needed so that a user doesn’t have to install anything in order to use it? I just want to make sure I’m not misunderstanding anything.
Well, Bad news Adam, the builder was working on Friday, and then when I tried to build it today I got this error and building error, nothing has been changed coding wise of the software itself.
MethodInvocationException:
Line |
2 | … shToolsRoot)[System.Reflection.Assembly]::LoadWithPartialName('System …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling “LoadWithPartialName” with “1” argument(s): “Could not load file or assembly ‘System.Windows.Forms, Culture=neutral, PublicKeyToken=null’. Operation is not supported. (0x80131515)”
This one seems different because it’s saying LoadWithPartialName which doesn’t make much sense, since there is no “LoadWithPartialName” in the files…
There is also build error along with this. I haven’t seen this one before.
C:\Program Files\dotnet\sdk\3.1.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(349,5): warning NETSDK1107: Microsoft.NET.Sdk.WindowsDesktop is required to build Windows desktop applications. ‘UseWpf’ and ‘UseWindowsForms’ are not supported by the current SDK.
Yes, I can. I am not entirely sure what’s going on anymore because now it’s loading but still and loading but still throwing the Assembly error for windows forms? Not sure how it can load when throwing an error but yeah. How would you like me to send it to you?