views:

304

answers:

2

I am using iBatis.NET in a very simple test project (VS 2008). When I run the suite and the Mapper is instantiated a FileNotFoundException pops up on opening SqlMap.config. The path where iBatis.NET looks for this file is "the current TestResults folder \ Out". Naturally, the file isn't copied there so the Mapper constructor fails.

I must completely misunderstand what is going on because I have been unable to find any information on SO or the web at large to indicate how I could remedy the problem. I did run across a couple of situations unrelated to iBatis.NET where the solution suggested to the user was to set "Enable Deployment" to "off" in the .testrunconfig file to force VS to run the tests from bin\Debug.

However, before I go down that avenue I am curious to know what others have done when using iBatis.NET in a test project. I have the unpleasant feeling that the resolution is trivial.

A: 

By default iBATIS.NET will look in the current directory for the map config file. As you say, the file is not there. The quickest way to solve your particular problem is to instruct Visual Studio to copy the SqlMap.config file to the output folder as part of building the project.

To do this, in the Solution Explorer, right-click on the SqlMap.config file and select Properties. In the property palette, look for Copy to Output Folder and select Copy If Newer.

Unless I misunderstand your situation, I believe this will work.

Jeremy
Thanks for the suggestion, Jeremy. From a different question on SO it looks like I will also need to specify SqlMap.config for deployment so it gets copied to the TestResults folder. A good thing this worked out, I don't think my coworkers could have managed the frustrated screams much longer.
alexsome
A: 

I have a same problem with alexsome. I selected "Copy to Output Folder" as Copy If Newer. and also I add sqlmap.config into "Deployment" . But the exception still occurs.

My project is like this:

I have two class lib and both of them have sqlmap.config.

Thank you

Chessman