VS2022 - WPF Designer error

Windows 11 22000
Tool: Visual Studio 2022
Version: 2022.1.0

Error:

PSWPF01.pssproj

<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>6CAFC0C6-A428-4d30-A9F9-700E829FEA51</ProjectGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>MyApplication</RootNamespace>
    <AssemblyName>MyApplication</AssemblyName>
    <Name>PSWPF01</Name>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <Name>mscorlib</Name>
      <AssemblyName>
      </AssemblyName>
      <HintPath>
      </HintPath>
    </Reference>
    <Reference Include="PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <Name>PresentationCore</Name>
      <AssemblyName>
      </AssemblyName>
      <HintPath>
      </HintPath>
    </Reference>
    <Reference Include="PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <Name>PresentationCore</Name>
      <AssemblyName>PresentationCore.dll</AssemblyName>
      <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\PresentationCore.dll</HintPath>
    </Reference>
    <Reference Include="PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <Name>PresentationFramework</Name>
      <AssemblyName>
      </AssemblyName>
      <HintPath>
      </HintPath>
    </Reference>
    <Reference Include="PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <Name>PresentationFramework</Name>
      <AssemblyName>PresentationFramework.dll</AssemblyName>
      <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\PresentationFramework.dll</HintPath>
    </Reference>
    <Reference Include="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <Name>System</Name>
      <AssemblyName>System.dll</AssemblyName>
      <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.dll</HintPath>
    </Reference>
    <Reference Include="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <Name>System.Drawing</Name>
      <AssemblyName>System.Drawing.dll</AssemblyName>
      <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Drawing.dll</HintPath>
    </Reference>
    <Reference Include="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <Name>System.Windows.Forms</Name>
      <AssemblyName>System.Windows.Forms.dll</AssemblyName>
      <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Windows.Forms.dll</HintPath>
    </Reference>
    <Reference Include="System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <Name>System.Xaml</Name>
      <AssemblyName>
      </AssemblyName>
      <HintPath>
      </HintPath>
    </Reference>
    <Reference Include="System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <Name>System.Xaml</Name>
      <AssemblyName>System.Xaml.dll</AssemblyName>
      <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Xaml.dll</HintPath>
    </Reference>
    <Reference Include="UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <Name>UIAutomationProvider</Name>
      <AssemblyName>
      </AssemblyName>
      <HintPath>
      </HintPath>
    </Reference>
    <Reference Include="UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <Name>UIAutomationProvider</Name>
      <AssemblyName>UIAutomationProvider.dll</AssemblyName>
      <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\UIAutomationProvider.dll</HintPath>
    </Reference>
    <Reference Include="WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <Name>WindowsBase</Name>
      <AssemblyName>
      </AssemblyName>
      <HintPath>
      </HintPath>
    </Reference>
    <Reference Include="WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <Name>WindowsBase</Name>
      <AssemblyName>WindowsBase.dll</AssemblyName>
      <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\WindowsBase.dll</HintPath>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <Content Include="PSWPF01.xaml" />
    <Content Include="Resources.resx" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="PSWPF01.xaml.ps1">
      <SubType>Code</SubType>
      <DependentUpon>PSWPF01.xaml</DependentUpon>
    </Compile>
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <Target Name="Build" />
  <Import Project="$(MSBuildExtensionsPath)\PowerShell Tools for Visual Studio\PowerShellTools.targets" Condition="Exists('$(MSBuildExtensionsPath)\PowerShell Tools for Visual Studio\PowerShellTools.targets')" />
</Project>

VS Components:

