david.s
david.s

Reputation: 11403

Can't instantiate COM object from ASP.NET MVC app

As the title says, I want to instantiate a COM object from an ASP.NET MVC app like this:

dynamic obj = Activator.CreateInstance(Type.GetTypeFromProgID(progID));

but it throws the following ComException:

Retrieving the COM class factory for component with CLSID {16542E4F-4594-4B97-922D-BE9C478F93BB} failed due to the following error: 800aea5f Exception from HRESULT: 0x800AEA5F.

The same code works from a Winforms app with the following build configuration: Platform: x86 and Platform target: x86.

I set the build configuration the same as the Winforms app for both the mvc app and the assembly where I use the COM object.

I'm using Windows 7, IIS 7.5, ASP.NET v4.0 Application Pool with Enable 32-Bit Applications True and the website runs under a user with Administator rights.

What are your suggestions to help solve this problem?

Upvotes: 1

Views: 1587

Answers (2)

Peter Ritchie
Peter Ritchie

Reputation: 35869

Set the Application Pool's Default User to a user with Admin rights

Upvotes: 0

YvesR
YvesR

Reputation: 6232

@david.s I don't know how to add a screenshot as a comment, so I set it as an answer. As you already have all 32bit stuff set and the DLL can't be called it might be a permission problem.

Call dcomcnfg.exe and check the settings (sorry, only german server, but should work): enter image description here

You have to reset your IIS after settings change.

Upvotes: 1

Related Questions