0

I have added a dll library inside my ASP.NET framework c# project and I have created a ASP.NET FRAMEWORK API CONTROLLER in this ASP.NET FRAMEWORK c# project. Inside this API CONTROLLER class, I have created a function called fnGetTerminalInfo() that instantiates an object of the dll library interface class.

I tried to run the API controller localhost:xxxxx/api/conGetTerminalInfoAPI/fnGetTerminalInfo in a localhost and it works perfectly. However, after deploying the project to IIS and run the API controller using this url <ip address>:<port number>/api/conGetTerminalInfoAPI/fnGetTerminalInfo in a browser, I received an error that says

Retrieving the COM class factory for component with CLSID {5DC9FDA1-B975-49BF-8A89-05068714BAFD} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). System.Runtime.InteropServices.COMException

However when I removed the code(s) that instantiates an object of the dll library interface class from the function fnGetTerminalInfo(), the error disappeared.

Does anyone know what causes the error? Thank You :) Looking forward to your answer :)

Balagurunathan Marimuthu
  • 2,927
  • 4
  • 31
  • 44
  • 64bit application? (Check project settings) – Ofiris Nov 09 '16 at 07:57
  • Your code uses a COM component that isn't registered. Register the component on the server. Note that this might not be possible (e.g shared web hosts), in which case you will need a different approach. – Dai Nov 09 '16 at 07:58
  • Alternatively: Registration-free COM: https://msdn.microsoft.com/en-us/library/fh1h056h(v=vs.110).aspx – Dai Nov 09 '16 at 07:59
  • @Ofiris, it says target any cpu, including x64. – Hardyanto Putra Antoni Nov 09 '16 at 08:02
  • possible duplicate from http://stackoverflow.com/questions/17985653/class-not-registered-error – Oswald Nov 09 '16 at 08:03
  • @Antoni Choose x86 as the platform target and retry, your DLL might be a 32bit component – Ofiris Nov 09 '16 at 08:03
  • @Dai, but it will still be possible using IIS right? – Hardyanto Putra Antoni Nov 09 '16 at 08:04
  • @Ofiris, after changing from "target any cpu" to "x86" and reload the url :/api/conGetTerminalInfoAPI/fnGetTerminalInfo in a browser, it gives me this error: System.BadImageFormatException: Could not load file or assembly 'ContactlessPaymentAPI' or one of its dependencies. An attempt was made to load a program with an incorrect format. – Hardyanto Putra Antoni Nov 09 '16 at 08:09
  • @Ofiris, it also says WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. – Hardyanto Putra Antoni Nov 09 '16 at 08:10

0 Answers0