MapPoint error - The RPC server is unavailable.

G

Guest

Hi,

I hope this is the most relevant newsgroup for this post.

I have a VB.NET app that uses the MapPoint component, and in my app I use
pushpins to display/retrieve GPS locations. Occasionally, when I call:

objMap.Distance(locNorthPole, locX)

my code catches an exception that's raised, the exception is:

Run-time exception thrown : System.Runtime.InteropServices.COMException -
The RPC server is unavailable.

I have searched on-line to try to find the cause/a solution to this and
haven't found much. Does anyone know if there's anything I can do to try to
solve this error, obviously I can catch and identify the error but once it's
occurred it seems to continuously reoccur until the app is closed and
restarted. I've tried calling Application.DoEvents (someone suggested that)
but it doesn't do anything for this problem.

Any ideas greatly appreciated,
Thanks,
Kath
 
J

Jeffrey Tan[MSFT]

Hi Kath,

Since you are using Application.DoEvents, I am assuming that you are
calling the MapPoint in a Winform application.

Can you tell me how do you reference the MapPoint WebService? Do you use
"Add Web Service"-> New a class instance-> Invoke WebMethod? I recommend
you provide the complete call stack information regarding this exception.
This requires you setup the debugging symbols for the debugger. Thanks

Based on the exception information, the problem likely means that mappoint
has shut down. Can we verify that mappoint is running at the time of the
error?

Finally, can you always reproduce this problem? Is there any detailed steps
to reproduce this issue? If so, please feel free to post here, I will give
it a try. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Hi Jeffrey,

Thanks for your reply.

I am using a MapPoint component in a windows form (which I called mpMap). It
is a COM control (MapPoint Control v11.0) I added to my toolbox, but I don't
believe it is a WebService. The references AxMapPoint and MapPoint have been
added to my project.

I have a variable on the form:

Private objMap As MapPoint.Map ' Map object

On my form load, I call the following code to initialise my map control:

' Set the map control to show the europe map template
mpMap.NewMap(MapPoint.GeoMapRegion.geoMapEurope)
' Retrieve the active map
objMap = mpMap.ActiveMap
' Set units to miles
Me.mpMap.Units = MapPoint.GeoUnits.geoMiles
' Provide map with toolbars
Me.mpMap.Toolbars.Item("Drawing").Visible = False
Me.mpMap.Toolbars.Item("Standard").Visible = True
Me.mpMap.Toolbars.Item("Navigation").Visible = True
Me.mpMap.Toolbars.Item("Location and Scale").Visible = True

I can reproduce this problem by running my code a couple of times, it
doesn't take long before it causes the exception. When the exception occurs,
I can see that MapPoint.exe is running in the processes.

The exception I first get has the message 'Unspecified error' with source
MapPoint, and then the message changes to 'The RPC server is unavailable' (if
there's an error I call the function again with the same parameters, I put
this in incase on the second or third try the function worked, so I could
return the correct info). The full call stack details are:

Code that fails (objMap.Distance function):
Public Sub CalcPos(ByRef objMap As MapPoint.Map, ByRef locX As
MapPoint.Location, ByRef dblLat As Double, ByRef dblLon As Double)
.....
dblLat = 90 - 180 * objMap.Distance(locNorthPole, locX) / dblHalfEarth
.....

Call Stack details:
GlimpseDesktop.exe!WindowsApplication1.modPublicFunctions.CalcPos(MapPoint.Map objMap = {System.__ComObject}, MapPoint.Location locX = {System.__ComObject}, Double dblLat = 2.0, Double dblLon = 2.0) Line 232 Basic

GlimpseDesktop.exe!WindowsApplication1.modPublicFunctions.CalcPos(MapPoint.Map
objMap = {System.__ComObject}, MapPoint.Location locX = {System.__ComObject},
Double dblLat = 2.0, Double dblLon = 2.0) Line 238 + 0x12 bytes Basic

GlimpseDesktop.exe!WindowsApplication1.frmMapPoint.LVMatchingAddresses_Click(Object
sender = {System.Windows.Forms.ListView}, System.EventArgs e =
{System.EventArgs}) Line 3630 + 0x45 bytes Basic
[<Non-user Code>]
GlimpseDesktop.exe!WindowsApplication1.frmSite.btnAddGPS_Click(Object
sender = {System.Windows.Forms.Button}, System.EventArgs e =
{System.EventArgs}) Line 1314 + 0xb bytes Basic
[<Non-user Code>]
GlimpseDesktop.exe!WindowsApplication1.Form1.btnSite_Click(Object sender =
{System.Windows.Forms.Button}, System.EventArgs e = {System.EventArgs}) Line
9253 + 0xb bytes Basic
[<Non-user Code>]
GlimpseDesktop.exe!WindowsApplication1.modMain.Main() Line 28 + 0xe
bytes Basic


Stack Trace details:

