Solved

Active Sync error with Visual Studio 2008

Posted on 2009-07-06
16
850 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Let me explain this picture a little bit.  First, in case you haven't already guessed, you are looking at my 2 phones, an Android Samsung Galaxy S5 on the left and an iPhone 5 on the right.  They are on their respective cradles on my desk.  But, you…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
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 …

691 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