I just installed Visual Studio on my home machine and also in a virtual machine lab with both 2017 & 2019 versions. The VM instances I installed via the GUI setup and the home machine I used used your offline CMD line method to ensure I had all the required dependencies. PS Pro Tools extension is version 5.5.1
Loading a new project, everything seems OK where I can add controls to the form and change properties etc. I then double-clicked say a button to add an action and proceed to add code to that command block. But… when I return to the form I get the following errors:
I can dismiss the error and run the project successfully but the error persist if the file was saved and reloaded. I tried reinstalling missing target libraries and adding specific code to reference them with partial effect - the errors changed but I forget what they were and I have uninstalled 2019 from the home system.
PSScriptPad fares better although I get a bunch of errors if I try to run the code when the form designer tab is active - runs fine from the code tab.
Attached is one screenshot (I have more but I’m only allowed one currently). This happens in all VS instances including the one I installed on my home system yesterday with all current updates installed.
Any idea what is going on? Are there components missing?
Some of you may not be surprised to know that the solution was to add the missing reference - System.Drawing (yes, I am somewhat new to this). The questioned now is why this wasn’t added automatically? My work computer that has an identical setup but is running VS Professional (vs Community) adds the System.Drawing reference automatically - why not in my case?
Seems like a bug in PoshTools to me. It should add that automatically when you add a new form to the project or create a project with the form project template. I’ll try and reproduce on my end. This used to be a problem before but the reference would be invalid and not missing all together but I thought it had been resolved.
Hate to tag on to this, but I have the same problem EXCEPT the reference does exist.
I can add the Powershell Form and stick a button on it and all is good.
As soon as I add code to the button… something as simple as Write-Host 'Test" and then switch back to the form I get the same errors.
could not find type system.drawing.point
could not find type system.drawing.size
The system.drawing is already there in references.
Ultimately I can’t even use the product if I can’t get past putting a button with code.
At the link below is a zipped file with the error. Just form with button. And I have NOT put a single line of code.
I do see to errors in the Error list after building:
“Missing closing } in statement block or type definition”
“The string is missing the terminator”
This is in the Form1.ps1.
I also see an error at top of screen stating “An exception of type ArgumentException has been encountered. This may be caused by an extension”
Hopefully you will be able to help figure out what is going on
Powershell Studio 2019 works great, but i would rather stay in Visual Studio with this product if this can be resolved
It is hard trying to use a priduct and getting issues right off the bat.
thanks for your time and help.
Understood. I agree that something not working right away sucks. I sure hate it when it’s the product that I work on.
That said, I haven’t been able to reproduce the issue you are experiencing. I was able to successfully modify the form in the project you attached. Can you please do me a favor and click Help -> About Microsoft Visual Studio and also send me a log from %AppData%\PowerShell Tools for Visual Studio?
If you don’t have time to debug this issues, that’s all good. I understand.
By the way my Dev environment is in a clean Windows 10 VM and nothing else installed other than Dev Express tools. So it isn’t all mucked up with a bunch of other applications.
So I have upgraded to 16.7.0 and it is acting different now.
So the System.Drawing reference did not automatically show up so I got the same errors.
But I could add the reference, save, close and re-open and now that error is gone and the form shows.
If I do a build it says succeeded, but if you go to the Error List after building I now see:
You must provide a value expression following the ‘=’ operator line 48.
I double click on it and it takes me to the PowerShellFormProject code for the form and the only contents are as follows (NOTE: There is no line 48):
If I create the project as “PowerShell Windows Forms Project” I still get the error, but it is because it forgot to put the System.Drawing reference. After I add, save, close it continues to work (at least for now).
If I create the project as “PowerShell Script Project” and then Add a PowerShell Form it automatically adds the System.Drawing reference, but eventually (after adding button or something else) will throw the errors and form no longer will display.
No matter what I do I cannot get it to fix itself.
I may have to abandon this if I can’t get this simple thing working.
I am more than welcome to do a WebEx or something with support if they wish to try and see what is going on.
Ok… tested further and in the second example above if I remove and then re-add the reference System.Drawing, save, close and open it works again.
One thing I noticed when it added the reference at the point when I added the form the System.Drawing had a yellow symbol next to it. Not sure what that means, but only thing I see different.
Also notice the ???.designer.ps1 seems to hold on to all the changes between object names.
For example if I add the button I see entries for the default button1, but if I change the button1 to something like btnTest then I see those entries AND the old button1 in that file. Seems like it should remove the old entries that do not exit to me. Just something else I noticed.