[英]How to handle the unit-test assembly load issue in C#
从 x64/x86 加载程序集时,我的单元测试项目中出现了System.BadImageFormatException异常消息。 下面是我在调试测试时遇到的异常的代码和屏幕截图。
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Example_Addin;
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using Microsoft.Office.Interop.Visio;
using Visio = Microsoft.Office.Interop.Visio;
namespace exampleProject
{
[TestClass]
public class exampleUnitTest1
{
[TestMethod]
public void Test_example()
{
try
{
Example exm_obj = new Example();
string file_path = "test.json";
string template_file = "template.vssx";
double height = 0.5;
double width = 0.5;
db_obj.read_data_shape_creation(@file_path, 0.5, 0.5, "F06", @template_file, "testing");
}
catch (Exception)
{
System.Diagnostics.Debug.WriteLine("Exception occour");
}
}
}
在这里,我想使用程序集依赖项对我的代码进行单元测试,但是在设置程序集之后,我得到了上面的捕捉异常并且代码执行停止了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.