Windows 저장소에 대한 전자 북 관리자를 구축하고 있으며 클래스 중 하나에서 IUriToStreamResolver 인터페이스를 구현했습니다. 나는 그것을 사용하여 epub을 엽니 다. 다음과 같이 코드는 다음과 같습니다System.InvalidCast 예외 Windows 런타임
public IAsyncOperation<IInputStream> UriToStreamAsync(Uri uri)
{
if(uri == null)
{
throw new Exception();
}
string path = uri.AbsolutePath;
return GetContent(path).AsAsyncOperation();
}
private async Task<IInputStream> GetContent(string path)
{
path = path.TrimStart('/');
var file = await StorageApplicationPermissions.FutureAccessList.GetFileAsync(App.token);
var stream = await file.OpenAsync(FileAccessMode.Read);
var archive = new ZipArchive(stream.AsStream());
var entry = archive.Entries.Where(a => a.FullName == path);
var entryStream = entry.First().Open();
return entryStream.AsInputStream();
}
GetContent()
방법에서 돌아온 후 나는 비밀 System.InvalidCast 예외를 얻을. 내가 좀 더 많은 정보를 얻을 수 있다고 생각한 혼합 된 디버깅을 가능하게 만들었지 만별로 도움이되지 않습니다. !
combase.dll RoFailFastWithErrorContextInternal (긴 부호 길이 구조체 _STOWED_EXCEPTION_INFORMATION_V1 * CONST) 알 [email protected]() 알 twinapi.appcore.dll : 여기
스택 인 Windows :: ApplicationModel :: Core :: CoreApplication :: ForwardLocalError (IRestrictedErrorInfo * 구조체) 알 수 없음 twinapi.appcore.dll Windows :: ApplicationModel :: Core :: CoreApplicationFactory :: ForwardLocalError (구조체 IRestrictedErrorInfo *) 알 수 없음 combase.dll ! CallErrorForwarder (void *, int, struct IRestrictedErrorInfo *) 알 수 없음 combase.dll! [email protected]() 알 수 없음 mscorlib.ni.dll! 63eb2d62() 알 수 없음 [아래 프레임이 틀리거나 누락되거나 mscorlib.ni.dll에 심볼이로드되지 않음]
[Managed to Native 전환]
가 mscorlib.dll! System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeMarshal.RoReportUnhandledError (System.Runtime.InteropServices.WindowsRuntime.IRestrictedErrorInfo 오류) 알 수없는 가 mscorlib.dll! System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeMarshal.ReportUnhandledError (시스템 .Exception e) 알 수 없음 System.Runtime.WindowsRuntime.dll! System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore() Unknown System.Runtime.WindowsRuntime.dll! System.Threading.WinRTSynchronizationContext.Invo ker.InvokeInContext (개체 thisObj) 알 수 없음 mscorlib.dll! System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback 콜백, 개체 상태, bool preserveSyncCtx) 알 수 없음 mscorlib.dll! System.Threading .ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback 콜백, 개체 상태, bool preserveSyncCtx) 알 수 없음 System.Runtime.WindowsRuntime.dll! System.Threading.WinRTSynchronizationContext.Invoker.Invoke() 알 수 없음 [네이티브 (Windows) :: UI :: Core :: CDispatcher :: ProcessInvokeItem() 줄 794 C++ Windows.UI.dll :: Core :: CDispatcher :: WaitAndProcessMessages (void * hEventWait) C++ Windows.UI.dll! Windows :: UI :: Core :: CDispatcher :: ProcessEvents (Windows :: UI :: Core :: CoreProcessEventsOption 옵션 = CoreProcessEventsOption_ProcessUntilQuit) Line 390 C++ Windows.UI.Xaml.dll! DirectUI :: FrameworkView :: 실행() 알 수 없음 twinapi.appcore.dll Windows :: ApplicationModel :: Core :: CoreApplicationView :: Run (void) Unknown twinapi.appcore.dll Windows :: Foundation :: Collections :: Internal :: HashMap , 구조체 Windows :: Foundation :: Collections :: Internal :: DefaultEqualityPredicate, 구조체 Windows :: Foundation :: Collections :: Internal :: DefaultLifetimeTraits, 구조체 Windows :: ApplicationModel :: Core :: Details :: SmugglableInterfaceLifetimeTraits, Windows :: Foundation :: Collections :: Internal :: HashMapOptions, 0,1,0> :: :: Remove (unsigned int) Unknown SHCore.dll!Microsoft :: WRL :: RuntimeClass, 클래스 CScalingInfoBase, 구조체 ICurrentWindowChangeListener, 클래스 :: Microsoft :: WRL :: FtmBase 클래스 :: Microsoft :: WRL :: 정보 :: Nil, 클래스 Microsoft :: WRL :: 정보 :: 없음 클래스 Microsoft : : WRL :: Details :: Nil, 클래스 Microsoft :: WRL :: Details :: Nil, 클래스 Microsoft :: WRL :: Details :: Nil, 클래스 Microsoft :: WRL :: Details :: 없음 :: ::`벡터 삭제 소멸자 '(서명 int)를 알 수없는 KERNEL32.DLL! @ BaseThreadInitThunk 12() 알 수없는 NTDLL.DLL @! __ RtlUserThreadStart() 알 수없는 NTDLL.DLL! __ 8() 알 수없는
그리고 여기가 아니라 RtlUserThreadStart @ 지역 : $ 예외 스택
[9 Frames, [email protected]()]
[0] [email protected]() void*
[1] mscorlib.ni.dll!63eb2c8a() void*
[2] mscorlib.ni.dll!63f4ffa2() void*
[3] mscorlib.ni.dll!63f4fd61() void*
[4] System.Runtime.WindowsRuntime.ni.dll!506ef9df() void*
[5] System.Runtime.WindowsRuntime.ni.dll!506ef965() void*
[6] mscorlib.ni.dll!63823156() void*
[7] System.Runtime.WindowsRuntime.ni.dll!506ef934() void*
[8] Windows.UI.ni.dll!50e1ff16() void*
도움이나 의견을 보내 주시면 감사하겠습니다.
나는이'WindowsRuntime Interop'의 확장 기능 중 하나로서이,()'stream.AsStream'의 사용의 돈을 내기 것입니다. 나는'StorageFile'이'file.OpenStreamForReadAsync()'또는'stream.AsStreamForRead()'와 같은 자체적 인 확장을 가져야한다고 생각한다. –
나는 컴파일 할 확장 메소드의 모든 조합을 시도했으며 동일한 결과를 얻었다. –
OneDrive에있는 파일 (SkyDrive의 새 이름)에 액세스하려고하십니까? –