C# calls Native DLL: Class not registered. Please help...

I am just trying to call COM Object from Windows Mobile 5.0 Device from Visual Studio 2005 using C#. I have a native com dll and I can  call it from Windows application. But when I tries to call the same dll from smart device, it doesn't work. It breaks in the com object. However, when I add the dll, it get all intellisense. The error is like:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in CEHarness.exeAdditional information: COM object with CLSID '{1B103B23-1243-11D5-94C4-00062999C513}' cannot be created due to the following error: Class not registered .

After that I went trying the Microsoft example. Step by Step: Incorporating COM Objects into Your .NET Compact Framework 2.0 Application at http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnnetcomp/html/med301_msdn_com_netcf2.asp
In the first exercise I got stuck...and get the same error when I try to call the COM from C#...
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in MyManagedCOMClient.exe
Additional information: COM object with CLSID '{B08E409B-F30C-4EFE-A217-ECA5F332E312}' cannot be created due to the following error: Class not registered .


I am new at Mobile device technology. I don't know why... I try to find out the answer in last three days but I am stuck...

Can somebody give me right direction. Thanks in advance



Answer this question

C# calls Native DLL: Class not registered. Please help...

  • DKode

    Thank you for the direction. Now I understand why it may not work.
    I don't know much about C++. I have the C++ code to create dll. It has four project. So after I compile the project with VS 2005, it generates a dll. It is using alt.
    So I after your suggestion, I tried to create an Alt Device Project. But in VS 2005, it creates lot of default file. So I am confused. I don't know how incorporated them with the windows source code.
    I am just wandering, is there any thing I can do to convert the generate dll to smart device dll Most probably, it is a bad question...

    Anyway, thank you for the showing me the direction.

  • BillyB26

    It will require some effort, but porting C++ code to C++ on pretty much identical platforms is not that hard. I've done some porting myself to Win32/C++ from various platforms and various languages (xNIX C, VAX Pascal, iRMX PL/M, IBM 370 Fortran IV) and it worked out just fine. Your company definitely can reuse this work with some modifications. But it’s not the matter of just coping the file to the device, sorry.
    < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />



  • Trixtan

    Yeah I meant ATL. Thank you for your reply. Actually, the company has invested lot of money to write COM object for windows. Therefore, they want to use the com without rewriting the code.
    Some of the dll are very big. My project is to investigate and give answer that they can use it for PDA or not. I know C# and how to call COM in managed code for windows. I am provided with C++ source for all COM object and I am facing problem to convert the dll for PDA. Converting dll for PDA looks very difficult as the code are very complex in C++.
    Now I know I will have hard time. Anyway, thank for your time and showing me the right direction.

  • _Bandit_

    Exactly, its native C++ DLL, it is compiled for specific subsystem (Win32) and specific CPU (x86) so it can run on desktop. Device has different subsystem (CE) and completely different processor (e.g. ARM). The reason you can’t use desktop native DLL on device is pretty much the same reason which prevents you from running Mac applications on PC – different processors and different OS.

    To fix that your DLL needs to be recompiled for CE/ARM (or other CPU your device has), that can be done with Visual Studio 2005 or with Embedded Visual C++. This DLL won’t run on desktop, so if you’re planning to use your DLL on desktop as well, please keep your original project.

    Please see this on how to register your DLL on CE device:

    http://forums.microsoft.com/msdn/showpost.aspx postid=92918&siteid=1
    < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />



  • AlinB

    You probably meant ATL...

    You can get rig of all files in the newly created project if you want to and replace them with files from desktop project. That is, however, unlikely to compile right away, you would have to do some manual tweaking to port the code. Or, you can use the default files and add functionality you need. That would require some C++ and COM knowledge, if you new to C++ it might be tough for you to do.

    By the way, why do you need this object in C++ Obviously you do not have it up and running, why can't you do it all from managed code < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />



  • Suraj R K

    Are you trying to use the very same DLL from desktop on device Is so, that won't work. You need to create a new COM DLL compiled specifically for device and properly register it.



  • Utku Selamo?lu

    I tried to use the Microsoft example. It is native C++ dll. I don't understand why it should not work. If you are right... then how you register the dll differently for devices using compact framework 2.0


  • C# calls Native DLL: Class not registered. Please help...