2

With the following class in one c++/cli project:

class __declspec(dllimport) MyClass
{
public:
    void Test(std::function<void()> operation)
    {
        operation();
    }
}

And a caller in another c++/cli project:

myClass.Test([](){});
myClass.Test([](){});
myClass.Test([](){});

I get the following error (twice):

LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std.tr1._Callable_obj<`anonymous namespace'::,0>): (0x02000490).

I do not get the error when calling Test only twice!

myClass.Test([](){});
myClass.Test([](){});

//COMPILES FINE!
//myClass.Test([](){});

I've tried switching off managed incremental building as per "LNK2022: metadata operation failed" driving me insane. However, the errors still occur.

I'm building in VS2013 but using the Visual Studio 2010 (v100) Platform Toolset.

Community
  • 1
  • 1
James Bateson
  • 1,069
  • 13
  • 20
  • Hmm, I'm not buying the 2 vs 3 lambdas scenario, you'll have to call Microsoft Support to get help with that. It is however the kind of linker error you get when you link code that was built with VS2013 with other code built with VS2010. – Hans Passant May 21 '15 at 10:53

0 Answers0