Packaging script for dotnet core with Forms not working yet?

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.

does this not get packaged with the EXE?

That should work. Are you using VS Code? Can you share your package.psd1 file?

Figured out that if i copy the dll to the same directory as the EXE it will work.

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.

Copying the DLL didn’t work for me. Thats strange. Its a PS7 issue.,

Let me give this a shot and see if I can figure out what’s wrong. You shouldn’t have to copy that DLL.

1 Like

I’ve fixed this issue and built is on the way. Should be released in the next 30 minutes or so.

1 Like

What is the build number? Because I’ve got 5.6.1 and it’s still giving the same can’t load the Systems.Form.dll Error.

Yep. That’s the version. Try hiding the console to see if it pops up.

I need to add a new output type for Win Forms to better denote when a WinForm app is being compiled.

1 Like

Oops, that was my bad, I had thought it rebuilt when I opened it again after the update and it never did. :sweat_smile:

So far so good on the build, thank you! :heart_eyes:

1 Like

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.

Can you send your pssproj file to me? It would be handy to see your settings.

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?

Can you email me at adam@ironmansoftware.com?

Did you receive the email?