Adding a property gives error LNK2022

Hi!

In a pure C++/CLI application developed with VS 2005 Proff final, I get sometimes the next error:

I add a property like

property bool StatusbarVisible{
bool get(void){return layoutConfig->statusbarVisible;}void set(bool value){layoutConfig->statusbarVisible=value;}

}



Then the linker gives several times the next error

Error 1 error LNK2022: metadata operation failed (80131187) : Inconsistent method declarations in duplicated types (types: ZXNewtonCP.LayoutManager; methods: get_StatusbarVisible): (0x0600000a). CommandProcessor.obj 

But if I make a rebuild instead a build, it links sucessfully.

Could it be a bug



Answer this question

Adding a property gives error LNK2022

  • John Warner

    BTW, Andrew already logged a bug for the issue and we will try to get it fixed if possible.

    Thanks,
      Ayman Shoukry
      VC++ Team

  • jsc7810

    Please, download my project from here. Open it (Visual Studio 2005) and go to "LayoutManager.h". Delete last property (it is not finished to type). Build the project. You get two errors, that's right.

    Now uncomment last property and build project. 'E voila', 36 LNK2022 errors.

    Now do a rebuild. LNK2022 errors have gone.

    Project zipped only contains Visual Studio projects and text files.


  • Franz Gsell

    Could you post a sample where folks on the forum can reproduce the error

    Thanks,
      Ayman Shoukry
      VC++ Team



  • Rogma

    The problem you are seeing results from the fact that the metadata in AssemblyInfo.obj doesn't match the metadata in all of the other object files. This is because AssemblyInfo.obj isn't being rebuilt after you add the property to LayoutManager.h. The linker is entirely correct to complain but the problem is in the build system or one if its dependencies and the diagnostic points you to a link problem.

    There is a chain of includes which show a dependency between the two files: AssemblyInfo.cpp #includes StdAfx.h which #includes LayoutManager.h. You already have a workaround: rebuild the whole solution.

    Normally files included in the precompiled header should be those which do not change frequently. But VC is not doing the right thing and not providing quality diagnostics.

    Thank you for reporting this issue!

    Andrew Pardoe
    VC++ Team



  • Chris_Wilson

    Hi,
     Some from the VC team is currently looking into the issue and will soon be updating the post with more info.

    Thanks for your patience!

    Thanks,
      Ayman Shoukry
      VC++ Team

  • Bertrand Degoy

    I have the same behaviour here, after modifying the signature of a method I get the LNK2022 error. It's quite frequent, by the way.


  • Adding a property gives error LNK2022