构建一个控制台应用程序(就像TwitterSearch.UI.Console)样本

时间:2013-09-05 20:15:22

标签: mvvmcross

我正在开发一个具有客户端和服务器端的项目。 我正在编写一个“预登记”工具,它将验证我们在客户端和服务器之间的大量通信。

我已经在双方进行了单元测试,现在我真的想测试两者之间的集成。

类似于与服务器的真实客户端连接,反之亦然。

我正在试图看看“TwitterSearch.UI.Console”是如何工作的,因为我认为斜纹布对我来说是一个很好的起点,但在花了一些时间来对抗之后,我想也许最好问专业人士在这里。

我正在使用此处的最新版本: https://github.com/slodge/MvvmCross-Tutorials

与最新的二进制文件配对。

现在这是输出调试溢出:

mvx: Diagnostic:   0.01 Setup: PlatformServices start
mvx: Diagnostic:   0.02 Setup: MvvmCross settings start
mvx: Diagnostic:   0.02 Setup: Singleton Cache start
mvx: Diagnostic:   0.02 Setup: Bootstrap actions
mvx: Diagnostic:   0.05 Setup: StringToTypeParser start
mvx: Diagnostic:   0.05 Setup: ViewModelFramework start
mvx: Diagnostic:   0.05 Setup: PluginManagerFramework start
mvx: Diagnostic:   0.06 Setup: App start
mvx: Diagnostic:   0.07 Loading plugin assembly: Cirrious.MvvmCross.Plugins.Visibility.Wpf
'TwitterSearch.UI.Console.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\fileZ\projZ\samples\MvvmCross-Tutorials\Sample - TwitterSearch\TwitterSearch.UI.Console\bin\Debug\TwitterSearch.Core.dll', Symbols loaded.
'TwitterSearch.UI.Console.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\fileZ\projZ\samples\MvvmCross-Tutorials\Sample - TwitterSearch\TwitterSearch.UI.Console\bin\Debug\Cirrious.MvvmCross.Plugins.Visibility.dll', Symbols loaded.
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'Cirrious.CrossCore.Exceptions.MvxException' occurred in Cirrious.CrossCore.dll

在异常细节中,看起来插件管理器正在解析程序集的名称错误?

他正在尝试加载Cirrious.MvvmCross.Plugins.Visibility.Wpf,而.Console应用引用的是Cirrious.MvvmCross.Plugins.Visibility.Console

以下是例外情况的更多细节:

Cirrious.CrossCore.Exceptions.MvxException was unhandled
  HResult=-2146233088
  Message=Could not load file or assembly 'Cirrious.MvvmCross.Plugins.Visibility.Wpf' or one of its dependencies. The system cannot find the file specified.
  Source=Cirrious.CrossCore
  StackTrace:
       at Cirrious.CrossCore.Plugins.MvxPluginManager.ExceptionWrappedLoadPlugin(Type toLoad) in c:\Projects\Misc\MVVMCROSS\CrossCore\Cirrious.CrossCore\Plugins\MvxPluginManager.cs:line 136
       at Cirrious.CrossCore.Plugins.MvxPluginManager.EnsurePlatformAdaptionLoaded[T]() in c:\Projects\Misc\MVVMCROSS\CrossCore\Cirrious.CrossCore\Plugins\MvxPluginManager.cs:line 87
       at Cirrious.MvvmCross.Plugins.Visibility.PluginLoader.EnsureLoaded() in c:\Projects\Misc\MVVMCROSS\Plugins\Cirrious\Visibility\Cirrious.MvvmCross.Plugins.Visibility\PluginLoader.cs:line 23
       at TwitterSearch.Core.TwitterSearchApp.InitialisePlugIns() in c:\fileZ\projZ\samples\MvvmCross-Tutorials\Sample - TwitterSearch\TwitterSearch.Core\TwitterSearchApp.cs:line 33
       at TwitterSearch.Core.TwitterSearchApp..ctor() in c:\fileZ\projZ\samples\MvvmCross-Tutorials\Sample - TwitterSearch\TwitterSearch.Core\TwitterSearchApp.cs:line 15
       at TwitterSearch.UI.Console.Setup.CreateApp() in c:\fileZ\projZ\samples\MvvmCross-Tutorials\Sample - TwitterSearch\TwitterSearch.UI.Console\Setup.cs:line 16
       at Cirrious.MvvmCross.Platform.MvxSetup.CreateAndInitializeApp(IMvxPluginManager pluginManager) in c:\Projects\Misc\MVVMCROSS\Cirrious\Cirrious.MvvmCross\Platform\MvxSetup.cs:line 272
       at Cirrious.MvvmCross.Platform.MvxSetup.InitializeApp(IMvxPluginManager pluginManager) in c:\Projects\Misc\MVVMCROSS\Cirrious\Cirrious.MvvmCross\Platform\MvxSetup.cs:line 265
       at Cirrious.MvvmCross.Platform.MvxSetup.InitializeSecondary() in c:\Projects\Misc\MVVMCROSS\Cirrious\Cirrious.MvvmCross\Platform\MvxSetup.cs:line 77
       at Cirrious.MvvmCross.Platform.MvxSetup.Initialize() in c:\Projects\Misc\MVVMCROSS\Cirrious\Cirrious.MvvmCross\Platform\MvxSetup.cs:line 36
       at TwitterSearch.UI.Console.Program.Run() in c:\fileZ\projZ\samples\MvvmCross-Tutorials\Sample - TwitterSearch\TwitterSearch.UI.Console\Program.cs:line 21
       at TwitterSearch.UI.Console.Program.Main(String[] args) in c:\fileZ\projZ\samples\MvvmCross-Tutorials\Sample - TwitterSearch\TwitterSearch.UI.Console\Program.cs:line 14
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.IO.FileNotFoundException
       HResult=-2147024894
       Message=Could not load file or assembly 'Cirrious.MvvmCross.Plugins.Visibility.Wpf' or one of its dependencies. The system cannot find the file specified.
       Source=mscorlib
       FileName=Cirrious.MvvmCross.Plugins.Visibility.Wpf
       FusionLog==== Pre-bind state information ===
