Problem Accessing PhoneBook in VB.NET 2005

katta

New member
Joined
Jul 26, 2006
Messages
3
Programming Experience
1-3
I have problem accessing phonebook in VB.NET2005. I am using a MotorolaMPx220. My code is below.
VB.NET:
<DllImport([COLOR=#800000]"Cellcore.dll"[/COLOR], SetLastError:=[COLOR=#0000ff]True[/COLOR], CharSet:=CharSet.Unicode)> _
[COLOR=#0000ff]Public[/COLOR] [COLOR=#0000ff]Shared[/COLOR] [COLOR=#0000ff]Function[/COLOR] SimReadPhonebookEntry([COLOR=#0000ff]ByVal[/COLOR] hSim [COLOR=#0000ff]As[/COLOR] IntPtr, [COLOR=#0000ff]ByVal[/COLOR] dwLocation [COLOR=#0000ff]As[/COLOR] Int32, [COLOR=#0000ff]ByVal[/COLOR] dwIndex [COLOR=#0000ff]As[/COLOR] Int32, [COLOR=#0000ff]ByRef[/COLOR] lpPhonebookEntry [COLOR=#0000ff]As[/COLOR] SimPhoneBookEntry) [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Boolean
[/COLOR][COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Function
[/COLOR]
 
<StructLayout(LayoutKind.Sequential)> _
[COLOR=#0000ff]Public[/COLOR] [COLOR=#0000ff]Structure[/COLOR] SimPhoneBookEntry
[COLOR=#0000ff]Public[/COLOR] cbSize [COLOR=#0000ff]As[/COLOR] IntPtr
[COLOR=#0000ff]Public[/COLOR] dwParams [COLOR=#0000ff]As[/COLOR] IntPtr
[COLOR=#0000ff]Public[/COLOR] lpszAddress [COLOR=#0000ff]As[/COLOR] IntPtr
[COLOR=#0000ff]Public[/COLOR] dwAddressType [COLOR=#0000ff]As[/COLOR] IntPtr
[COLOR=#0000ff]Public[/COLOR] dwNumPlan [COLOR=#0000ff]As[/COLOR] IntPtr
[COLOR=#0000ff]Public[/COLOR] lpszText [COLOR=#0000ff]As[/COLOR] IntPtr
[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Structure[/COLOR] [COLOR=#008000]'SimPhoneBookEntry
[/COLOR]
 
[COLOR=blue]Public Sub[/COLOR] ReadPhoneBook()
 
[COLOR=#0000ff]Dim[/COLOR] hSim [COLOR=#0000ff]As[/COLOR] IntPtr
[COLOR=#0000ff]Dim[/COLOR] usedLoc [COLOR=#0000ff]As[/COLOR] UInt32
[COLOR=#0000ff]Dim[/COLOR] totalLoc [COLOR=#0000ff]As[/COLOR] UInt32
[COLOR=#0000ff]Dim[/COLOR] lpPhoneBookEntry [COLOR=#0000ff]As[/COLOR] Sim_Manager.SimPhoneBookEntry [COLOR=#008000]'= New [/COLOR][COLOR=#008000]
 
 
[/COLOR][COLOR=#0000ff]Try[/COLOR]
[COLOR=#0000ff]
[/COLOR][COLOR=#0000ff]Dim[/COLOR] val [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = Sim_Manager.SimInitialize(0, 0, 0, hSim)
 
Sim_Manager.SimGetPhonebookStatus(hSim, 16, usedLoc, totalLoc)
 
Sim_Manager.SimReadPhonebookEntry(hSim, 16, 1 ,pPhoneBookEntry)
 
Sim_Manager.SimDeinitialize(hSim)
[COLOR=#0000ff]Catch[/COLOR] ex [COLOR=#0000ff]As[/COLOR] Exception
MessageBox.Show(System.Runtime.InteropServices.Marshal.GetLastWin32Error())
MessageBox.Show(ex.ToString)
[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Try[/COLOR]
 
[COLOR=blue]End Sub[/COLOR]
I am getting error message "The remote connection to the device has been lost. Please verify the device connection and restart debugging"

I am not sure about the error.Can anyone help me to find out the error??
 
Last edited:
Quite a bit of info about this on the net. It seems that it is a random occurence. It comes then it goes away just as silently. How annoying!!! Most info suggests that it crops up during the change in build configuration from debug to release. Some say it's to do with the breakpoint they have set. I cant find any conclusive, or definitive answers. Sorry.
 
vis781,
Thank you for your quick reply. I have no idea about the Constants used to access phone book, ie SIM_PBSTORAGE_SIM. Can you please help me to find out any documentation on this constants?? I tried random constants to get the phone book status. thanks in advance..
 
Last edited by a moderator:
Back
Top