Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. .NET 5?

.NET 5?

Scheduled Pinned Locked Moved Managed C++/CLI
dotnethelpcsharpc++question
8 Posts 5 Posters 21 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John Schroedl
    wrote on last edited by
    #1

    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

    Richard Andrew x64R 1 Reply Last reply
    0
    • J John Schroedl

      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

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      I'm interested in this question. Did you find an answer?

      The difficult we do right away... ...the impossible takes slightly longer.

      J 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        I'm interested in this question. Did you find an answer?

        The difficult we do right away... ...the impossible takes slightly longer.

        J Offline
        J Offline
        John Schroedl
        wrote on last edited by
        #3

        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.

        D 1 Reply Last reply
        0
        • J John Schroedl

          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.

          D Offline
          D Offline
          Doug Milne 2021
          wrote on last edited by
          #4

          We've run into the same linker problem, porting an application to .net5. Did you ever get a resolution to this issue?

          J 1 Reply Last reply
          0
          • D Doug Milne 2021

            We've run into the same linker problem, porting an application to .net5. Did you ever get a resolution to this issue?

            J Offline
            J Offline
            John Schroedl
            wrote on last edited by
            #5

            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.

            D 1 Reply Last reply
            0
            • J John Schroedl

              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.

              D Offline
              D Offline
              Doug Milne 2021
              wrote on last edited by
              #6

              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) { }

              D 1 Reply Last reply
              0
              • D Doug Milne 2021

                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) { }

                D Offline
                D Offline
                D Milne
                wrote on last edited by
                #7

                We submitted an ticket with Microsoft and they have acknowledged this as a bug. I will update with any additional information.

                L 1 Reply Last reply
                0
                • D D Milne

                  We submitted an ticket with Microsoft and they have acknowledged this as a bug. I will update with any additional information.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  If you are also Doug Milne 2021, then you should close one of these accounts.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups