Active Sync error with Visual Studio 2008

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.
bmutchAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

alexey_gusevCommented:
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
kyodaiCommented:
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
bmutchAuthor Commented:
it was in system32, registered it just in case, and no change...same error.
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

alexey_gusevCommented:
so can you load it manually with LoadLibrary() ? and if no, what's the error code?
0
bmutchAuthor Commented:
can you give me the exact syntax using loadlibrary to load the dll?
thanks.
0
bmutchAuthor Commented:
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
alexey_gusevCommented:
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
bmutchAuthor Commented:
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
alexey_gusevCommented:
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
bmutchAuthor Commented:
... 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
alexey_gusevCommented:
ahhhhhh, you HAVE TO TELL IT :)

RAPI is for desktop only :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bmutchAuthor Commented:
ok, thanks , I will now finish beating my head against the wall... :)
0
alexey_gusevCommented:
that said, you can use it FROM desktop to do many things on PDA, but not in the opposite direction
0
bmutchAuthor Commented:
yes, it helps to remember which direction you are going... :)
0
bmutchAuthor Commented:
good job, thanks alexey
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.