?
Solved

Active Sync error with Visual Studio 2008

Posted on 2009-07-06
16
Medium Priority
?
854 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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 2000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

If you are anything like me, you install many apps on your phone and have your life on it, sometimes literally.  When I bought my current phone, a Samsung Galaxy S5 from Verizon, they were only selling the versions with 16 GB internal.  I didn't rea…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

752 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