Skip to Content
Sep 07, 2017 at 06:53 PM

SAP Business One and Microsoft Unit Tests

338 Views Last edit Sep 08, 2017 at 06:37 AM 2 rev

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 -