MoqRT错误 - 创建MoqRT.Baked.dll时出现未处理的异常

时间:2016-03-08 12:41:14

标签: sqlite testing frameworks windows-runtime mocking

我正在使用VS2013社区版,SQLite并使用MSTestFramework创建了Test项目,我在这里引用MoqRT框架来创建模拟对象。

但是在创建模拟对象时,我得到的错误如下,

Unhandled baking exception:  --> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.DllNotFoundException: Unable to load DLL 'sqlite3': This operation is only valid in the context of an application container. (Exception from HRESULT: 0x8007109A)
   at SQLite.SQLite3.Open(String filename, IntPtr& db)
   at SQLite.SQLiteConnection..ctor(String databasePath)
   at MoqRT.Baking.BakingController.GetDatabase()
   at MoqRT.Baking.BakingController..ctor(String testAssembly, String appxPath, String bakingPath)
   at MoqRT.MoqRTRuntime.InitializeBaking(String testAssembly, String appxPath, String bakingPath)
   --- End of inner exception stack trace ---

Server stack trace: 
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at MoqRT.Baking.BakingWorkItem.Run(BakingContext context) in d:\Kierron Matte\Projects\Mercury\R & D\Unit Testing\MoqRT-master\MoqRT.Baker\Controller\BakingWorkItem.cs:line 35
   at MoqRT.Baking.BakingPoke.RunWorkItem(BakingController owner, WorkItem item) in d:\Kierron Matte\Projects\Mercury\R & D\Unit Testing\MoqRT-master\MoqRT.Baker\Controller\BakingPoke.cs:line 36
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at MoqRT.Baking.IBakingPoke.RunWorkItem(BakingController owner, WorkItem item)
   at MoqRT.Baking.BakingRunner.ThreadEntryPoint() in d:\Kierron Matte\Projects\Mercury\R & D\Unit Testing\MoqRT-master\MoqRT.Baker\Controller\BakingRunner.cs:line 55

我从GitHub“/ mbrit / moqrt”中引用了该项目和步骤 但无法创建MoqRT.Baked.dll。

我在测试项目中引用了以下文件,

  1. MoqRT.MetroStyle.dll
  2. MoqRT.MetroStyle.pdb
  3. MoqRT.MetroStyle.pri
  4. 我还添加了图片供您参考。 提前致谢。 Unhandled Exception while Creating MoqRT.Baked.dll

1 个答案:

答案 0 :(得分:0)

我已经通过从我的测试项目中删除了与MoqRT版本(SQLite3.dll)使用的类似的其他SQLite(For Windows RunTime)引用来解决此问题。