StackTrace " at MapPoint.Map.Distance(Location StartLocation, Location
EndLocation)
at WindowsApplication1.modPublicFunctions.CalcPos(Map& objMap, Location&
locX, Double& dblLat, Double& dblLon) in D:\My Documents\Visual Studio
Projects\Desktop App\App6\Desktop28\modPublicFunctions.vb:line 219" String

Exception details:

ex {System.Runtime.InteropServices.COMException} System.Exception
[System.Runtime.InteropServices.COMException] {System.Runtime.InteropServices.COMException}System.Runtime.InteropServices.COMException
HelpLink Nothing String
InnerException Nothing System.Exception
Message "The RPC server is unavailable."
Source "Interop.MapPoint"

The CalcPos function is called when we close the form, to get the latest
position of a pushpin on the map (which the user may have moved), see
function below.

Public Function GetGPSFromPushpin() As Boolean
.....
' If we've now been able to find a pushpin (if there's no
pushpin on the map at all, we won't)
If Not RecordSet.EOF Then
PushpinLoc = RecordSet.Pushpin.Location
CalcPos(objMap, PushpinLoc, lat, lon)
.....
End Function

Thanks,
Kath

"Jeffrey Tan[MSFT]" said:
Hi Kath,

Since you are using Application.DoEvents, I am assuming that you are
calling the MapPoint in a Winform application.

Can you tell me how do you reference the MapPoint WebService? Do you use
"Add Web Service"-> New a class instance-> Invoke WebMethod? I recommend
you provide the complete call stack information regarding this exception.
This requires you setup the debugging symbols for the debugger. Thanks

Based on the exception information, the problem likely means that mappoint
has shut down. Can we verify that mappoint is running at the time of the
error?

Finally, can you always reproduce this problem? Is there any detailed steps
to reproduce this issue? If so, please feel free to post here, I will give
it a try. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Kath,

Ok, I understand now that you are using the MapPoint COM component of
MapPoint product.

There is not much special in the call stack.

Can you provide the full code snippet of function CalcPos method? It will
be helpful to understand your code logic.

Also, is it possible for you to provide the detailed steps and a sample
project for me to reproduce the problem? This will be more efficient for us
to troubleshoot it.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Hi Jeffrey,

Thanks for your reply.

I created a sample project but couldn't replicate the error, so I was
messing around with the code and I realised that my mapping form and map
object were working fine the first time I opened the form, but when I closed
the form and re-opened it I was getting the RPC error straight away, so I
thought it must be something not being disposed of properly? I checked all my
objects and couldn't see what it would be, and noticed that in the CalcPos
function (see below) the variable locNorthPole was not nothing when used when
the form was opened for the second time, whereas I was expecting it to be
nothing. This CalcPos function was a public function in a module, as I use it
in more than one form. I copied the CalcPos function to the form classes of
the forms that use it (i.e. so each form uses it's own local declaration of
the function), and now locNorthPole is nothing everytime I open a new
instance of the form and the error has gone.

I don't completely understand what the cause was, but I guess something was
staying in memory and not allowing the new instance of mappoint to work
properly?

Note: CalcPos is a procedure edited from code provided by mp2kmag.com

Thanks,
Kath

Public Sub CalcPos(ByRef objMap As MapPoint.Map, ByRef locX As
MapPoint.Location, ByRef dblLat As Double, ByRef dblLon As Double)
Try
Static locNorthPole As MapPoint.Location
Static locSantaCruz As MapPoint.Location ' Center of western
hemisphere
Static dblHalfEarth As Double ' Half circumference of the earth
(as a sphere)
Static dblQuarterEarth As Double ' Quarter circumference of the
earth (as a sphere)
' Static Pi As Double

'Check if initialization already done. cos variables are static,
they keep their last value
' when this sub is next called, so we don't need to recalc these
values
If locNorthPole Is Nothing Then
locNorthPole = objMap.GetLocation(90, 0)
locSantaCruz = objMap.GetLocation(0, -90)
'Compute distance between north and south poles == half
earth circumference
dblHalfEarth = objMap.Distance(locNorthPole,
objMap.GetLocation(-90, 0))
'Quarter of that is the max distance a point may be away
from locSantaCruz and still be in western hemisphere
dblQuarterEarth = dblHalfEarth / 2
' Pi = 3.14159265358979
End If
'Compute latitude from distance to north pole
dblLat = 90 - 180 * objMap.Distance(locNorthPole, locX) /
dblHalfEarth
Dim l As Double
Dim d As Double
'Compute great circle distance to locX from point on Greenwich
meridian and computed Latitude
d = objMap.Distance(objMap.GetLocation(dblLat, 0), locX)
'convert latitude to radian
l = (dblLat / 180) * Math.PI
'Compute Longitude from great circle distance
dblLon = 180 * Acos((Cos((d * 2 * Math.PI) / (2 * dblHalfEarth))
- Sin(l) * Sin(l)) / (Cos(l) * Cos(l))) / PI
'Correct longitude sign if located in western hemisphere
If objMap.Distance(locSantaCruz, locX) < dblQuarterEarth Then
dblLon = -dblLon
MapPointFuncRetry = 0 ' reset
Catch ex As Exception
WriteToLog(" ERROR in CalcPos - " + ex.Message)
' If MapPoint is too busy, we get 'RPC unavailable' error msg,
so check for this and retry if nec.
If ex.Message.IndexOf("RPC") > -1 Or
ex.Source.IndexOf("MapPoint") > -1 Then
If MapPointFuncRetry < 2 Then
' recall this procedure up to 2 times (so runs 3 times
in all)
MapPointFuncRetry += 1
CalcPos(objMap, locX, dblLat, dblLon)
Else ' return these flag values, to flag that it has failed
MapPointFuncRetry = 0 ' reset
WriteToLog(" in CalcPos, returning -1 for both")
dblLat = -1
dblLon = -1
End If
Else
MapPointFuncRetry = 0 ' reset
WriteToLog(" in CalcPos, returning -1 for both")
dblLat = -1
dblLon = -1
End If
End Try
End Sub


