COMException CreateInstance error while publishing

I am currently developing a C # WebAPI project that references a third-party api dll. A component is a simple COM link that I added to a visual studio project.
The web API is published on the intranet server (IIS) with security enabled and user impersonation, anonymous out disabled.

When running web api in visual studio (2015) on my local machine, everything works fine.

When I run the published web api on our IIS server, everything works fine, however, when I submit a request for a controller action that uses a third-party library, I get the following error:

System.Runtime.InteropServices.COMException
Additional Information:
Error CreateInstance.
at ThirdPartyLib.Connect ()

A third-party dependency was installed on the server (as well as on my dev machine) using their installer. It registered a set of DLLs and installed related software. I checked the correct installation. In fact, a simple winforms application using the same DLL works fine.

Process Monitor shows that w3wp.exe is using the correct dll.

I'm not sure what I am missing?
If this problem is right, how can I solve it?

+6
source share
1 answer

You can change the application pool identifier for a user with higher permissions.

Note. . You can use ASP.NET impersonation using a web configuration to run the entire application with a specific identity, or using code to run only part of the code using a specific identity. For example, I tested <identity impersonate="true" userName="r.aghaei" password="mypassword"/> to resolve the file system and worked correctly. Just perform impersonation of attention in webconfig or in code, it just works if the user of the application pool has sufficient rights to allow impersonation. For more information on how to use the configuration or the impersonation inn code, see this MSDN KB article.

Also do not neglect the least privilege.

+2
source

Source: https://habr.com/ru/post/1012226/


All Articles