【发布时间】:2019-04-21 11:28:54
【问题描述】:
在我继续努力在 C++/winrt 中加载一组 .svg 文件时,我遇到了一个神秘的链接错误。我想尝试使用 CanvasSvgDocument.ReadAsync(resourceCreator, filestream)。要到达那里,首先需要从 StorageFile 获取流,这似乎是实现它的方法(nextFile,一个 StorageFile,在本示例中已加载)。这当然是在定义为 IAsyncAction 的方法中。我将从文件顶部列出#includes 和命名空间。
#include "winrt/Windows.ApplicationModel.h"
#include "winrt/Windows.Storage.h"
#include "winrt/Windows.Storage.Streams.h"
#include "winrt/Windows.Foundation.Collections.h"
#include "winrt/Windows.Storage.Search.h"
#include "winrt/Windows.UI.Core.h"
#include "winrt/Windows.UI.Xaml.Media.h"
#include "pch.h"
using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::Storage;
using namespace Windows::Storage::Provider;
using namespace Windows::Storage::Search;
using namespace Windows::Storage::Streams;
这是有问题的调用:
IRandomAccessStreamWithContentType fileStream = co_await nextFile.OpenReadAsync();
这会产生一个链接错误,我将在下面输入。我是否尝试使用 fileStream 结果的完全限定名称并不重要:
winrt::Windows::Storage::Streams::IRandomAccessStreamWithContentType fileStream = co_await nextFile.OpenReadAsync();
无论哪种方式我都会收到此链接错误:
错误 LNK2019 未解析的外部符号“public: struct winrt::Windows::Foundation::IAsyncOperation __thiscall winrt::impl::consume_Windows_Storage_Streams_IRandomAccessStreamReference::OpenReadAsync(void)const " (?OpenReadAsync@?$consume_Windows_Storage_Streams_IRandomAccessStreamReference@UIStorageFile@Storage@Windows@winrt@@@impl@winrt@@QBE?AU?$IAsyncOperation@UIRandomAccessStreamWithContentType@Streams@Storage@Windows@winrt@@@Foundation@Windows@3@XZ) 在函数“public: struct”中引用 winrt::Windows::Foundation::IAsyncAction __thiscall AppEngine::ResourceManager::LoadSvgResources$_ResumeCoro$2(结构 winrt::Microsoft::Graphics::Canvas::UI::Xaml::CanvasControl)" (?LoadSvgResources$_ResumeCoro$2@ResourceManager@AppEngine@@QAE?AUIAsyncAction@Foundation@Windows@winrt@@UCanvasControl@Xaml@UI@Canvas@Graphics@Microsoft@6@@Z)
我也尝试过使用 auto 作为结果类型,但没有成功。在 C++/winrt 中使用 OpenReadAsync() 获取流的正确方法是什么?
【问题讨论】: