Solved

Active Sync error with Visual Studio 2008

Posted on 2009-07-06
16
845 Views
Last Modified: 2013-11-26
I am developing a  application using VS 2008 and the OpenNETCF library. It is throwing an error at this line of code in the ActiveSync object constructor:
dccMan = new DccMan();

the error is : Can't find PInvoke DLL 'rapi.dll'

I have ActiveSync 4.5 installed and running.

Help please.
thanks.
0
Comment
Question by:bmutch
  • 8
  • 7
16 Comments
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 24787752
check that rapi.dll is in windows (whatever it is on your system)\system32 folder.

does it show any specific error apart from that message? you might also try to P/Invoke LoadLibrary() method and load rapi.dll manually to see what happens
0
 
LVL 11

Expert Comment

by:kyodai
ID: 24787758
Well the error seems to be quite obvious from the message - did you check that you have the rapi.dll? If yes you should register it with regsvr32.
0
 

Author Comment

by:bmutch
ID: 24787864
it was in system32, registered it just in case, and no change...same error.
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 24

Expert Comment

by:alexey_gusev
ID: 24787882
so can you load it manually with LoadLibrary() ? and if no, what's the error code?
0
 

Author Comment

by:bmutch
ID: 24787906
can you give me the exact syntax using loadlibrary to load the dll?
thanks.
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 24787939
0
 

Author Comment

by:bmutch
ID: 24788100
from the above I get this:

Declare Function LoadLibraryW Lib "coredll.dll" (TODO) As TODO

can you tell me how to change this to utilize the rapi?
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 24788151
I usually use

http://www.developerfusion.com/tools/convert/csharp-to-vb/ 

to convert between VB.NET and C#

so it gives me

<DllImport("coredll.dll", EntryPoint := "LoadLibraryW", SetLastError := True)> _
Friend Shared Function LoadLibraryCE(ByVal lpszLib As String) As IntPtr
End Function

then you simply call it as

Try
      Dim hDll as IntPtr = LoadLibrary("rapi.dll")
catch exWin32 as Win32Exception
' check here
catch ex as Exception
' check here too
end try
0
 

Author Comment

by:bmutch
ID: 24788216
ok, I now have this and the LoadLibrary call succeeds, but still fails at same line: am  I suppossed to put this in the same mod as where it is erroring? am I suppossed to use the rapi_dll object somewhere?

    Declare Function LoadLibrary Lib "coredll" Alias "LoadLibrary" (ByVal lpLibFileName As String) As IntPtr

        Dim rapi_dll As Object = LoadLibrary("rapi.dll")




0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 24788430
no, this was just a test if it can be loaded at all

I've just downloaded OpenNETCF Communication library (from CodePlex where it migrated recently) and then used it in VS2008 in simple console app (with added reference to OpenNETCF.Desktop.Communication):

Imports OpenNETCF.Desktop.Communication

Module Module1

    Sub Main()
        Dim rapi As New RAPI()
        rapi.ActiveSync.ConnectNow()
    End Sub

End Module

I put a breakpoint in ActiveSync.cs:

            internal ActiveSync()
            {
                  try
                  {
                        // call CoCreateInstance
                        dccMan = new DccMan();   // <-- Breakpoint is set HERE
                        .....

... and worked like a charm :)

0
 

Author Comment

by:bmutch
ID: 24788530
... worked like a charm   - gee thanks  :)
that's exactly where mine is crashing...

ok, I just created a console app and it works, I will now try to determine why it works in this app and not the original - (smart device project)
0
 
LVL 24

Accepted Solution

by:
alexey_gusev earned 500 total points
ID: 24788558
ahhhhhh, you HAVE TO TELL IT :)

RAPI is for desktop only :)
0
 

Author Comment

by:bmutch
ID: 24788616
ok, thanks , I will now finish beating my head against the wall... :)
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 24788649
that said, you can use it FROM desktop to do many things on PDA, but not in the opposite direction
0
 

Author Comment

by:bmutch
ID: 24788678
yes, it helps to remember which direction you are going... :)
0
 

Author Closing Comment

by:bmutch
ID: 31600282
good job, thanks alexey
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
I recently asked a question (http://www.experts-exchange.com/Programming/Smartphones/Android/Q_28684946.html) about Computer Inventory applications for Mobile Devices.  I was specifically interested in an app I could use on my android phone.  The be…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question