locked
unresolved external symbol "public: virtual class Platform::String ^

    Question

  • I'm venturing into C++ to create WinRT Component DLL. It has been some time since I used C++, so please be gentle.

    I'm trying to create a method that returns a String that I can use in my C# app. I'm getting the error:

    unresolved external symbol "public: virtual class Platform::String ^ ...

    I tried including vcorlib.h thinking that's where Platfom::String lives, but that just made things worse.

    Here is my code:

    Test.h

    #pragma once namespace MyTest { public ref class Test sealed { public: Test(); Platform::String^ Hello(); }; }

    Test.cpp

    #include "pch.h"
    #include "Test.h"
    
    using namespace MyTest;
    using namespace Platform;
    
    
    Test::Test()
    {
    }
    
    String^ Hello()
    {
    	String^ str = "hello"; 
    	return str;
    }





    • Edited by Richard Garside Thursday, April 12, 2012 6:27 AM Indication that error message was longer
    Wednesday, April 11, 2012 11:56 AM

Answers

  • Hello,

    The Hello function should be in the Test class. When you implement it, you should add the class name like

    String^ Test::Hello()
    {
    	String^ str = "hello"; 
    	return str;
    }

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, April 12, 2012 5:08 AM