.NET 5?
-
Has anyone tackled moving a project using C++/CLI to target .NET 5? After struggling with the project settings, I am very close as everything compiles and resolves references now. But, I'm stuck with a useless link error. Adding /VERBOSE and /VERBOSE:CLR don't add any more info. Just wondering if it's supported or not.. FWIW, here's the link error. There is usually a message after the
"(80131195) :"
12>MSVCMRTD_netcore.LIB(mstartup.obj) : error LNK2022: metadata operation failed (80131195) :
12>LINK : fatal error LNK1255: link failed because of metadata errors
12>Done building project "JmpCLR.vcxproj" -- FAILED.John
-
Has anyone tackled moving a project using C++/CLI to target .NET 5? After struggling with the project settings, I am very close as everything compiles and resolves references now. But, I'm stuck with a useless link error. Adding /VERBOSE and /VERBOSE:CLR don't add any more info. Just wondering if it's supported or not.. FWIW, here's the link error. There is usually a message after the
"(80131195) :"
12>MSVCMRTD_netcore.LIB(mstartup.obj) : error LNK2022: metadata operation failed (80131195) :
12>LINK : fatal error LNK1255: link failed because of metadata errors
12>Done building project "JmpCLR.vcxproj" -- FAILED.John
I'm interested in this question. Did you find an answer?
The difficult we do right away... ...the impossible takes slightly longer.
-
I'm interested in this question. Did you find an answer?
The difficult we do right away... ...the impossible takes slightly longer.
Unfortunately not. The best (only) write-up I've found specifically dealing with targeting .NET 5 from C++/CLI code is this one from "Mike" at Microsoft. Porting a C++/CLI Project to .NET Core That allowed me to get past some of the early build issues I encountered. But, I still have no way of diagnosing the remaining linker error. I am looking at other changes right now but will return to this sometime soon. I may have to resort to using one of my MSDN Premier tickets on the issues.
-
Unfortunately not. The best (only) write-up I've found specifically dealing with targeting .NET 5 from C++/CLI code is this one from "Mike" at Microsoft. Porting a C++/CLI Project to .NET Core That allowed me to get past some of the early build issues I encountered. But, I still have no way of diagnosing the remaining linker error. I am looking at other changes right now but will return to this sometime soon. I may have to resort to using one of my MSDN Premier tickets on the issues.
We've run into the same linker problem, porting an application to .net5. Did you ever get a resolution to this issue?
-
We've run into the same linker problem, porting an application to .net5. Did you ever get a resolution to this issue?
Hi Doug, No. I've tried various things and each attempt ends up with this inscrutable linker error. I have not opened a MSDN premier support ticket yet due to other work deadlines but I plan to when I can focus on this again. I tried to get help on twitter but all point me to opening a devcommunity ticket + prayer. I will add a reply here if I manage to get further. Please let me know if you find a way to diagnose the issue as well. I plan to try VS 2022 preview 3 which dropped yesterday as well though confidence is not high that they touched the C++/CLI compiler/linker at all since 2017.
-
Hi Doug, No. I've tried various things and each attempt ends up with this inscrutable linker error. I have not opened a MSDN premier support ticket yet due to other work deadlines but I plan to when I can focus on this again. I tried to get help on twitter but all point me to opening a devcommunity ticket + prayer. I will add a reply here if I manage to get further. Please let me know if you find a way to diagnose the issue as well. I plan to try VS 2022 preview 3 which dropped yesterday as well though confidence is not high that they touched the C++/CLI compiler/linker at all since 2017.
Hi John, We've narrowed down the problem to the use of gcroot as a parameter method in an unmanaged class. Using gcroot seems to be okay. See below for a contrived example. Given the nature of the error, it may not be related your problem. // fails when cpp is compiled with /clr:dotnetcore // succeeds when cpp is compiled with /clr #pragma once #include class UnmanagedClassWithGcHandle { public: int age; // error LNK2022 : metadata operation failed(80131195) : ( ONLY TARGETING .NET 5.0 ) void foobar(gcroot); // this is successful void foobar2(gcroot); }; void UnmanagedClassWithGcHandle::foobar(gcroot) { } void UnmanagedClassWithGcHandle::foobar2(gcroot) { }
-
Hi John, We've narrowed down the problem to the use of gcroot as a parameter method in an unmanaged class. Using gcroot seems to be okay. See below for a contrived example. Given the nature of the error, it may not be related your problem. // fails when cpp is compiled with /clr:dotnetcore // succeeds when cpp is compiled with /clr #pragma once #include class UnmanagedClassWithGcHandle { public: int age; // error LNK2022 : metadata operation failed(80131195) : ( ONLY TARGETING .NET 5.0 ) void foobar(gcroot); // this is successful void foobar2(gcroot); }; void UnmanagedClassWithGcHandle::foobar(gcroot) { } void UnmanagedClassWithGcHandle::foobar2(gcroot) { }
-
We submitted an ticket with Microsoft and they have acknowledged this as a bug. I will update with any additional information.