Jump to content

WindowsBase version conflict when building PDN 4.3 plugins


null54

Recommended Posts

I encountered a MSBuild warning when updating a few of my FileType plugins for Paint.NET 4.3.

 

Warning    MSB3277    Found conflicts between different versions of "WindowsBase" that could not be resolved.
There was a conflict between "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "WindowsBase, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
    "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was chosen because it was primary and "WindowsBase, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was not.
    References which depend on "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\WindowsBase.dll].
        C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\WindowsBase.dll
          Project file item includes which caused reference "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\WindowsBase.dll".
            C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\WindowsBase.dll
    References which depend on "WindowsBase, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [].
        D:\Program Files\paint.net\PaintDotNet.Base.dll
          Project file item includes which caused reference "D:\Program Files\paint.net\PaintDotNet.Base.dll".
            PaintDotNet.Base
            PaintDotNet.Core
            PaintDotNet.Data
        D:\Program Files\paint.net\PaintDotNet.Core.dll
          Project file item includes which caused reference "D:\Program Files\paint.net\PaintDotNet.Core.dll".
            PaintDotNet.Core
            PaintDotNet.Data
        D:\Program Files\paint.net\PaintDotNet.SystemLayer.dll
          Project file item includes which caused reference "D:\Program Files\paint.net\PaintDotNet.SystemLayer.dll".
            PaintDotNet.Core
            PaintDotNet.Data
        D:\Program Files\paint.net\PaintDotNet.Framework.dll
          Project file item includes which caused reference "D:\Program Files\paint.net\PaintDotNet.Framework.dll".
            PaintDotNet.Data
        D:\Program Files\paint.net\PaintDotNet.SystemLayer.Native.x64.dll
          Project file item includes which caused reference "D:\Program Files\paint.net\PaintDotNet.SystemLayer.Native.x64.dll".
            PaintDotNet.Core
            PaintDotNet.Data    DdsFileTypePlus    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets    2203    

 

Has anyone else had this issue?

PdnSig.png

Plugin Pack | PSFilterPdn | Content Aware Fill | G'MICPaint Shop Pro Filetype | RAW Filetype | WebP Filetype

The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait

 

Link to comment
Share on other sites

  • null54 changed the title to WindowsBase version conflict when building PDN 4.3 plugins

I saw this a few times but I don't remember what fixed it. Could just be like @AndrewDavid said ... exit VS, delete bin and obj folders, reload and try again.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

@null54 ILSpy shows me that you're using 4.2.16 libraries for references. This is not a good idea. It'll mostly work but things (methods and stuff) you're using may not be available anymore or their behaviour may be different for some reason.

 

I'd suggest referencing PDN 4.3's libraries to minimize the risk.

 

This is WebP plugin. Same for AvifFileType and DDSFileTypePlus.

 

// Detected TargetFramework-Id: .NETCoreApp,Version=v5.0
// Detected RuntimePack: Microsoft.NETCore.App

// Referenced assemblies (in metadata order):
// PaintDotNet.Base, Version=4.216.7781.39227, Culture=neutral, PublicKeyToken=null
	// Assembly reference loading information:
	// There were some problems during assembly reference load, see below for more information!
	// Error: Could not find reference: PaintDotNet.Base, Version=4.216.7781.39227, Culture=neutral, PublicKeyToken=null

// PaintDotNet.Core, Version=4.216.7781.39227, Culture=neutral, PublicKeyToken=null
	// Assembly reference loading information:
	// There were some problems during assembly reference load, see below for more information!
	// Error: Could not find reference: PaintDotNet.Core, Version=4.216.7781.39227, Culture=neutral, PublicKeyToken=null

// PaintDotNet.Data, Version=4.216.7781.39227, Culture=neutral, PublicKeyToken=null
	// Assembly reference loading information:
	// There were some problems during assembly reference load, see below for more information!
	// Error: Could not find reference: PaintDotNet.Data, Version=4.216.7781.39227, Culture=neutral, PublicKeyToken=null

// System.Collections, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (unresolved)
// System.ComponentModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (unresolved)
// System.Drawing.Common, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 (unresolved)
// System.Drawing.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (unresolved)
// System.Linq, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (unresolved)
// System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (unresolved)
// System.Runtime.InteropServices, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (unresolved)
// System.Runtime.InteropServices.RuntimeInformation, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (unresolved)
// WebP_ARM64.dll
// contains no metadata
// WebP_x64.dll
// contains no metadata
// WebP_x86.dll
// contains no metadata

 

