2

I am trying to load "MarkEzd.dll" in my c# project. For get access to the DLL file, I called it as:

static class A
{
    [DllImport("MarkEzd.dll", EntryPoint = "lmc1_Initial2", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
    public static extern int Initialize(string PathName, bool TestMode)
}

I followed the structure supposed by "Bkjames" in this post: Loading a C++ DLL in C#

Then I wrote this line:

A.Initialize(@"The path of MarkEzd.dll", true);

but I got this error message: Unable to load DLL `MarkEzd.dll': this specified module could not be found. [Exception from HRESULT: 0x8007007E)

Does anybody have any idea? I am in Debug mode. and I see that the MarkEzd.dll is in the debug folder.

Backs
  • 24,430
  • 5
  • 58
  • 85
  • @ALex F Thanks. I used DependencyWalker and I found a lot of issues with MarkEzd.dll. Is it useful to download another one? I found another one on the internet. But it didn't work too. – Zahra Rezaei Jan 02 '22 at 09:34
  • 1
    Don't trust dependency walker, it isn't accurate on modern windows. Use loader snaps to debug dependencies. Or read docs for the dll and make sure you have necessary dependencies. – David Heffernan Jan 02 '22 at 17:25
  • I have this problem too. But it works for older model lasers Lmc1. Apparently markezd.dll is written for the lower versions and does not work for the new series of laser devices. – Hassan Pournajaf Feb 06 '22 at 05:56

1 Answers1

0

Try this

[DllImport("MarkEzd.dll", EntryPoint = "lmc1_Initial2", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern int lmc1_Initial2(string strEzCadPath, int bTestMode, IntPtr hOwenWnd);

And calling

int ErrorCode = lmc1_Initial2(Application.StartupPath, 0, Handle);  

And you can define errors as

#define LMC1_ERR_SUCCESS 0 // Success
#define LMC1_ERR_EZCADRUN 1 // Find EZCAD running
#define LMC1_ERR_NOFINDCFGFILE 2 // Can not find EZCAD.CFG
#define LMC1_ERR_FAILEDOPEN 3 // Open LMC1 board failed
#define LMC1_ERR_NODEVICE 4 // Can not find valid lmc1 device
#define LMC1_ERR_HARDVER 5 // L mc1 s version is error.
#define LMC1_ERR_DEVCFG 6 // Can not find configuration files
#define LMC1_ERR_STOPSIGNAL 7 // A larm signal
#define LMC1_ERR_USERSTOP 8 // User stops
#define LMC1_ERR_UNKNOW 9 // Unknown error
#define LMC1_ERR_OUTTIME 10 // Overtime
#define LMC1_ERR_NOINITIAL 11 // Un-initialized
#define LMC1_ERR_READFILE 12 // Read file error
#define LMC1_ERR_OWENWNDNULL 13 // Window handle is NULL
#define LMC1_ERR_NOFINDFONT 14 // Can not find designated font
#define LMC1_ERR_PENNO 15 // Wrong pen number
#define LMC1_ERR_NOTTEXT 16 // Object is not text
#define LMC1_ERR_SAVEFILE 17 // Save file failed
#define LMC1_ERR_NOFINDENT 18 // Can not find designated object
#define LMC1_ERR_STATUE 19 // Can not run the operation in
SetTom
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 30 '22 at 00:13
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/31893038) – MD. RAKIB HASAN Jun 02 '22 at 04:56