{

  "version": "1.0",

  "components": [

    "Microsoft.VisualStudio.Component.CoreEditor",

    "Microsoft.VisualStudio.Workload.CoreEditor",

    "Microsoft.Net.Component.4.8.SDK",

    "Microsoft.Net.Component.4.7.2.TargetingPack",

    "Microsoft.Net.ComponentGroup.DevelopmentPrerequisites",

    "Microsoft.VisualStudio.Component.JavaScript.Diagnostics",

    "Microsoft.VisualStudio.Component.Roslyn.Compiler",

    "Microsoft.Component.MSBuild",

    "Microsoft.VisualStudio.Component.Roslyn.LanguageServices",

    "Microsoft.VisualStudio.Component.TextTemplating",

    "Microsoft.VisualStudio.Component.NuGet",

    "Microsoft.VisualStudio.Component.SQL.LocalDB.Runtime",

    "Microsoft.VisualStudio.Component.SQL.CLR",

    "Microsoft.Component.ClickOnce",

    "Microsoft.VisualStudio.Component.ManagedDesktop.Core",

    "Microsoft.NetCore.Component.Runtime.6.0",

    "Microsoft.NetCore.Component.SDK",

    "Microsoft.VisualStudio.Component.FSharp",

    "Microsoft.ComponentGroup.ClickOnce.Publish",

    "Microsoft.NetCore.Component.DevelopmentTools",

    "Microsoft.Net.Component.4.8.TargetingPack",

    "Microsoft.Net.ComponentGroup.4.8.DeveloperTools",

    "Microsoft.VisualStudio.Component.DiagnosticTools",

    "Microsoft.VisualStudio.Component.Debugger.JustInTime",

    "Microsoft.VisualStudio.Component.IntelliCode",

    "Microsoft.VisualStudio.Component.AspNet45",

    "Microsoft.VisualStudio.Component.AspNet",

    "Microsoft.Net.Component.4.6.2.TargetingPack",

    "Microsoft.Net.Component.4.7.TargetingPack",

    "Microsoft.Net.Component.4.7.1.TargetingPack",

    "Microsoft.VisualStudio.Component.ManagedDesktop.Prerequisites",

    "Microsoft.ComponentGroup.Blend",

    "Microsoft.VisualStudio.ComponentGroup.MSIX.Packaging",

    "Microsoft.VisualStudio.Workload.ManagedDesktop",

    "Microsoft.VisualStudio.Component.VC.Redist.14.Latest",

    "Microsoft.Net.Component.4.6.TargetingPack",

    "Microsoft.VisualStudio.Component.VC.Redist.MSM",

    "Microsoft.NetCore.Component.Runtime.3.1",

    "Microsoft.NetCore.Component.Runtime.5.0",

    "Microsoft.Net.Component.4.6.1.TargetingPack",

    "Microsoft.Net.Component.4.6.1.SDK",

    "Microsoft.Net.Component.4.6.2.SDK",

    "Microsoft.Net.Component.4.7.SDK",

    "Microsoft.Net.Component.4.7.1.SDK",

    "Microsoft.Net.Component.4.7.2.SDK"

  ]

}

Thanks for the report. I’ll open an issue for this. I haven’t see this yet so I’ll have to try to reproduce.

Can confirm as I ran into this issue as well. :heavy_check_mark:

It is a misleading error because it has nothing to do with “Developer Packs”. :roll_eyes: I am fairly certain that this is related to permissions. There are some assemblies which are not loaded in the GAC. A non-admin user will not be able to add them.

