Description
openedon Aug 25, 2024
.NET version
.NET 9
{
"name": "Microsoft.NETCore.App",
"version": "9.0.0-preview.7.24405.7"
},
{
"name": "Microsoft.WindowsDesktop.App",
"version": "9.0.0-preview.7.24405.2"
}
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
The error is not there in any previous .NET build before .NET9 e.g. it worked in .NET5, .NET6, .NET8 for us.
Issue description
.NET 9 Building fails with CLR C++ mixed code on Bitmap due to introduction of IPointer in #10783 in Visual Studio 2022 17.12 preview
You get this strange error when you want to access any property of a System::Drawing::Bitmap ^ bmp in C++ CLI/CLR :
error C3229: 'TPointer *': indirections on a generic type parameter are not allowed
I assume this is caused by this change which doesn't even seem to document why it introduced such a native pointer class as base class from #10783 in https://github.com/dotnet/winforms/pull/10783/files
it changed
public sealed unsafe class Bitmap : Image
to
public sealed unsafe class Bitmap : Image, IPointer
Note that this change will most likely also break running any .NET 8 or .NET6 software on .NET 9 , which may happen a lot when people like us distribute their software with Rollforward=LatestMajor
Steps to reproduce
Create mixed mode C++ CLR project for .NET9 with Visual Studio 2022 17.12 preview and a function that uses System::Drawing::Bitmap ^ bmp as argument and then try to access a property e.g. int flags = bmp->Flags;
It will complain that you try to access a pointer
error C3229: 'TPointer *': indirections on a generic type parameter are not allowed
Note that this may potentially also be caused by a bug in the Visual Studio 17.12 preview compiler or the .NET 9 SDK compiler but we are very worried that simply due to this change our software will not work on PCs with NET9
test.cpp(2168,5): error C3229: 'TPointer *': indirections on a generic type parameter are not allowed
1>(compiling source file '/test.cpp')
1> test.cpp(2168,5):
1> compiler using 'TPointer' to continue parsing
1> test.cpp(2168,5):
1> This diagnostic occurred while importing type 'Windows::Win32::Foundation::IPointer' from assembly 'System.Private.Windows.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
1> test.cpp(2168,5):
1> This diagnostic occurred while importing type 'System::Drawing::IImage' from assembly 'System.Private.Windows.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
1> test.cpp(2168,5):
1> This diagnostic occurred while importing type 'System::Drawing::Image' from assembly 'System.Drawing.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
1> test.cpp(2168,5):
1> This diagnostic occurred while importing type 'System::Drawing::Bitmap' from assembly 'System.Drawing.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
To reproduce the compile issue see example in #11983 (comment)