rapi2.dll registration

Apr 21, 2012 at 6:07 PM


I built a simple application using rapi2.dll ( Latest version )

First of all - thank you for this wonderful wrapper, it saved me a lot of time.

Second - I wrote a simple Main entry point to only print the remote device information - nothing else.

Application is built successfully in Visual Studio 2010 using .NET framework version 4.

I try to run the application without ActiveSync installed - I'm aware that it can not work, but I'm expecting a "Device is not connected" message to be printed.

The error I'm getting is "
Unhandled Exception: System.TypeInitializationException: The type initializer for 'System.Devices.RemoteDeviceManager' threw an exception. ---> System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {35440327-1517-4B72-865E-3FFE8E97002F} failed due to
the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
   at System.Devices.RemoteDeviceManager..cctor()
   --- End of inner exception stack trace ---

A Google search for the above exception introduced me to Regsvr32.exe tool which I probably need to use in order to register rapi2.dll.

When I try to use it though, I get a popup message "

The module "RAPI2.dll" was loaded but the entry-point DllRegisterServer was not found.

Make sure that "RAPI2.dll" is a valid DLL or OCX file and then try again.


My question is : Is it possible that this exception and error are caused only because ActiveSync is not installed? Or in other words - If I'll install ActiveSync is there a possibility that these problems will be solved?

Thank you!

Apr 23, 2012 at 5:51 AM

That exception is basically saying, "When you tried to startup the RAPI2 base manager, the underlying COM object was not found on the system." So yes, if you intall ActiveSync, this exception will go away. Pretty much if the constructor for RemoteDeviceManager throws any exception, you likely have an ActiveSync problem.

Apr 24, 2012 at 9:32 AM

Thank you very much for your fast responses - It helps me a lot.

I'm going to try and install ActiveSync and hopefully to close this discussion.


Apr 24, 2012 at 8:49 PM

Does anybody know how to late bind the RAPI2 DLL.....or able to provide an example??

I'm trying to make the RAPI portion of my application "optional" which is presenting multiple challenges since ActiveSync MUST be installed at runtime (the guys problem above).  I've tried to trap the application unhandledexception that's thrown, but it ignores my e.ExitApplication=false and always terminates the application regardless.  So I'm thinking the only way to do this is to late-bind the rapi2 and trap anything gracefully then.

Any ideas would be greatly appreciated.  Perhaps an enhancement to the DLL to help out in this area would also be a beautiful thing!!



Apr 24, 2012 at 9:13 PM

In the 2.0 release download that was posted today, there is smarter handling of a missing library. If it is missing, an InvalidOperationException will be thrown when constructing RemoteDeviceManager.

Apr 24, 2012 at 9:36 PM

I'm using the new 2.0 library...and I get an Unhandled innerexception that refers to the missing system.devices class.  This occurs on application load in my application event handler....presumably before the RemoteDeviceManager is even constructed.

Any other ideas??



Apr 24, 2012 at 9:57 PM

My mistake...sorry for the trouble!!  I was instantiating the rapimgr with NEW keyword.  Changed that to a declaration then made NEW assignment elsewhere.  Now it throws the exception where I can trap it in a Try.  FYI - the exception I get is "Type Initializer for System.Devices.RemoteDeviceManager threw an exception".

Thanks again for all your help!!  Perhaps others will benefit from my mistake as well!!


Jun 8, 2012 at 5:56 AM

I also face the same thing


I have a program that load RAPI2 in OnLoad event. But if no Active Sync installed, error will come up.


I suppose the only way to guard this is during loading, check for Active Sync installation. If not installed, prompt the user to install first before using the program.


However, this problem does not happen if using Win7 and Windows Mobile Device Center. If the Windows Mobile Device Center not installed, it can run. 


Different behaviors between Microsoft ActiveSync and Windows Mobile Device Center...