Skip to Content

SAP Business One and Microsoft Unit Tests

Sep 07, 2017 at 06:53 PM


avatar image

Hello experts,


I am getting this error after starting up my Unit test and opening up a connection -

"Retrieving the COM class factory for component with CLSID {632F4591-AA62-4219-8FB6-22BCF5F60090} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."


Is there a setting that I am missing? What should I be doing so that I can get my Unit tests to be able to access SAP DI API?


I am using Visual Studio 2013; My computer is 64-bit; I have the 64 bit version of SAP Business one installed on my computer; In my Unit test project I am referencing Interop.SAPbobsCOM version 9 32-bit (I got this using Visual Studio's dumpbin tool);


I have looked through many blogs and questions/answers. I had a similar problem when trying to connect to SAP through my service hosted on IIS Express and solved it by setting some registry value so IISExpress will run using 64-bits. I have tried compiling my tests in x86 (with no luck) and x64 (after doing this I could not even start the test).

I tried removing the reference to Interop.SAPbobsCOM (since it was 32-bit) and replaced it with SAPbobsCOM90 (64-bit) - which I found in C:\Program Files\SAP\SAP Business One DI API\DI API 90.

Every time I switch my project properties to compile in x64, instead of Any or x86, leads me to wonder if it has something to do with Microsoft's Unit Testing. Visual Studio's IISExpress worked only with 32-bit by default until I changed some registry I am wondering if maybe the Unit Tests are the same in that they will only work with 32-bit (is there a setting to get them to use 64-bit instead)?

Please let me know if there is any more information that I have not included here that would be beneficial. Thank you for your help -


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Frank Dewey Sep 09, 2017 at 03:18 PM

I found the took me a while to get there =) I've not worked with Unit tests in a lot of detail, but it turns out that there is a setting in Visual Studio that will tell Unit tests to run in 32-bit or 64-bit. This can be accessed in the menu by going to Test > Test Settings > Default Processor Architecture

10 |10000 characters needed characters left characters exceeded