Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 5 of 5

InvalidCastException in OpenMap

This is a discussion on InvalidCastException in OpenMap within the MapPoint Desktop Discussion forums, part of the Map Forums category; I am having a problem moving a MapPoint solution from development to server. I am using MapPoint 2004 installed on ...

  1. #1
    kdulaney is offline Junior Member White Belt
    Join Date
    Jan 2005
    Posts
    8

    InvalidCastException in OpenMap

    I am having a problem moving a MapPoint solution from development to server. I am using MapPoint 2004 installed on my development workstation and VisualStudio.NET (framework 1.0).

    In my project I am referencing the MapPoint 11.0 Object Library (North America) type library 8.2 and using the Application.OpenMap() to open an existing MapPoint map.

    Everything works great on my workstation, but when I compile the code and move the application to a server (Also with MapPoint 2004 installed) I receive the following error:
    -----------------
    Exception: System.InvalidCastException
    Message: QueryInterface for interface MapPoint._Application failed.
    Source: MapPoint
    at MapPoint.ApplicationClass.OpenMap(String FileName, Boolean AddToRecentFiles)
    at VBMap.Map.Output()
    ------------------

    Can someone give me some suggestions? I have tried replacing the MapPoint 2004 object library reference with the COM dll (extracted from the tlb using the framework tblimp util as seen here: http://support.microsoft.com/default...EN-US;302898#1
    ) to no avail.

    Thank you.

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    OpenMap() works over a network without any problem. Is the path containting valid path? like: '\\machine\c\whatever\etc' ??

  3. #3
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Thank you for your help, Wilfried. It is greatly appreciated.

    The mappoint .ptm project path is relative to the application path and there is no server-to-server communiction (it all runs on one box) so i am not using a fully qualified path. i am just doing a simple open (I thought).

    My compiled .exe resides at
    c:\program files\visualoas\myapp.exe
    My mapPoint projects reside at
    c:\program files\visualoas\mappointprojects\Aproject.ptm.

    myapp.exe does something like this:
    Dim m_objApp As New MapPoint.Application()
    Dim m_objMap As MapPoint.Map

    m_objMap = m_objApp.OpenMap("MapPointProjects\Aproject.ptm", false)

    Like i said, the code works when running on my dev workstation, that's why i am confused. I can post my VB Class doe that does all the object stuff if you think it will help.

    Thanks again.

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    You can also use:

    Code:
                MP.NewMap(GeoMapRegion.geoMapEurope);
    whitch is 6he default setting and notht path depenefive.

  5. #5
    kdulaney is offline Junior Member White Belt
    Join Date
    Jan 2005
    Posts
    8
    This actually ended up being a server registry/pointer problem. I compared the file systems of the two machines and they were identical. However, a removal and reinstall of MapPoint fixed whatever registry or pointer problem it was having. Kind of strange considering the MapPoint applicatin itself ran fine and was able to open and create maps - I just couldn't use the object library to do it from code.

    Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. MappointControl OpenMap filename string length limitation
    By malejo in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-02-2005, 03:55 AM
  2. OpenMap in delphi ?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 05-13-2003, 12:23 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96