Repository navigation
Description
Description
I'm using the latest .NET8 and VS 17.8
It's a compile error for c++/cli:
1>C:\Users\admin\source\repos\Project1\Project1\Source.cpp(5,1): error C3611: 'System::Numerics::INumberBase::System::IUtf8SpanFormattable.TryFormat': a sealed function cannot have a pure-specifier
1>C:\Users\admin\source\repos\Project1\Project1\Source.cpp(5,1): message : This diagnostic occurred while importing type 'System::Numerics::INumberBase' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
1>C:\Users\admin\source\repos\Project1\Project1\Source.cpp(5,1): message : This diagnostic occurred while importing type 'System::Numerics::INumber' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
1>C:\Users\admin\source\repos\Project1\Project1\Source.cpp(5,1): message : This diagnostic occurred while importing type 'System::Numerics::IBinaryNumber' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
1>C:\Users\admin\source\repos\Project1\Project1\Source.cpp(5,1): message : This diagnostic occurred while importing type 'System::Numerics::IBinaryInteger' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
1>C:\Users\admin\source\repos\Project1\Project1\Source.cpp(5,1): message : This diagnostic occurred while importing type 'System::IntPtr' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
1
It happens as long as System::IntPtr is used. For example, add a function in c++/cli project:
void test(System::IntPtr) {}
These code can compile with .NET8 preview versions (preview, rc1, rc2), but fails with today's .NET8 official version 8.0.100
This problem is pretty urgent for us because our product is very close to the release date (we were waiting for .NET8 official release). Could you please take a look right now? Is there any workaround that we can use to make build pass?
I have encountered this problem in one .NET8 daily build months ago (#88840 (comment)), then it was gone. I don't understand why it comes back in today's official version.
Just FYI, I also reported a similar bug dotnet/winforms#9644, it's not urgent.
Reproduction Steps
create c++/cli project in VS.
add function:
void test(System::IntPtr) {}
build fails
Expected behavior
build should pass
Actual behavior
build fails
Regression?
Yes, it's good in .NET8 preview versions.
Known Workarounds
No response
Configuration
No response
Other information
No response
Activity
tannergooding commentedon Nov 14, 2023
Could you clarify what version of the C++/CLI build tools you have installed?
I am not able to repro this using the following in VS 17.9 Preview 1:
void test(System::IntPtr) {}toClassLibrary1::Class1inClassLibrary1.hThis was also validated to be resolved in the last preview of VS 17.8. I am currently installing VS 17.8 RTM to see if something broke between the last preview and actual release.
panxn commentedon Nov 14, 2023
@tannergooding Thanks for your reply! I just found it can build with VC toolset 14.38.
I have 14.36, 14.37 and 14.38 installed. 14.36 is the default one. The code can only compile with 14.38.
But the code can compile with 14.36 in previous net8 preview versions. What is changed? Could I go back to the old compiler behavior? I ask this question because it's almost impossible for us to use 17.8 immediately because time is very limited.
tannergooding commentedon Nov 14, 2023
Visual Studio 2022 17.8 is the minimum version required to work with .NET 8
C++/CLI had to update to support a particular feature of
static virtuals in interfacesthat they did not previously support as we needed to take advantage of it in .NET 8.This lack of support in C++/CLI was found back around .NET 8 Preview 4-5, at which point we temporarily removed the neded API. This was added back for RTM once the C++/CLI fix landed (which was only in the last preview of VS 2022 17.8).
panxn commentedon Nov 14, 2023
Is there any workaround that I can use? Is it possible for me to "temporarily removed the needed API" like you did? We have no enough time.
tannergooding commentedon Nov 14, 2023
There is not.
If you are targeting .NET 8 and using C++/CLI, then you need C++/CLI 14.38. This necessitates using VS 2022 17.8.
panxn commentedon Nov 14, 2023
I see. Thanks for your help!