简体   繁体   English

在Xamarin.Forms中使用StructureMap

[英]Using StructureMap with Xamarin.Forms

I am developping a cross-platform application based on Xamarin Forms. 我正在开发基于Xamarin Forms的跨平台应用程序。 In my application, I want to use StructureMap for IoC. 在我的应用程序中,我想将StructureMap用于IoC。

I made a sample application. 我做了一个示例应用程序。 As soon as I add StructureMap package (4.6.1), I get an error on deploy : 一旦添加StructureMap软件包(4.6.1),我在部署时会收到错误消息:

Synchronizing files... Building and running... Built with 1 messages. 同步文件...构建和运行...内置1条消息。 (1,1): error: Failed to load assembly from stream: System.AggregateException: One or more errors occurred. (1,1):错误:无法从流中加载程序集:System.AggregateException:发生一个或多个错误。 ---> System.AggregateException: One or more errors occurred. ---> System.AggregateException:发生一个或多个错误。 ---> 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". ---> 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”。 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) 在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)
at System.IO.File.OpenRead (System.String path) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at .$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
在<.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 () [0x0000f] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at System.Threading.Tasks.Task.Execute () [0x00010] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 --- End of inner exception stack trace --- ---> (Inner Exception #0) 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".
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”。
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) 在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)
at System.IO.File.OpenRead (System.String path) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at .$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 <--- <--- 在<.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 -<---

Failed to debug your app. 无法调试您的应用程序。

I use Visual Studio 2017 (15.7.1) and Xamarin Forms 3.0.0.482510. 我使用Visual Studio 2017(15.7.1)和Xamarin Forms 3.0.0.482510。

I also have the same type of issue with Entity Framerwork Core SQLite Entity Framerwork Core SQLite也有相同类型的问题

Have you ever encountered this error ? 您是否遇到过此错误?

I would suggest you don't use StructureMap on Xamarin.Forms as it is unsupported: 我建议您不要在Xamarin.Forms上使用StructureMap,因为它不受支持:

StructureMap 4.5+ will not work on Xamarin iOS because it depends on System.Reflection.Emit, which is not available in MonoTouch. StructureMap 4.5+在Xamarin iOS上不起作用,因为它依赖于System.Reflection.Emit,而MonoTouch中不提供。 StructureMap 4.4 works for at least basic scenarios on that platform. StructureMap 4.4至少适用于该平台上的基本方案。 Nobody in the core StructureMap team is currently working with Xamarin mobile runtimes, but we are interested in verifying StructureMap on new platforms if any volunteers are interested in helping us out. 目前,StructureMap核心团队中没有人正在使用Xamarin移动运行时,但是,如果有志愿者愿意帮助我们,我们有兴趣在新平台上验证StructureMap。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM