簡體   English   中英

在Xamarin.Forms中使用StructureMap

[英]Using StructureMap with Xamarin.Forms

我正在開發基於Xamarin Forms的跨平台應用程序。 在我的應用程序中,我想將StructureMap用於IoC。

我做了一個示例應用程序。 一旦添加StructureMap軟件包(4.6.1),我在部署時會收到錯誤消息:

同步文件...構建和運行...內置1條消息。 (1,1):錯誤:無法從流中加載程序集:System.AggregateException:發生一個或多個錯誤。 ---> System.AggregateException:發生一個或多個錯誤。 ---> System.IO.DirectoryNotFoundException:找不到路徑“ /data/user/0/com.xamarin.live/files/External/.nuget/packages/system.runtime.loader/4.3.0的一部分/ref/netstandard1.5/System.Runtime.Loader.dll”。 在System.IO.FileStream..ctor(System.String路徑,System.IO.FileMode模式,System.IO.FileAccess訪問,System.IO.FileShare共享,System.Int32 bufferSize,System.Boolean匿名,System.IO。 FileOptions選項)在System.IO.FileStream..ctor的<896ad1d315ca4ba7b117efb8dacaedcf>:0中的[0x0017d](System.String路徑,System.IO.FileMode模式,System.IO.FileAccess訪問,System.IO.FileShare共享)[0x00000 ],位於<896ad1d315ca4ba7b117efb8dacaedcf>中,位於(包裝帶檢查的遠程調用)System.IO.FileStream:.ctor(字符串,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
在<.896ad1d315ca4ba7b117efb8dacaedcf>:0的System.IO.File.OpenRead(System.String路徑)[0x00000]處.. $ LocalFileSystem + Upsight-IFileSystem-OpenReadAsync @ 49-1。在(5a7d391011b47c3aa7450383d97d5在System.Threading.Tasks.Task 1[TResult].InnerInvoke () [0x0000f] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Threading.Tasks.Task.Execute () [0x00010] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 --- End of inner exception stack trace --- --- End of inner exception stack trace --- ---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path "/data/user/0/com.xamarin.live/files/External/.nuget/packages/system.runtime.loader/4.3.0/ref/netstandard1.5/System.Runtime.Loader.dll". at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0017d] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
at System.IO.File.OpenRead (System.String path) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at <StartupCode$Continuous-Core-Droid>.$LocalFileSystem+Upsight-IFileSystem-OpenReadAsync@49-1.Invoke () [0x00012] in <5a7d391011b47c3aa745038310397d5a>:0 at System.Threading.Tasks.Task
1[TResult].InnerInvoke () [0x0000f] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Threading.Tasks.Task.Execute () [0x00010] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 --- End of inner exception stack trace --- --- End of inner exception stack trace --- ---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path "/data/user/0/com.xamarin.live/files/External/.nuget/packages/system.runtime.loader/4.3.0/ref/netstandard1.5/System.Runtime.Loader.dll". at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0017d] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
at System.IO.File.OpenRead (System.String path) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at <StartupCode$Continuous-Core-Droid>.$LocalFileSystem+Upsight-IFileSystem-OpenReadAsync@49-1.Invoke () [0x00012] in <5a7d391011b47c3aa745038310397d5a>:0 at System.Threading.Tasks.Task
1[TResult].InnerInvoke () [0x0000f] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Threading.Tasks.Task.Execute () [0x00010] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 --- End of inner exception stack trace --- --- End of inner exception stack trace --- ---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path "/data/user/0/com.xamarin.live/files/External/.nuget/packages/system.runtime.loader/4.3.0/ref/netstandard1.5/System.Runtime.Loader.dll". at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0017d] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
at System.IO.File.OpenRead (System.String path) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at <StartupCode$Continuous-Core-Droid>.$LocalFileSystem+Upsight-IFileSystem-OpenReadAsync@49-1.Invoke () [0x00012] in <5a7d391011b47c3aa745038310397d5a>:0 at System.Threading.Tasks.Task
1 [TResult] .InnerInvoke()在[896ad1d315ca4ba7b117efb8dacaedcf>:0中的[0x0000f]在System.Threading.Tasks.Task.Execute(0)中<896ad1d315ca4ba7b117efb8dacaedcf>:0 ---內部異常堆棧跟蹤結束--- --->(內部異常#0)System.IO.DirectoryNotFoundException:找不到路徑“ / data / user / 0 / com”的一部分.xamarin.live /文件/外部/ .nuget /包/ system.runtime.loader / 4.3.0 / REF / netstandard1.5 / System.Runtime.Loader.dll”。
在System.IO.FileStream..ctor(System.String路徑,System.IO.FileMode模式,System.IO.FileAccess訪問,System.IO.FileShare共享,System.Int32 bufferSize,System.Boolean匿名,System.IO。 FileOptions選項)在System.IO.FileStream..ctor的<896ad1d315ca4ba7b117efb8dacaedcf>:0中的[0x0017d](System.String路徑,System.IO.FileMode模式,System.IO.FileAccess訪問,System.IO.FileShare共享)[0x00000 ],位於<896ad1d315ca4ba7b117efb8dacaedcf>中,位於(包裝帶檢查的遠程調用)System.IO.FileStream:.ctor(字符串,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
在<.896ad1d315ca4ba7b117efb8dacaedcf>:0的System.IO.File.OpenRead(System.String路徑)[0x00000]處.. $ LocalFileSystem + Upsight-IFileSystem-OpenReadAsync @ 49-1。在(5a7d391011b47c3aa7450383d97d5在System.Threading.Tasks.Task`1 [TResult] .InnerInvoke()[0x0000f]在<896ad1d315ca4ba7b117efb8dacaedcf>:0在System.Threading.Tasks.Task.Execute()[0x00010]在<896ad1d315ca4ba7b117efb8dacaedcf>:0 -<---

無法調試您的應用程序。

我使用Visual Studio 2017(15.7.1)和Xamarin Forms 3.0.0.482510。

Entity Framerwork Core SQLite也有相同類型的問題

您是否遇到過此錯誤?

我建議您不要在Xamarin.Forms上使用StructureMap,因為它不受支持:

StructureMap 4.5+在Xamarin iOS上不起作用,因為它依賴於System.Reflection.Emit,而MonoTouch中不提供。 StructureMap 4.4至少適用於該平台上的基本方案。 目前,StructureMap核心團隊中沒有人正在使用Xamarin移動運行時,但是,如果有志願者願意幫助我們,我們有興趣在新平台上驗證StructureMap。

http://structuremap.github.io/get-structuremap/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM