Import Itaucripto DLL into VB

Asked

Viewed 1,232 times

2

Hello, I’m implementing the second way of boleto Itaú, but I’m trying to work with ASP.NET VB and I don’t have much knowledge in this language. I did everything right and is working locally, but when I go up to my Locaweb hosting I get the following error

[HttpException (0x80004005): Could not create an object of type 'Itaucripto.cripto'.]

This error happens because itaucripto.dll is not installed in my hosting, I contacted support and said that they do not install the DLL on the server and that I must color the DLL within my project and reference it in the application. How do I import is DLL in my application ?

2 answers

2

First manage an Interop Assembly. This DLL is a COM Assembly, not directly compatible with the .NET. Then include this Assembly in your code to access the COM interfaces.

Done that, you need to configure the project to use the registry free DLL in the Windows interface.

There is also a second alternative from Framework 3.5, which is by compiling the Interop DLL in the Build of the project. Inside your file .csproj, it is necessary to place the following:

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

There are more details in this OS response.

  • All right, I’ll try the second alternative I’m with Framework 4.5, thank you!!

  • Using the second option I need to generate an Interop Assembly ?

  • No, the idea is that Msbuild generates this for you. You just need to make the statement on the web.config.

  • My web.config is not recognizing the <Itemgroup> property, do you know what it might be ? " Configuration Error Unable to read the 'Itemgroup' configuration section because a section declaration is missing"

  • @Danielgregatto My mistake. No web.config. It’s inside the .csproj.

0

You can make the Dll reference by using Dllimport. At the top of your code type:

Imports System.Runtime.InteropServices

Then put the Dll in the source of your code, this is quite important, in case your Dll stays in a folder that it does not find, it will not work. Finally, just invoke the Dll.

<System.Runtime.InteropService.DllImport("SUADLL.dll", _
SetLastError:=True, CharSet:=CharSet.Auto)> _

Browser other questions tagged

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