Solved

Active Sync error with Visual Studio 2008

Posted on 2009-07-06
16
831 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
With Windows Embedded Handheld, called Windows Mobile, Microsoft re-designed the user interface. The Start Icon moved down to the bottom, inside the menu bar area.   If you need to hide the Start Icon and/or the SIP (soft input panel, softwar…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now