runtime: [dotnet-sdk-10.0.100-preview.3.25174.5] Failed to build the retargeted paint.net with CS0104 and CS8377
Application Name: paint.net OS: Windows 10 21H2 CPU: X64 .NET Build Number: dotnet-sdk-10.0.100-preview.3.25174.5 Source Code and repro machine checking at:https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2433931 Github Link: https://github.com/dotnet/paint.net
Verify Scenarios: 1). Windows 10 21H2 AMD64 + default target .NET 9 + dotnet-sdk-9.0.202: Pass 2). Windows 10 21H2 AMD64 + default target .NET 9 + dotnet-sdk-10.0.100-preview.3.25174.5: Pass 3). Windows 10 21H2 AMD64 + Retarget .NET 10 + dotnet-sdk-10.0.100-preview.1.25103.13: Pass 4). Windows 10 21H2 AMD64 + Retarget .NET 10 + dotnet-sdk-10.0.100-preview.3.25174.5: Fail 5). Windows 10 21H2 AMD64 + Retarget .NET 10 + dotnet-sdk-10.0.100-preview.3.25177.4: Fail
Description : When retargeting 3rd party application to .NET 10, we get below errors:
error CS0104: 'GCHandle<>' is an ambiguous reference between 'PaintDotNet.Runtime.GCHandle<T>' and 'System.Runtime.InteropServices.GCHandle<T>'
error CS8377: The type 'CDWriteInlineObjectCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IDWriteInlineObject.Vtbl<TSelf>'
error CS8377: The type 'CDWritePixelSnappingCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IDWritePixelSnapping.Vtbl<TSelf>'
Repro steps on repro machine: The source code in repro machine has been retargeted to .NET 10.
- Open “C:\paint.net\paintdotnet.sln” with Visual Studio.
- Build Misc/AppVersion project first.
- Build paintdotnet project.
Expected Result:
Only 2 errors which related to build tools that won’t affect generate application executable under bin\Release folder. We can ignore them.
Actual Result: Except above build tools issue, there are errors about CS0104 and CS8377:
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.DirectWrite.CDWriteInlineObjectCcw.Generated.cs(28,127): error CS8377: The type 'CDWriteInlineObjectCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IDWriteInlineObject.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.DirectWrite.CDWritePixelSnappingCcw.Generated.cs(28,129): error CS8377: The type 'CDWritePixelSnappingCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IDWritePixelSnapping.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Animation.CUIAnimationInterpolatorCcw.Generated.cs(28,135): error CS8377: The type 'CUIAnimationInterpolatorCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IUIAnimationInterpolator.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Direct2D1.CD2D1AnalysisTransformCcw.Generated.cs(28,131): error CS8377: The type 'CD2D1AnalysisTransformCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'ID2D1AnalysisTransform.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Animation.CUIAnimationManagerEventHandlerCcw.Generated.cs(28,149): error CS8377: The type 'CUIAnimationManagerEventHandlerCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IUIAnimationManagerEventHandler.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Animation.CUIAnimationVariableChangeHandlerCcw.Generated.cs(28,153): error CS8377: The type 'CUIAnimationVariableChangeHandlerCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IUIAnimationVariableChangeHandler.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Imaging.CWICBitmapCcw.Generated.cs(28,105): error CS8377: The type 'CWICBitmapCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IWICBitmap.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Animation.CUIAnimationVariableIntegerChangeHandlerCcw.Generated.cs(28,167): error CS8377: The type 'CUIAnimationVariableIntegerChangeHandlerCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IUIAnimationVariableIntegerChangeHandler.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Imaging.CWICBitmapFrameEncodeCcw.Generated.cs(28,127): error CS8377: The type 'CWICBitmapFrameEncodeCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IWICBitmapFrameEncode.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Direct2D1.CD2D1CommandSink5Ccw.Generated.cs(28,121): error CS8377: The type 'CD2D1CommandSink5Ccw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'ID2D1CommandSink5.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.DirectWrite.CDWriteTextRenderer1Ccw.Generated.cs(28,129): error CS8377: The type 'CDWriteTextRenderer1Ccw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IDWriteTextRenderer1.Vtbl<TSelf>' C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Direct2D1.CD2D1ComputeTransformCcw.Generated.cs(28,129): error CS8377: The type 'CD2D1ComputeTransformCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'ID2D1ComputeTransform.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.ComponentModel.CStreamCcw.Generated.cs(28,106): error CS8377: The type 'CStreamCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IStream.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Direct2D1.CD2D1DrawTransformCcw.Generated.cs(28,123): error CS8377: The type 'CD2D1DrawTransformCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'ID2D1DrawTransform.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Imaging.CWICBitmapLockCcw.Generated.cs(28,113): error CS8377: The type 'CWICBitmapLockCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IWICBitmapLock.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Imaging.CWICBitmapSourceCcw.Generated.cs(28,117): error CS8377: The type 'CWICBitmapSourceCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IWICBitmapSource.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Direct2D1.CD2D1EffectImplCcw.Generated.cs(28,117): error CS8377: The type 'CD2D1EffectImplCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'ID2D1EffectImpl.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Direct2D1.CD2D1GdiMetafileSink1Ccw.Generated.cs(28,129): error CS8377: The type 'CD2D1GdiMetafileSink1Ccw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'ID2D1GdiMetafileSink1.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Direct2D1.CD2D1GeometrySinkCcw.Generated.cs(28,121): error CS8377: The type 'CD2D1GeometrySinkCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'ID2D1GeometrySink.Vtbl<TSelf>' C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Direct2D1.CD2D1SimplifiedGeometrySinkCcw.Generated.cs(28,141): error CS8377: The type 'CD2D1SimplifiedGeometrySinkCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'ID2D1SimplifiedGeometrySink.Vtbl<TSelf>' C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Direct2D1.CD2D1SourceTransformCcw.Generated.cs(28,127): error CS8377: The type 'CD2D1SourceTransformCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'ID2D1SourceTransform.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Direct2D1.CD2D1TesselationSinkCcw.Generated.cs(28,128): error CS8377: The type 'CD2D1TesselationSinkCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'ID2D1TessellationSink.Vtbl<TSelf>' C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Direct2D1.CD2D1TransformCcw.Generated.cs(28,115): error CS8377: The type 'CD2D1TransformCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'ID2D1Transform.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComCallableWrapperGenerator\PaintDotNet.Direct2D1.CD2D1TransformNodeCcw.Generated.cs(28,123): error CS8377: The type 'CD2D1TransformNodeCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'ID2D1TransformNode.Vtbl<TSelf>'
C:\paint.net\Windows\obj\Debug\generated\PaintDotNet.ObjectRefGenerator\PaintDotNet.Generators.Interop.ComObjectImplGenerator\PaintDotNet.Interop.CDynamicCcw.Generated.cs(23,101): error CS8377: The type 'CDynamicCcw' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TSelf' in the generic type or method 'IFxObjectRef.Vtbl<TSelf>'
Findings:
For error CS0104, we found paint.net has its own GCHandle<T> definded in “paint.net\Runtime\Runtime\GCHandle`1.cs”. If we assign its alias like this in source code, the error CS0104 can be resolved:
private PaintDotNet.Runtime.GCHandle<object> objectHandle;
For error CS8377, all of them come from source generate file. (binlog attached: build_fail.zip)
dotnet info:
.NET SDK:
Version: 10.0.100-preview.3.25174.5
Commit: f36c57aec7
Workload version: 10.0.100-manifests.ef4f854f
MSBuild version: 17.15.0-preview-25167-10+bcc2dc6a6
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19044
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.100-preview.3.25174.5\
Host:
Version: 10.0.0-preview.3.25171.5
Architecture: x64
Commit: 0a33e18a0b
.NET SDKs installed:
10.0.100-preview.3.25174.5 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 10.0.0-preview.3.25172.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 10.0.0-preview.3.25171.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 10.0.0-preview.3.25174.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (12 by maintainers)
Thanks for the heads up. From what I can tell, the new
GCHandle<T>is equivalent to my oldGCHandle<T>except that it splits out Normal, Weak, and Pinned into separate structs. Should be easy enough to accommodate as the 3 handle types aren’t ever mixed together in the same scenarios.