-1

I'm kind of new in C# and Visual Studio. I've searched for the question and found some interesting answers but none of them seems to works.

This is the situation: I have a TPV example source that is supposed to be ok itself, and I compile it with Visual Studio 2015 from a 32 bit Windows 7 using the option Release/x86, and it's aimed to work on a 64 bit Windows 7. The Application opens but when I'm about to use some functions (such as opening the cash drawer or other special events which depend on the peripherals) it throws a box saying it has an error and can either continue ignoring the error (which keeps the app running but ignores the petition about those peripheral events) or quit. This is the extra information it gives me:

This is the exception:

System.DllNotFoundException: Unable to load DLL 'toggle_Cd.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) at Elo_Proj.cashDrawerPopup._tmain() at Elo_Proj.cashDrawerPopup.cashDrawerPopup_Load(Object sender, EventArgs e) in C:\Users\usuario\Documents\TPV\PayPoint Windows\Sample Source\Elo_Paypoint_Windows_App_Source_Code\Elo_Paypoint_Windows_App_Source_Code\Elo_Proj_prj\cashDrawerPopup.cs:line 106 at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Apart from assembly information that I think is not especially relevant here. I tried to look for the Exception from HRESULT: 0x8007007E but couldn't find a proper solution. I also looked for the toggle_Cd.dll but I'm clueless about what to do with it. I tried to add it to the path that leads in dll windows32 in the 64bit machine and to add it directly in the same folder of the executable, but I guess that isn't how it works.

Thanks in advance, and sorry for my inexperience with the language, program and the OS.

gorkem
  • 731
  • 1
  • 10
  • 17
Paula
  • 184
  • 1
  • 3
  • 9
  • How do you load toggle_Cd.dll? – Zbidi May 02 '17 at 10:27
  • is this `toggle_Cd.dll` part of your source? – Stefan May 02 '17 at 10:27
  • Looking at the exception message it seems that `toggle_Cd.dll` is a COM library. So you need to register it (with regsvr32.exe) or, better, install the vendor's redistribuitable package(s)... – Seididieci May 02 '17 at 10:28
  • For assembly registration you can check this answer: http://stackoverflow.com/questions/19401873/run-time-error-440-vb6/19402159#19402159 – Stefan May 02 '17 at 10:29
  • 1
    You are out of your depth here. `_tmain()` is the entrypoint of a console mode program. An exe, not a dll, presumably just the sample program you compiled. Consider using the Process class to minimize the pain points. – Hans Passant May 02 '17 at 10:29
  • @Stefan yes it is. In fact it's named toggle_cd.dll and not toggle_Cd.dll, but I also tried changing that and it didn't work. – Paula May 02 '17 at 10:31
  • @Zbidi I use it like this in the code: [DllImport("toggle_Cd.dll", CallingConvention = CallingConvention.Cdecl)] – Paula May 02 '17 at 10:31
  • So, the `toggle_cd.dll` is an unmanaged dll. Since the error is `DllNotFoundException`, where is this dll located? – Stefan May 02 '17 at 10:43
  • @Stefan ok so the code is in a source folder. The dll is located in another folder located in Binaries/External_Dll/BCR_&_CD – Paula May 02 '17 at 10:51
  • okay guys so I tried (again) to put the .dll in the same folder of the executable (Bin) and the error doesn't show up anymore but some of the periferal doen't work, whatsover (the cash drawer does work now, but not others). – Paula May 02 '17 at 11:03
  • That's a first step :-) I think your next issue would be a valid new question. – Stefan May 02 '17 at 12:06

1 Answers1

0

Okay, so with the original example folders tree .dll won't work. But pasting the .dll files required in the Bin folder where the application is, it does work. I would like it to work using the .dll organized propertly but this shows me the error is in the path, so I think I can handle it. I'm having some issues with the proper activity of the peripherals, but it doesn't have anything to do with the .dll (I think!).

Thank you a lot, guys, your fast answers guided me well.

Have a nice day.

Paula
  • 184
  • 1
  • 3
  • 9