If using VS2005, the emulator now simulates arm4, so make sure you add the cooresponding compiled dll to the project.
Also, when you add the dll to your project, highlight the dll in the solution- and make sure the "Copy to output directory" is Copy if newer, otherwise, the DLL will never copy and your program won't be able to find it!!
If your goal is just to get your unmanaged dlls to compile and then copy into the bin directory of your managed project, there's a simpler way.
1) In the Solution Explorer, right click on the "References" entry of your managed project and select "Add Reference". 2) On the "Projects" tab of the resulting dialog, double click on your unmanaged project names to add them to the "Selected Components" section. 3) Click "OK" to add these references to the managed project.
Now whenever you compile your solution, the unmanaged dlls will be compiled, then automatically copied into the output directory of the managed application.
I’ve been trying the advices here for debugging into the dll, without much luck. When running directly from eMbedded C++ (without going through the VisualStudio environment) The debugger hangs with the message “Waiting for debuggee to start...” for several minutes and eMbedded stops responding after that.
I am running the solution on the device it self, while having a breakpoint set in the unmanaged dll. Reaching the breakpoint does not have any effect on the debugger. Could someone give a more detailed advice on how to setup debugging and tracing into the unmanaged dll described here?
Hi i have the same problem. in my application. I wrote the code in C++ to generate an assembly (dll unmanaged) i call it in mmy application C#) and the application run without any problem. But when i used clickonce for deployment or projet setup. When installed to the client my application crash for all the call of the dll unmanaged. I look the forlder installing of my application all the file (dll managed, file,...) still present except the dll unmanaged. Someone could help me to fixe this problem.
I made some approch: all my dll unmamaged i added then in the project like (build action content)-> i receive the same error messages. i changed it to Embeded resource, but the problem still the same.
I'm having a tough time here getting the sample to run. The problem shows up both on the sample project that I downloaded and when I follow the tutorial. I've made sure the .dll is updated and copied each time to the device or emulator, as well as the program. However, anytime I run the project on the emulator or on the device itself, I get this error message after pressing the button:
An unhandled exception of type 'System.MissingMethodException' occurred in Managed.exe
I am running into the same problem...I downloaded the example code and tried in both 2005 and 2003, but I get the MissingMethodException. Is there somewhere special I need to put the DLL. I have the extern "C" in front of my dll method. What is the take here? When I view the details of my exception I can dig down deeper and see this "Can't find PInvoke DLL 'Unmanaged.dll'".
I enjoyed reading your article. It was very straight forward. I tried rebuilding your demo using the windows applications templates.
Instead of building the Managed application using Smart Device Appication wizzard, I chose C# Windows Application wizzard.
Instead of building the unmanaged project using the WCE Dynamic-Link Library eMbedded Visual C++ 4.0, I chose Win32 Project wizzard setting the wizzard to build Dynamic-link library that exports all symbols.
I followed the rest of your instructions exactly. I feel that I reduplicated your managed C# / Unmanaged eMbedded C++ application to a Managed C# / Unmanged C++ application. When I execute this application, I get the following exception:
An unhandled exception of type 'System.DllNotFoundException' occurred in Managed.exe Additional information: Unable to load DLL (Unmanaged.dll)
As I far as I know it is possible to use the P/Invoke on .NET to call native functions from native .dlls created using EVC++. Now my question is whether I can call from the native dll. a method of the .net program, to create a bidirectional communication between 2 programs written one in .net and the other in EVC++. And even more, Can I create a managed .dll with .net and then call it from my EVC++ application? Many thanks in advance! It is critical for me to know if this is possible. Best wishes and regards to all!
I have never done this but my understanding is that you need to create a COM wrapper around your .Net component, and then use COM in your unmanaged code to call the wrapper. There are articles in MSDN on the various interop possibilities.
Thanks Adrian, The problem now, is that .NET Compact Framework (which is the platform for mobile devices) does not support interoperability with COM objets. The way to access COM objects is calling native DLLs which in turn can access COM DLLs. So this solution is not viable. There is almost no information in the web about how to do this, I know that is not a common way to operate... Thank you very much!
' global settings Dim g_objFS Dim g_objWshShell Dim g_rebuild Dim g_clean Dim strNewConfigurationName int errors Dim ErrorTextStream
' ***************************************************************************** ' script entry point; retrieve arguments and build
WScript.Echo "Make eVC++, Version " & MAKEEVC_VERSION + vbCrLf + _ "Copyright (C) 2005 Baxter HealthCare Inc. All rights reserved." + vbCrLf
Set g_objFS = WScript.CreateObject("Scripting.FileSystemObject") If Err.Number <> 0 Then ExitWithError "Failed to create Scripting.FileSystemObject." Set g_objWshShell = CreateObject("WScript.Shell") If Err.Number <> 0 Then ExitWithError "Failed to create WScript.Shell."
' process command-line arguments If WScript.Arguments.Count < 6 Then ' too few parameters WScript.Echo "Usage: cscript " & WScript.ScriptName & " <Inputdir> <InputName> <InputPath> <ConfigurationName> <TargetPath> [/rebuild]|[/clear]" WScript.Quit -1 End If
'out with the old If g_objFS.FileExists(strTargetPath) = true Then g_objFS.DeleteFile strTargetPath End If 'and the log file If g_objFS.FileExists(strInputDir & "errorlog.txt") = true Then g_objFS.DeleteFile(strInputDir & "errorlog.txt") End If
If g_clean Then errors = g_objWshShell.Run( strEVCPath & " " & strInputPath & " /make " & strBuild & " /clean",2,1) If errors <> 0 Then WScript.Quit errors End If ElseIf g_rebuild Then errors = g_objWshShell.Run( strEVCPath & " " & strInputPath & " /make " & strBuild & " /out errorlog.txt /rebuild",2,1) If errors = 0 Then If g_objFS.FileExists(strInputDir & "errorlog.txt") = true Then g_objFS.DeleteFile(strInputDir & "errorlog.txt") End If Else Set ErrorTextStream = g_objFS.OpenTextFile(strInputDir & "errorlog.txt", 1) Do While Not ErrorTextStream.AtEndOfStream WScript.Echo(ErrorTextStream.ReadLine) Loop ErrorTextStream.Close WScript.Quit errors End If If g_objFS.FileExists(strBuildPath) = true Then g_objFS.CopyFile strBuildPath, strTargetPath Else WScript.Quit -1 End If Else errors = g_objWshShell.Run( strEVCPath & " " & strInputPath & " /make " & strBuild & " /out errorlog.txt",2,1) If errors = 0 Then If g_objFS.FileExists(strInputDir & "errorlog.txt") = true Then g_objFS.DeleteFile(strInputDir & "errorlog.txt") End If Else Set ErrorTextStream = g_objFS.OpenTextFile(strInputDir & "errorlog.txt", 1) Do While Not ErrorTextStream.AtEndOfStream WScript.Echo(ErrorTextStream.ReadLine) Loop ErrorTextStream.Close WScript.Quit errors End If If g_objFS.FileExists(strBuildPath) = true Then g_objFS.CopyFile strBuildPath,strTargetPath Else WScript.Quit -1 End If End If
WScript.Quit errors ' exit with success code if we got here
I am using exactly this configuration, as an old C++/MFC programmer, trying to move to the .NET and using still the CCeDBDatabase class, but I have no idea what the format of the file is and wonder about using it (this seems to be old technology, going back to 1998 or so)
For a C++ / MFC environment, what would be a better option, how can I use ADO for example or any other suggestion.