NUnit Error: The Type Initializer for … Threw an Exception (And app.config)
来源:互联网 发布:bh椭圆机 知乎 编辑:程序博客网 时间:2024/04/29 06:23
My Visual Studio solution contains 5 projects, one of them is for unit testing purpose. The unit testing project is referencing to Entity Framework library where I query data from database. Well, since the Entity Framework is depending on app.config for the connection string, my NUnit returns error when I run it. This is because NUnit can’t find the connection string in app.config file. The error is: System.TypeInitializationException: The type initializer for ‘…’ threw an exception. Here’s the screenshot (some information is blacked out on purpose). I use NUnit 2.5.9 for unit testing. Two workarounds for this problem are stated below. You don’t have to apply both workarounds, just either one of them. In my case, the first one works like charm.
System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
Example: NUnit project file is “C:/Users/Documents/Nunit/ProjectTest.nunit”. My app.config will have to be “C:/Users/Documents/Nunit/ProjectTest.config”
Example: Library project file is “C:/Users/Documents/ProjectSolution/ProjectTest/bin/Debug/ProjectTest.dll”. My app.config will have to be “C:/Users/Documents/ProjectSolution/ProjectTest/bin/Debug/ProjectTest.dll.config” (if doesn’t work, try rename it to ”C:/Users/Documents/ProjectSolution/ProjectTest/bin/Debug/ProjectTest.config”)
- NUnit Error: The Type Initializer for … Threw an Exception (And app.config)
- The type initializer for 'TestStatic.StaticClass' threw an exception.
- The type initializer threw an exception.
- What Can I do if "The type initializer for 'Emgu.CV.CvInvoke' threw an exception"?
- The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.
- 使用Spire组件抛出异常The type initializer for 'spr857' threw an exception
- 使用Spire组件抛出异常The type initializer for 'spr857' threw an exception
- SqlConnection new 的時候,报:“The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.”
- ERROR LiveListenerBus: Listener EventLoggingListener threw an exception
- the service threw an unknown exception in SCOM 2012
- Could not install the app on the device, read the error above for details. Make sure you have an And
- Could not install the app on the device, read the error above for details. Make sure you have an And
- Error: variable 'QApplication app' has initializer but incomplete type
- Set connectionId threw an exception.
- Servlet execution threw an exception
- terminate_handler unexpectedly threw an exception
- Cannot find an initializer for type '[(String)]' that accepts an argument list of type '(LazyForward
- C#中异常:“The type initializer to throw an exception(类型初始值设定项引发异常)”的简单分析与解决方法
- 在ubuntu10.04 下安装NS2
- Android ROM的制作与烧录
- HDU 2152 Fruit 母函数
- 库函数
- 我居然看到了这么一篇让我心碎的文章
- NUnit Error: The Type Initializer for … Threw an Exception (And app.config)
- VC 执行带参数的exe
- Ext动态radio ajax请求
- Java基础:初学入门需掌握的30个基本概念
- zthread学习 实例八 任务终止(一)——观赏植物园
- 金山词霸2011不能在PDF中取词 解决办法
- 安卓,我火了
- 利用jpeglib压缩和解压图像为jpg格式
- win7上帝模式