import methods from an unmanaged Bematech DLL c#

Asked

Viewed 1,001 times

1

I need to use a dll provided by Bematech with functionalities of a non fiscal printer. The example they provided brings the following code:

[DllImport("MP2032.dll")]
public static extern int ConfiguraModeloImpressora(int model);

The program generates the following exception:

Additional information: An attempt has been made to upload a program with an incorrect format. (HRESULT exception: 0x8007000B)

Believing that the problem could be in dll I created a new project to generate an exportable dll. Returned the same error. I have read several posts and articles and do not understand why my code does not work.

  • 1

    Does the DLL used match your executable architecture? (32 or 64 bit)

  • Yes Bruno, 32 bits.

  • 1

    Try following the suggested tip at this link (https://social.msdn.microsoft.com/Forums/pt-BR/216a765f-3082-4fd0-bdd7-b90707daa393/erro-dll-daruma) I think you can help.

  • 1

    @tiagocosta checks if your project really is in the properties -> Build -> Platform Target is x86. The times I had this problem was because of not being x86.

  • Thanks Bruno Bermann and Pablo Vargas, it worked.

No answers

Browser other questions tagged

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