-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Breaking change] .NET 7 with C++/CLI requires Visual Studio 2022 17.2 Preview 2 #28542
Comments
0 I'm trying to use: I seem to be getting a similar error. @gewarren? I've been able to compile some csproj projects but for my vcxproj I am getting: 6>C:\Development\Source\ApmUpdateDotNet7\framework\oqkern\shared\ManagedDateTime.cpp(31,4): error C2220: the following warning is treated as an error 6>C:\Development\Source\ApmUpdateDotNet7\framework\oqkern\shared\ManagedDateTime.cpp(31,4): warning C4679: 'Parse': could not import member 6>C:\Development\Source\ApmUpdateDotNet7\framework\oqkern\shared\ManagedDateTime.cpp(31,4): message : static virtual methods of interfaces are not supported and will be unavailable 6>C:\Development\Source\ApmUpdateDotNet7\framework\oqkern\shared\ManagedDateTime.cpp(31,4): message : This diagnostic occurred while importing type 'System::IParsable' from assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. |
@tannergooding Can you take a look at @DerekSMorin's situation and advise? |
This is expected. C++/CLI changed what was a hard error into a warning. You likely have |
Thanks @tannergooding - I ended up having to disable 4679 and thanks to your help I managed to get things compiling. |
Visual Studio = Version 17.5.3 I'm getting a bunch of of errors like this one when trying to compile my C++/CLI project with .NET 7:
Here's the line on which the error above occurs: I read the post here: https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/7.0/cpluspluscli-compiler-version I thought that using the latest VS2022 would fix this issue, but it didn't. And in my case, it's not warning considered as error type thing like @DerekSMorin so I can't disable any warning to make it compile. Any advice? UPDATE |
Hello, We are getting similar error (not a warning) on our C++/CLI projects moving from .NET 6 to .NET 8.
The article pointed by @mo-russo doesn't seem to explicitly suggest to move to Platform Toolset v143. Is this the case ? |
In general each new version of .NET requires the latest version of VS, VSCode, Rider, etc and the latest version of various other toolchains, such as C++. It's entirely possible they partially work on older versions, but the experience will often be subpar or may break down when encountering various edges or newly introduced APIs, language or runtime features, etc (if you're on an older IDE, then IntelliSense may not be up to date with the actual build for example). .NET 8 requires C++/CLI v143 and VS 2022 v17.8.0 or later core types, such as |
Thanks @tannergooding for your explanation. |
I am not aware of any workaround. C++/CLI required changes to support newer runtime features, such as |
Description
Starting in .NET 7 Preview 3, Visual Studio 2022 17.2 Preview 2+ must be used for C++/CLI projects.
.NET 7 Preview 3 includes "Generic Math" APIs that use
static abstract
interface members on primitive types such asSystem.Int32
; earlier versions of the C++/CLI compiler were incompatible with such members. Because those members are used on many primitive types, compilation errors will occur when targetingnet7.0
even if the Generic Math features are not used directly.Beyond C++/CLI, it's also possible that the introduction of
static abstract
interface members on primitiveSystem
types will surface issues in other tools that are not forward-compatible with the usage of this new language construct. As was done with C++/CLI, any other tools impacted by this change will need to be updated to accommodate the usage ofstatic abstract
interface members. If needed on such issues, tool authors should file a New Issue · dotnet/runtime to request guidance.Pull Request: Moving "Generic Math" in box and making it no longer experimental by tannergooding · Pull Request #65731 · dotnet/runtime
Version
.NET 7 Preview 3
Previous behavior
Compiling .NET projects using C++/CLI would not result in errors related to members on primitive
System
types.New behavior
Compiling a .NET 7 Preview 3
net7.0
project using C++/CLI in an earlier release of Visual Studio will result in many errors similar to this example:There is no way to work around this compiler error as it's generated because of
static abstract
interface members on primitiveSystem
types. By upgrading to Visual Studio 2022 17.2 Preview 2+, the compilation errors will no longer occur.Implicitly-implemented
static abstract
interface members can be invoked, but even with Visual Studio 2022 17.2 Preview 2+ C++/CLI does not support invoking explicitly-implementedstatic abstract
interface members.Type of breaking change
Reason for change
.NET 7 Preview 3 includes the new API definitions for the "Generic Math" feature set. These APIs were introduced in .NET 6 as a preview feature, requiring an additional
System.Runtime.Experimental
package to be installed to gain access to the APIs. Those APIs are being included in-box with .NET 7 Preview 3 with further stabilization and refinement to come in later .NET 7 previews.See Developers can use Generic Math without enabling preview features · Issue #63548 · dotnet/runtime for more information.
Recommended action
Upgrade to Visual Studio 2022 17.2 Preview 2+ to continue using C++/CLI with .NET 7 Preview 3+. See Visual Studio 2022 Preview Release Notes | Microsoft Docs for more information and downloads.
Feature area
Core .NET libraries
Affected APIs
No response
The text was updated successfully, but these errors were encountered: