1

Im trying to create a C++ Runtime compoment to use in c# windows store app project;

I Created a new project C++ -> Windows Store App -> Windows Runtime Component. The new project has default class1.

This is what i m trying to do and i get error:

Class1.h:

public ref class Class1 sealed
{
public:
    Class1();
            Windows::Foundation::IAsyncOperation<Windows::UI::Xaml::Media::Imaging::BitmapImage^>^ StreamToBitmap(Windows::Storage::Streams::IRandomAccessStream^ fileStream);

};

Class1.cpp:

Class1::Class1()
{
}



IAsyncOperation<BitmapImage^>^ StreamToBitmap(IRandomAccessStream^ fileStream)
{
    return create_async([=]()
    {
        auto bitmapImage = ref new BitmapImage();
        bitmapImage->SetSource(fileStream);
        return bitmapImage;

    });

}

Error

Error 2 error LNK2019: unresolved external symbol "public: virtual struct Windows::Foundation::IAsyncOperation ^ cdecl TestRuntimeC_toCS::Class1::[TestRuntimeC_toCS::_IClass1PublicNonVirtuals]::LoadImage(struct Windows::Storage::Streams::IRandomAccessStream ^)" (?LoadImage@?Q_IClass1PublicNonVirtuals@TestRuntimeC__toCS@@Class1@2@U$AAAP$AAU?$IAsyncOperation@P$AAVBitmapImage@Imaging@Media@Xaml@UI@Windows@@@Foundation@Windows@@P$AAUIRandomAccessStream@Streams@Storage@6@@Z) referenced in function "public: virtual long _stdcall TestRuntimeC_toCS::Class1::[TestRuntimeC_toCS::_IClass1PublicNonVirtuals]::__abi_TestRuntimeC__toCSIClass1PublicNonVirtuals_abi_LoadImage(struct Windows::Storage::Streams::IRandomAccessStream ^,struct Windows::Foundation::IAsyncOperation ^ *)" (?__abi_TestRuntimeC__toCSIClass1PublicNonVirtuals___abi_LoadImage@?Q_IClass1PublicNonVirtuals@TestRuntimeC_toCS@@Class1@2@U$AAGJP$AAUIRandomAccessStream@Streams@Storage@Windows@@PAP$AAU?$IAsyncOperation@P$AAVBitmapImage@Imaging@Media@Xaml@UI@Windows@@@Foundation@7@@Z) C:\Users\Stamatis\Documents\Visual Studio 2013\Projects\TestRuntimeC++toCS\TestRuntimeC++toCS\Class1.obj TestRuntimeC++toCS

Stamos
  • 3,938
  • 1
  • 22
  • 48
  • Do you have `LoadImage` anywhere in your code? – Filip Skakun Apr 14 '14 at 05:48
  • No not yet. I will call it from a c# project but i cant complile this one. – Stamos Apr 14 '14 at 22:59
  • Well, the code seems to be complaining about the missing `LoadImage` implementation, so I thought that's what's missing. – Filip Skakun Apr 14 '14 at 23:15
  • So I m missing some include?Any ideas what I need? btw if i put it in private it work but i need public so i can call.Thanks and sorry for the inconvenience. – Stamos Apr 14 '14 at 23:48
  • Not sure. Just trying to parse that error message. It seems like maybe there is a `LoadImage()` method declared in some header file in your solution, but not implemented anywhere. Then again maybe it's just that something doesn't like the `++` in your project path. – Filip Skakun Apr 15 '14 at 01:30

0 Answers0