LOG: User = LAGOA\Sergio
LOG: DisplayName = Cirrious.MvvmCross.Plugins.Visibility.Wpf
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Cirrious.MvvmCross.Plugins.Visibility.Wpf | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/fileZ/projZ/samples/MvvmCross-Tutorials/Sample - TwitterSearch/TwitterSearch.UI.Console/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Cirrious.CrossCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e16445fd9b451819.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\fileZ\projZ\samples\MvvmCross-Tutorials\Sample - TwitterSearch\TwitterSearch.UI.Console\bin\Debug\TwitterSearch.UI.Console.vshost.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/fileZ/projZ/samples/MvvmCross-Tutorials/Sample - TwitterSearch/TwitterSearch.UI.Console/bin/Debug/Cirrious.MvvmCross.Plugins.Visibility.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/fileZ/projZ/samples/MvvmCross-Tutorials/Sample - TwitterSearch/TwitterSearch.UI.Console/bin/Debug/Cirrious.MvvmCross.Plugins.Visibility.Wpf/Cirrious.MvvmCross.Plugins.Visibility.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/fileZ/projZ/samples/MvvmCross-Tutorials/Sample - TwitterSearch/TwitterSearch.UI.Console/bin/Debug/Cirrious.MvvmCross.Plugins.Visibility.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/fileZ/projZ/samples/MvvmCross-Tutorials/Sample - TwitterSearch/TwitterSearch.UI.Console/bin/Debug/Cirrious.MvvmCross.Plugins.Visibility.Wpf/Cirrious.MvvmCross.Plugins.Visibility.Wpf.EXE.

       StackTrace:
            at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
            at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
            at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
            at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
            at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
            at System.Reflection.Assembly.Load(String assemblyString)
            at Cirrious.CrossCore.Plugins.MvxFilePluginManager.LoadAssembly(Type toLoad) in c:\Projects\Misc\MVVMCROSS\CrossCore\Cirrious.CrossCore\Plugins\MvxFilePluginManager.cs:line 53
            at Cirrious.CrossCore.Plugins.MvxFilePluginManager.FindPlugin(Type toLoad) in c:\Projects\Misc\MVVMCROSS\CrossCore\Cirrious.CrossCore\Plugins\MvxFilePluginManager.cs:line 31
            at Cirrious.CrossCore.Plugins.MvxPluginManager.ExceptionWrappedLoadPlugin(Type toLoad) in c:\Projects\Misc\MVVMCROSS\CrossCore\Cirrious.CrossCore\Plugins\MvxPluginManager.cs:line 120
       InnerException: 

有人可以帮我弄清楚我是否做错了或插件是否真的试图加载错误的文件?

谢谢你, 塞尔吉奥

1 个答案:

答案 0 :(得分:2)

最近的更改意味着ConsoleWpf将共享Wpf个插件(因为它们都是.Net45插件)。

这是在https://github.com/slodge/MvvmCross/pull/395之后做出的 - 重复这一点似乎毫无意义。

此更改在标记为3.0.11-beta1的当前二进制文件中发布 - 我们正尝试尽快发布3.0.11版本的发行说明(但正在打击Xamarin设置和PCL问题)。当我们达到稳定时,我们也会(尝试)更新所有示例项目。 (但是,由于Twitter已经弃用了它所使用的RSS API,TwitterSearch现在已经被遗忘了。

如果您需要以前的稳定二进制文件,可以https://github.com/slodge/MvvmCross-Binaries/releases

下载3.0.10

至于Console的价值,我通常认为这是有限的 - 我发现编写单元测试是一种更好的方法,而不是编写一个控制台应用程序。我通常发现控制台的用户体验有限,无法用于真正的用户体验。应用