"Jeffrey Tan[MSFT]" said:
Hi Kath,

Ok, I understand now that you are using the MapPoint COM component of
MapPoint product.

There is not much special in the call stack.

Can you provide the full code snippet of function CalcPos method? It will
be helpful to understand your code logic.

Also, is it possible for you to provide the detailed steps and a sample
project for me to reproduce the problem? This will be more efficient for us
to troubleshoot it.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Kath,

I have discussed this issue with our MapPonit program manager. However,
based on the code snippet, we still can not identify the root cause. Based
on the newsgroup nature, it would be helpful if you can narrow down your
project into a small one which can reproduce this issue.

If youare using CalcPos to get to the lat/long of a pushpin or location
object, MapPoint 2006 supports this build-in, is it possible for you to use
it?

Regarding locNorthPole is not nothing issue, can you tell me if your form
is closed is your application terminated? How do you start the Form?
locNorthPole is a static reference, so once the reference is assigned an
object, it will still point to this object. Also, when the second this
method is called, the locNorthPole reference will not be initialized again,
it will always use the first assigned object. So if your Form is closed
without terminating the process, the locNorthPole reference will point to
the first assigned object when it is called the second time. Does this make
sense to you? Did this cause your problem?

Please feel free to feedback, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Hi Jeffrey,

Comments below...
Hi Kath,

I have discussed this issue with our MapPonit program manager. However,
based on the code snippet, we still can not identify the root cause. Based
on the newsgroup nature, it would be helpful if you can narrow down your
project into a small one which can reproduce this issue.

I'm still not sure what difference moving the code made. Unfortunately, my
project is very large and attempts to re-create the problem in a sample
project have not been successful. As I have a long list of things to do I'm
afraid I don't have spare time to spend on creating a sample project, given
that the problem has already been fixed.
If youare using CalcPos to get to the lat/long of a pushpin or location
object, MapPoint 2006 supports this build-in, is it possible for you to use
it?

That's useful to know, thanks. We are MSDN subscribers so I'm sure we'll be
moving to MapPoint 2006 soon (we currently use 2004).
Regarding locNorthPole is not nothing issue, can you tell me if your form
is closed is your application terminated? How do you start the Form?
locNorthPole is a static reference, so once the reference is assigned an
object, it will still point to this object. Also, when the second this
method is called, the locNorthPole reference will not be initialized again,
it will always use the first assigned object. So if your Form is closed
without terminating the process, the locNorthPole reference will point to
the first assigned object when it is called the second time. Does this make
sense to you? Did this cause your problem?

I think I confused myself with this locNorthPole being nothing! I'm not sure
it was relevant. The variable will of course be nothing once I've closed my
form, as moving the code has made it a local variable to that form, so it
would be destroyed when the form was.


Sorry I can't be more help on the cause of the issue. I'm afraid my priority
has been to fix the problem, and moving the code seems to have done that.
Moving to MapPoint 2006 sounds like it will require some code redesign
anyway, and I may no longer need this function.

Thanks for your time and comments, hopefully if others have this problem
they may be able to solve it, even if we don't know the cause!

Thanks again,
Kath
 
J

Jeffrey Tan[MSFT]

Hi Kath,

Glad to hear that you finally can fix this issue, although we still can not
find the root cause. Sorry, our newsgroup support nature limited that it is
hard for us to troubleshoot an project specific issue. The most efficient
support approach for such project specific is still Microsoft PSS support
by case. The PSS engineers have the advantage of doing dump analysis and
remote debugging. Thanks for your understanding.

Anyway, if you need further help, please feel free to post, I will work
with you. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top