DataGridView

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
dlisterjr
Posts: 5
Last visit: Mon Oct 28, 2019 11:56 am

DataGridView

Post by dlisterjr »

When trying to use a DataGridView control, I get the following error:

Cannot resolve dependency to assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: DataGridView

Post by jvierra »

Not enough information to understand what you are trying to do. Perhaps you need to rebuild the cache or reinstall PSS>
User avatar
dlisterjr
Posts: 5
Last visit: Mon Oct 28, 2019 11:56 am

Re: DataGridView

Post by dlisterjr »

I have a form that I have been working on. It's working fine. But when I add a DataGridView to the form and run the script I get that error. As soon as I remove the DataGridView from the from, the script runs fine.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: DataGridView

Post by jvierra »

What version of PSS are you running?
User avatar
dlisterjr
Posts: 5
Last visit: Mon Oct 28, 2019 11:56 am

Re: DataGridView

Post by dlisterjr »

PowerShell Studio 2017 v5.4.141
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: DataGridView

Post by davidc »

Please answer the following:

1. What version of PowerShell do you have installed?
2. What platform settings are you using when you run the script?
3. Do you have .NET 2.0 installed?
David
SAPIEN Technologies, Inc.
User avatar
dlisterjr
Posts: 5
Last visit: Mon Oct 28, 2019 11:56 am

Re: DataGridView

Post by dlisterjr »

The server is Windows 2012 R2 running Powershell:

Major Minor Build Revision
----- ----- ----- --------
5 1 14393 1358

These are the platform controls are:
Local Machine
v5 - 64bit
STA mode enabled

.Net Versions Installed:
2.0.50727.4927
3.0.30729.4926
3.5.30729.4926
4.6.01055
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: DataGridView

Post by jvierra »

Sometimes a PSF file can become corrupted and odd things will happen. Have you tried starting a new form and adding just the DGV to the form then run it. If this fails then the issue is not likely with the PSF file. If it succeeds then suspect the PSF.

You clearly have V2 support installed as you can run the form without the DGV.

When creating the new form do not use the same template that you used for the failing form. It, too, can be corrupted.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: DataGridView

Post by jvierra »

Without the DGV you can easily check the running Net version by adding this to the form load. It will appear in the output pane when the form opens.

Write-Host ([System.Windows.Forms.DataGridView].Assembly.ImageRuntimeVersion)
User avatar
dlisterjr
Posts: 5
Last visit: Mon Oct 28, 2019 11:56 am

Re: DataGridView

Post by dlisterjr »

I figured it out. The assembly for .net 2.0 (System) was not loaded. Not sure why it doesn't use the 4.0 assembly. But it's resolved.
This topic is 6 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked