Using Itaucripto_.dll within web service (without registering on the server)

Asked

Viewed 310 times

0

I tried to put the COM DLL in the webservice project (using the code below to include it):

<Project ...>
  <ItemGroup>
    <COMFileReference Include="itaucripto_.dll">
      <EmbedInteropTypes>True</EmbedInteropTypes>
    </COMFileReference>
  </ItemGroup>
</Project>

Is there anything else you need to do on a WCF service with asmx? The server makes an exception saying that it cannot find the COM class because it is not registered. I don’t want to register the DLL on the server; but instead I want to call it without registration. Ambience:

  • Visual Studio 2017
  • WCF service application with an asmx web service (I’m trying to instantiate the COM object in asmx’s Helloworld method)

Code:

Itaucripto.cripto itau = new Itaucripto.cripto();

Exception:

An exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll but was not handled in user code

Additional information: Retrieving the COM class factory for component
with CLSID {E9067548-B9D1-4146-BEDC-0F7BFEDF6E94} failed due to the 
following error: 80040154 Class not registered (Exception from HRESULT: 
0x80040154 (REGDB_E_CLASSNOTREG)). occurred
  • Isn’t it a question of x64 vs x86? Ex.: You are compiling your project into 64 and dll is 32

  • I forced the project to 32bits (x86), nothing.

  • The problem happens in debug by visual studio or only when you publish in IIS?

  • Debugging by IIS Express in VS.

  • Even with Plataform target x86 and allow unsafe code marked?

  • I just marked Unsafe Code. Nothing.

Show 1 more comment

1 answer

0

I’ve had the same problem, I found the solution by reading this question from the OS: Interop type cannot be Embedded

The solution was as follows:

1. Registrar o assembly de criptografia do Itaú usando o comando REGSVR32 com privilégios de admin. 
   Exemplo: C:\Windows\System\regsvr32 Itaucripto_.dll
2. Importar o assembly no projeto.
3. Setar a propriedade "Embed Interop Types" com false na dll importada nas referências, 
   pois não é uma DLL que roda sobre o Framework .Net

Browser other questions tagged

You are not signed in. Login or sign up in order to post.