Problem with Unit Testing Revit 2012 addin in Visual Studio 2010

Problem with Unit Testing Revit 2012 addin in Visual Studio 2010

Anonymous
Not applicable
1,259 Views
3 Replies
Message 1 of 4

Problem with Unit Testing Revit 2012 addin in Visual Studio 2010

Anonymous
Not applicable

I am trying to create unit test in VS2010 for Revit addin that I developed. Problem is when I create unit test for a method and then run that test, I get this message:

Test method TestProject1.SimpleTestCommandTest.ExecuteTest threw exception: System.IO.FileNotFoundException: Could not load file or assembly 'RevitAPIUI.dll' or one of its dependencies. The specified module could not be found.

RevitAPIUI.dll is properly added to references of Revit addin project, and also in references of test project.

Any idea what should I do to fix this?

0 Likes
1,260 Views
3 Replies
Replies (3)
Message 2 of 4

MattSiebert
Contributor
Contributor

I ran into a similar issue a while ago when I was trying to use reflection to list some of Revit's enums.

 

I didn't really need to get this working so I eventually gave up, but before I did I added a handler for the AssemblyResolve event to try to find the issue.  It turns out that the issue was caused by the Revit assemblies' dependency on the Visual C++ Runtime.

 

It seems the solution is to ensure the VC++ Runtime is loaded into the process in order to satisfy Revit's dependencies, simply referencing the VC++ assemblies won't help you as the runtime needs to be loaded a specific way.  I had other time constraints so I gave up after this and I didn't look into how to load the runtime properly.

 

I hope this helps.

0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi, Matt. Thank you for your answer. I'll try doing what you suggested. Hopefully, it will give results.

0 Likes
Message 4 of 4

Anonymous
Not applicable

Hey Guys,

 

I am having the same problem. 

 

Any update?? Has anyone solved this issue? 

 

Its very difficult to unit test Revit. 

0 Likes