Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

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

	};
}


Class1.cpp:


C++
Class1::Class1()
{
}

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

	});
		
}


Errors:

Error	2	error LNK2019: unresolved external symbol "public: virtual struct Windows::Foundation::IAsyncOperation<class Windows::UI::Xaml::Media::Imaging::BitmapImage ^> ^ __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__toCS___IClass1PublicNonVirtuals____abi_LoadImage(struct Windows::Storage::Streams::IRandomAccessStream ^,struct Windows::Foundation::IAsyncOperation<class Windows::UI::Xaml::Media::Imaging::BitmapImage ^> ^ *)" (?__abi_TestRuntimeC__toCS___IClass1PublicNonVirtuals____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
Posted
Updated 13-Apr-14 7:06am
v3
Comments
Richard MacCutchan 14-Apr-14 4:22am    
The declaration in your header file is not matched by the implementation in your source code. Use proper meaningful class names and ensure that both definitions are the same.

1 solution

Looks like all you need to do would be to change
C++
IAsyncOperation<BitmapImage^>^ StreamToBitmap(IRandomAccessStream^ fileStream)

to:
C++
IAsyncOperation<BitmapImage^>^ Class1::StreamToBitmap(IRandomAccessStream^ fileStream)

in your Class1.cpp file.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900