For my plugins, I'm doing it like this in project file. This resolves version conflicts and also helps me to see which things are available (or not) in each version of PDN. Unfortunately I couldn't find an official way to acquire older versions of PDN libraries for backward compatible development purposes. I took a backup before installing 4.3.

 

	<ItemGroup Condition="'$(TargetFramework)'=='net47'">
		<Reference Include="PaintDotNet.Base">
			<HintPath>..\4.2.16 Libs\PaintDotNet.Base.dll</HintPath>
		</Reference>
		<Reference Include="PaintDotNet.Core">
			<HintPath>..\4.2.16 Libs\PaintDotNet.Core.dll</HintPath>
		</Reference>
		<Reference Include="PaintDotNet.Data">
			<HintPath>..\4.2.16 Libs\PaintDotNet.Data.dll</HintPath>
		</Reference>
	</ItemGroup>

	<ItemGroup Condition="'$(TargetFramework)'=='net5.0-windows'">
		<Reference Include="PaintDotNet.Base">
			<HintPath>C:\Program Files\paint.net\PaintDotNet.Base.dll</HintPath>
		</Reference>
		<Reference Include="PaintDotNet.Core">
			<HintPath>C:\Program Files\paint.net\PaintDotNet.Core.dll</HintPath>
		</Reference>
		<Reference Include="PaintDotNet.Data">
			<HintPath>C:\Program Files\paint.net\PaintDotNet.Data.dll</HintPath>
		</Reference>
	</ItemGroup>
Link to comment
Share on other sites

2 hours ago, otuncelli said:

I'd suggest referencing PDN 4.3's libraries to minimize the risk.

 

I received the warning after changing those projects to use the PDN 4.3 libraries.

PdnSig.png

Plugin Pack | PSFilterPdn | Content Aware Fill | G'MICPaint Shop Pro Filetype | RAW Filetype | WebP Filetype

The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait

 

Link to comment
Share on other sites

  • 3 weeks later...
  • 6 months later...

@midora

 

Here's a suggested solution to this issue for VS2022. I just rebuilt 3 plugins and found a way to resolve the warning.

Add the WindowsBase.dll to your project from the paint.net directory

Change the platform target to x64. (WindowsBase does not like the reference to the ARM64 CPU)

I was able to build 2 plugins without seeing the error at all.

The experts might not like the solution, but it does work. :)

 

 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

Yeah. Don't see the architecture unless you absolutely need to. You'll know if you do, and in this case you don't.


And don't add WindowsBase.dll as a reference from the paint.net directory. That's 100% wrong.

 

The solution is to have the right lines (highlighted below) in your csproj at the top, and remove any "references" to WindowsBase, PresentationCore, PresentationFramework, System.Windows.Forms. Those assembly references are handled automatically by the build system now.

 

image.png

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

2 hours ago, toe_head2001 said:

what happens when you try to run your plugin on a x86 or an ARM64 system...

Any plugins I build (Except 1) are for personal use. They are all exported from Codelab to VS.

 

Changing those lines in csproj file did not resolve the issue. 

 

@Rick Brewster Here's a detailed list of events when trying your suggestion. Each change resulted in another error.

Spoiler

1. Error adding "UseWpf" I did keep the other 2 lines.

Severity    Code    Description    Project    File    Line    Suppression State
Error    MSB4030    " true " is an invalid value for the "UseWpf" parameter of the "GenerateSupportedTargetFrameworkAlias" task. The "UseWpf" parameter is of type "System.Boolean".    xy2xyzEffect    C:\Program Files\dotnet\sdk\6.0.300-preview.22204.3\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets    1050    


2. Error when CPU is changed to Any
Severity    Code    Description    Project    File    Line    Suppression State
Warning    MSB3270    There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "WindowsBase", "AMD64". 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.    xy2xyzEffect    C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets    2302  

 

After removing WindowsBase from references this CPU error was removed

 

3. On build 

Severity    Code    Description    Project    File    Line    Suppression State
Warning    MSB3277    Found conflicts between different versions of "WindowsBase" that could not be resolved.
There was a conflict between "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "WindowsBase, Version=6.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
    "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was chosen because it was primary and "WindowsBase, Version=6.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was not.
    References which depend on "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.3\ref\net6.0\WindowsBase.dll].
        C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.3\ref\net6.0\WindowsBase.dll
          Project file item includes which caused reference "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.3\ref\net6.0\WindowsBase.dll".
            C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.3\ref/net6.0/WindowsBase.dll
    References which depend on "WindowsBase, Version=6.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [].
        C:\Program Files\paint.net\PaintDotNet.Base.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\PaintDotNet.Base.dll".
            PaintDotNet.Base
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\PaintDotNet.Core.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\PaintDotNet.Core.dll".
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\PresentationFramework.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\PresentationFramework.dll".
            PaintDotNet.Base
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\PaintDotNet.SystemLayer.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\PaintDotNet.SystemLayer.dll".
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\PaintDotNet.Framework.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\PaintDotNet.Framework.dll".
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\PresentationCore.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\PresentationCore.dll".
            PaintDotNet.Base
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\UIAutomationProvider.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\UIAutomationProvider.dll".
            PaintDotNet.Base
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\UIAutomationTypes.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\UIAutomationTypes.dll".
            PaintDotNet.Base
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\ReachFramework.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\ReachFramework.dll".
            PaintDotNet.Base
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\System.Printing.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\System.Printing.dll".
            PaintDotNet.Base
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\PresentationUI.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\PresentationUI.dll".
            PaintDotNet.Base
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\PaintDotNet.SystemLayer.Native.x64.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\PaintDotNet.SystemLayer.Native.x64.dll".
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\DirectWriteForwarder.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\DirectWriteForwarder.dll".
            PaintDotNet.Base
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\PresentationFramework.Aero.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\PresentationFramework.Aero.dll".
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\PresentationFramework.Aero2.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\PresentationFramework.Aero2.dll".
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\PresentationFramework.AeroLite.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\PresentationFramework.AeroLite.dll".
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\PresentationFramework.Classic.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\PresentationFramework.Classic.dll".
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\PresentationFramework.Luna.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\PresentationFramework.Luna.dll".
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\PresentationFramework.Royale.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\PresentationFramework.Royale.dll".
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\System.Windows.Controls.Ribbon.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\System.Windows.Controls.Ribbon.dll".
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\System.Windows.Presentation.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\System.Windows.Presentation.dll".
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\UIAutomationClient.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\UIAutomationClient.dll".
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects
        C:\Program Files\paint.net\UIAutomationClientSideProviders.dll
          Project file item includes which caused reference "C:\Program Files\paint.net\UIAutomationClientSideProviders.dll".
            PaintDotNet.Core
            PaintDotNet.Data
            PaintDotNet.Effects    xy2xyzEffect    C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets    2302  

 