@ALIENQuake Could you or your desktop support agent please try launching Visual Studio 2022 with elevated admin rights? (Shift-Right-click, 'run as administrator). I only needed to do this once on my end and from then on I don’t see the error as a non-admin.

@adam I believe the best way to reproduce this would be to install everything on a fresh Windows 10 box (which I just did recently). I will see about developing a workstation snapshot that I can revert on my end to help isolate the culprit assembly(ies).

1 Like

@DataTraveler Tried with Admin rights, I’m still getting this error.

@ALIENQuake thanks for quick response, ok let’s try a different approach. Can you post the assemblies that you have loaded by running the below command in PowerShell and then posting a screenshot?

[appdomain]::CurrentDomain.GetAssemblies() | Out-GridView

Advanced

If you are willing, can we get full confirmation that you are running VS2022 in elevated mode? If you could open an elevated prompt and then launch the VS2022 manually (after confirming that NET SESSIONS does not respond with access denied) we should know with absolute certainty (pictured below).

Thank you!

Something else that we can try is opening the PowerShell command prompt for VS2022 and then running gacutil.exe. Could you please try pasting in the below commands into the VS2022 prompt and then sharing any results that come up as 0 items found?

gacutil.exe /l “mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”
gacutil.exe /l “PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”
gacutil.exe /l “PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”
gacutil.exe /l “System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”
gacutil.exe /l “System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”
gacutil.exe /l “System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”
gacutil.exe /l “System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”
gacutil.exe /l “UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”
gacutil.exe /l “WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”

I do have launched VS as admin, the ‘ADMIN’ indicator is added on the top-right side of the interface.

1.[appdomain]::CurrentDomain.GetAssemblies() | Out-GridView

True	v4.0.30319	C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.ConsoleHost\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.ConsoleHost.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Management.Infrastructure\v4.0_1.0.0.0__31bf3856ad364e35\Microsoft.Management.Infrastructure.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Management\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Management.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.DirectoryServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.DirectoryServices.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Numerics\v4.0_4.0.0.0__b77a5c561934e089\System.Numerics.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_pl_b77a5c561934e089\mscorlib.resources.dll	
False	v4.0.30319		
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Security\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Security.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_32\System.Transactions\v4.0_4.0.0.0__b77a5c561934e089\System.Transactions.dll	
False	v4.0.30319	C:\Program Files\WindowsPowerShell\Modules\PSReadline\2.0.0\Microsoft.PowerShell.PSReadLine.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Utility\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Commands.Utility.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration.Install\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.Install.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.resources\v4.0_4.0.0.0_pl_b77a5c561934e089\System.Xml.resources.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Management\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Commands.Management.dll	
False	v4.0.30319	C:\Users\ALIEN\Documents\WindowsPowerShell\Modules\DnsClient\dnslookup.dll	
False	v4.0.30319		
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Management.Infrastructure.CimCmdlets\v4.0_1.0.0.0__31bf3856ad364e35\Microsoft.Management.Infrastructure.CimCmdlets.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_32\Microsoft.Management.Infrastructure.Native\v4.0_1.0.0.0__31bf3856ad364e35\Microsoft.Management.Infrastructure.Native.dll	
False	v4.0.30319		
False	v4.0.30319		
False	v4.0.30319	D:\Programs\Microsoft Visual Studio\2022\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll	
False	v4.0.30319	D:\Programs\Microsoft Visual Studio\2022\Community\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Telemetry.dll	
False	v4.0.30319	D:\Programs\Microsoft Visual Studio\2022\Community\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Utilities.Internal.dll	
False	v4.0.30319	D:\Programs\Microsoft Visual Studio\2022\Community\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.RemoteControl.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll	
False	v4.0.30319	D:\Programs\Microsoft Visual Studio\2022\Community\Common7\IDE\PrivateAssemblies\Newtonsoft.Json.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll	
True	v4.0.30319	C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.ScheduledJob\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.ScheduledJob.dll	


  1. gacutil.exe
[ALIEN-PC] ALIEN > D:\Programs\Microsoft Visual Studio\2022\Community
gacutil.exe /l “PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64
  PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=x86

Number of items = 2
[ALIEN-PC] ALIEN > D:\Programs\Microsoft Visual Studio\2022\Community
gacutil.exe /l “PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL

Number of items = 1
[ALIEN-PC] ALIEN > D:\Programs\Microsoft Visual Studio\2022\Community
gacutil.exe /l “System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL

Number of items = 1
[ALIEN-PC] ALIEN > D:\Programs\Microsoft Visual Studio\2022\Community
gacutil.exe /l “System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL

Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL

Number of items = 1
[ALIEN-PC] ALIEN > D:\Programs\Microsoft Visual Studio\2022\Community
gacutil.exe /l “System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL

Number of items = 1
[ALIEN-PC] ALIEN > D:\Programs\Microsoft Visual Studio\2022\Community
gacutil.exe /l “System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL

Number of items = 1
[ALIEN-PC] ALIEN > D:\Programs\Microsoft Visual Studio\2022\Community
gacutil.exe /l “UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL

Number of items = 1
[ALIEN-PC] ALIEN > D:\Programs\Microsoft Visual Studio\2022\Community
gacutil.exe /l “WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”

After spending a lot more time on this I realize that (per @ALIENQuake’s feedback) running as Admin does not actually work for the project file that was posted here. That procedure seems to have fixed a similar issue for me but I have since recreated this with the same installation of VS2022. I also tried installing every developer package from 4.6.2 and above but no dice.

The way I recreated this was simply creating a new project.

@adam would it be possible to discover what is on “line 1217” per screenshot below? That might help narrow down what’s going on here.

1 Like

I would also like to add that when I recreated the issue, simply running the project (F5) and seeing the form drawn was enough to make the error go away until the project was unloaded and loaded again. In other words, the error message about the missing assembly seems superfluous and not impactful.

image

Starting with Visual Studio 2022, Visual Studio no longer includes .NET Framework components for .NET Framework 4.0 - 4.5.1 because these versions are no longer supported. Visual Studio 2022 and later versions can’t build apps that target .NET Framework 4.0 through .NET Framework 4.5.1. To continue building these apps, you can use Visual Studio 2019 or an earlier version.

Thanks @ALIENQuake and @DataTraveler for trying to get to the bottom of this.

It shouldn’t do this on a fresh install, so I’ll log it as a bug. It doesn’t sound like we have a repeated workaround at the moment.

An issue is open here: Error in WPF Designer in VS2022 · Issue #832 · ironmansoftware/issues · GitHub

I have an update on this. I have found that after recreating the error, it can be seemingly resolved by removing the line (shown below) that imports the CSharp targets. The project still builds and displays the visual.

  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

@ALIENQuake could you kindly try removing that line from your .pssproj file (while the project is unloaded) to see if it helps?

More

The reference to “line (1217, 5)” is for the file C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets (355kb) (pictured below)

@DataTraveler After removing this line, all references disappear, opening xaml does not trigger the visual designer and I can no longer run the project at all.

This should be resolved in this build. Can either of you try it in your environment?

1 Like

@adamdriscoll New build seems fixed the problem. Thanks!

1 Like

I can confirm that the error went away on my side after installing the updated extension. However, there is now a warning which I do not recall seeing before.

There was a mismatch between the processor architecture of the project being built “MSIL” and the processor architecture of the reference “C:\Windows\Microsoft[dot]NET\Framework\v4.0.30319\mscorlib.dll”, “x86”. This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. PowerShellFormProject1 C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64 C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets