0

This seems to be a hot topic on SO but none of the solutions I've seen work for me.

My web application uses PolarZIP to handle compressing and decompressing XML files that get served to / received from the end user. There is no reference to PolarZIP.dll in my project, nor is there any using statement in the class that does this work, but on our live server the application behaves correctly. Locally, as soon as it tries to instantiate this PolarZIP object I get this exception:

Retrieving the COM class factory for component with CLSID {9A00B901-D104-11D4-B8F7-080030001D26} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

This is the most popular thread I could find:

Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154

But setting all of my projects in the solution to build for x86 (instead of 'Any CPU') made things worse-- when I launch the application instead I get this new server error:

Could not load file or assembly 'OurSoftware.Business' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Most other questions citing this error either just get flagged as duplicate for the one I linked above, or don't have any answers at all I have PolarZIP.ocx in my C:\Windows\SysWOW64\ folder which is where it is on the live server (where the software functions correctly).

Any ideas?

Edit; The CLSID 9A00B901-D104-11D4-B8F7-080030001D26 does show up in regedit if that matters. Name: (Default), Type: REG_SZ, Data: PolarZIP Control

Community
  • 1
  • 1
sab669
  • 3,984
  • 8
  • 38
  • 75
  • You have to run your web app in 32-bit mode to use this component. Google "run web application in 32-bit mode" for hits. – Hans Passant Apr 07 '16 at 14:36
  • `Enable 32-Bit Applications` set to `true` in IIS for the app pool my application uses – sab669 Apr 07 '16 at 14:46
  • Well, that is not what the exception says. You forced x86 and the server does not like it. Hard to guess why you would omit such an essential detail from your question btw. Move over a bit, we can't see your screen. – Hans Passant Apr 07 '16 at 14:50
  • I'm not sure exactly what you mean, however I did just notice a formatting error in my question. Accidentally moved the error ("canot load file or assembly ...") to be an extra paragraph down, so I can see where the confusion would come in. But that's what I get if I try when I build targetting x86. You'll have to forgive me; while I'm fairly comfortable writing C# / .NET code, I know far less about the "inner workings" of IIS and things of that nature. – sab669 Apr 07 '16 at 15:30

2 Answers2

0

Copying the file isn't enough - you need to register the library. This is usually handled by the installer - copying files around is usually a bad idea. If you don't have an option to use the installer, have a look at regsvr32.exe. It may very well be that there are additional steps that need to be handled, and dependencies that need to be installed - really, using the installer is by far the preferred option :)

Additionally, make sure the bitness is correct. A 32-bit application can't access a 64-bit COMponent and vice versa.

Luaan
  • 62,244
  • 7
  • 97
  • 116
  • I tried running `%systemroot%\SysWOW64\regsvr32 C:\Windows\SysWOW64\PolarZIP.ocx` from the command line and that said it was successfully registered, but I still get the same behavior described in my post unfortunately. It's most likely a 32-bit library, but I can't build my application for x86 specifically as I mentioned :/ – sab669 Apr 07 '16 at 14:30
  • @sab669 That just makes it very weird that it ever worked, anywhere. You can't use a 32-bit COM library in a 64-bit process. If that's what you need, you'll have to create a proxy 32-bit process to deal with the COM objects, I'm affraid. Using a native (that is, .NET native) solution might be a better idea. What's wrong with `DeflateStream` or `ZipArchive`? – Luaan Apr 07 '16 at 15:21
  • I'll have to look into native solutions, but the fact that it works on the live server and not my own locally is very bizarre. I don't know the full in-and-out of that setup, though. Still relatively new at this company (< 1 year). No idea why they decided to use this library however many years ago when such a decision was made. But maybe I can look into a native .NET solution for what i need to do instead of trying to figure out why I can't use this library. All I need to do is accept a zip, unpack it, and validate the XML files inside anyways... – sab669 Apr 07 '16 at 15:24
-1

Did you check any dependent libraries are missing using 'Depends.exe' ?