0

I am working with some test code to create Visio documents. I am using Visual Studio 2010 on Window 7 64 bit. When I run my program and attempt to create the new Visio application object in the program I get thie following exception:

Retrieving the COM class factory for component with CLSID {00021A20-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

Here's the code that causes the exception:

Visio.Application va = new Microsoft.Office.Interop.Visio.Application();

I verified the project settings are to build a 32-bit application. I have tracked it back to 64-bit Windows can't load the 32-bit .COM Visio dll. I tried registering the dll using regsvr32 but get an error message that the entry-point DLLregisterserver was not found. MDSN says this means the file is not a valid .dll. Nowever I am trying to register the Microsoft.Office.Interop.Visio.dll from the Visual Studio libraries. Is there a fix for this? Is there a 64-bit version of the .COM libraries?

David Green
  • 1,210
  • 22
  • 38
  • Which version of .net you are using? – Dinesh Feb 27 '12 at 04:38
  • check this link. http://stackoverflow.com/questions/4021796/error-80040154-class-not-registered-exception-when-initializing-vcprojectengin – Dinesh Feb 27 '12 at 04:43
  • Are you using 32-bit or 64-bit Office? That's what matters, not the bitness of Windows. – Ben Voigt Feb 27 '12 at 04:45
  • I am using .NET 4.0. I already checked the project settings, I am building for 32-bit. FWIW the same project I have some test code that builds an Excel spreadsheet. That is also .COM and I assume is also 32-bit. – David Green Feb 27 '12 at 04:48
  • You mean, 64 bit Win7 OS, 64 bit office and your applications is 32 bit? – Dinesh Feb 27 '12 at 05:18
  • 1
    @David: I'm pretty sure you're going to need to install 32-bit Visio in order to use its Interop assembly from a 32-bit program. – Ben Voigt Feb 27 '12 at 05:57
  • @Dinesh, yes, 64bit Windows, 64bit office. App is 32-bit. Some of the people who would use it are still on a 32 bit OS. If it matters, I got the same error when I changed the project settings to a 64bit app. – David Green Feb 27 '12 at 12:36
  • @BenVoigt - that worked. thanks for the tip. It makes sense that I am calling the application interface which would need to talk to the actual Visio app. – David Green Feb 27 '12 at 17:44
  • @David: I'll write an answer. – Ben Voigt Feb 27 '12 at 17:46

2 Answers2

0

Follow this link. This page explains how to install dlls as on 32 bit system, though you are using 64 bit system

You can find 32-bit version of REGSVR32 on 64 bit system on path-- %systemroot%\SysWoW64\regsvr32.exe.

WoW = stands for Windows on Windows

Amol Chavan
  • 3,835
  • 1
  • 21
  • 32
  • I tried both (32 and 64bit) versions of regsvr32 and both fail with the same message. For now I will assume a corrupt dll file and try getting a clean copy. – David Green Feb 27 '12 at 04:50
0

The Interop assembly you're trying to load depends on the native Visio DLLs. In order to load those DLLs in-process, they need to match your process bitness.

So, you'll need to have 32-bit Visio installed.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720