4. Adding WindowsBase to references clears the error but creates this conflict

Severity    Code    Description    Project    File    Line    Suppression State
Warning    MSB3270    There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "WindowsBase", "AMD64". 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.    xy2xyzEffect    C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets    2302    

 

5. Changing platform target to x64 clears this error.

 

I know from previous builds that the error is just a warning and has no effect on the operation of the plugin. I just prefer not to see any warnings or messages when I work in VS. I did notice that your csproj is for an executable and not an assembly. That may be why UseWPF caused an error. The csproj is generated by codelab as well.

Hence my solution for plugins that are not distributed (for @toe_head2001's ease of mind) :)

 

Only through a clear understanding of the problem can we gain a permanent solution.

 

 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

@Rick Brewster I think the issue is within the WindowsBase file itself.

 

Spoiler

Taken from C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.3\ref\net6.0WindowsBase.dll
[assembly: AssemblyVersion("4.0.0.0")]
[assembly: AssemblyFileVersion("6.0.322.12309")]

 

The csproj file is generated by codelab.

 

 

The codelab code comes from 

 

 

Edited by AndrewDavid
Removed upload

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

4 hours ago, AndrewDavid said:

1. Error adding "UseWpf" I did keep the other 2 lines.

Severity    Code    Description    Project    File    Line    Suppression State
Error    MSB4030    " true " is an invalid value for the "UseWpf" parameter of the "GenerateSupportedTargetFrameworkAlias" task. The "UseWpf" parameter is of type "System.Boolean".    xy2xyzEffect    C:\Program Files\dotnet\sdk\6.0.300-preview.22204.3\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets    1050    

 

You have space characters.

 

It needs to be exactly like this (case-insensitive):

<UseWpf>true<UseWpf>

 

Not like this:

<UseWpf> true <UseWpf>
Link to comment
Share on other sites

OK that worked. No WindowsBase error - 
Removed reference to WindowsBase and changed to AnyCPU
Build succeeded without warning

PS @otuncelli
You are missing the hash tag	
<UseWpf>true</UseWpf>

Now to add those 3 2 lines when codelab generates the VS solution  :)

 

<UseWindowsForms>true</UseWindowsForms>

<UseWpf>true</UseWpf>

<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>

 

Who gets the solution tag?

 

 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

3 hours ago, AndrewDavid said:

PS @otuncelli You are missing the hash tag <UseWpf>true</UseWpf>

 

*Slash

Yup 😹

 

3 hours ago, AndrewDavid said:

Who gets the solution tag?

 

You shouldn't need to add ImportWindowsDesktopTargets. It's enabled by default if you add UseWPF. You can confirm this by looking at the .targets file:

 

https://github.com/dotnet/sdk/blob/master/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets#L1160

 

Link to comment
Share on other sites

  • 3 months later...

I too am running into this - with Net6 and VS2022

 

I have not found a good solution at all - the best bet seems to be to ignore the warning (which is never a good idea)

 

Enabling WPF/WinForms (which I don't need) seems less than ideal.

 

I was speculating a binding redirect would help, but the csproj does not seem to like it. https://stackoverflow.com/questions/43365736/assembly-binding-redirect-how-and-why

<dependentAssembly>
    <assemblyIdentity name="WindowsBase" publicKeyToken="31bf3856ad364e35" culture="neutral" />  
    <bindingRedirect oldVersion="4.0.0.0" newVersion="6.0.2.0" />  
</dependentAssembly>


...or even trying it automatically - https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/how-to-enable-and-disable-automatic-binding-redirection

Cheers

John

Link to comment
Share on other sites

4 hours ago, John Scott said:

Enabling WPF/WinForms (which I don't need) seems less than ideal.

 

That's the solution. That's literally all you need to do.

 

Binding redirects are a mess. And, I don't think they even work beyond .NET Framework -- they're a solution for a problem that no longer exists.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...