Link to home
Start Free TrialLog in
Avatar of ba272
ba272

asked on

Having trouble converting VB to C#

Hi,

I am trying to change a variable used in the MapPoint ActiveX control to hopefully get it to do what I need it to do.  I am trying to set a variable, UserControl, to true. But it throws the exception:

"Access is denied" when I try to set it to true.

I have been digging through the Help function, which uses VB only, and have found they have used an interesting term for the UserControl.  They say "Let".

Does anyone have any idea what I might try in C# to get past this exception?  If the property were read only, wouldn't it say so?  And how could it be read only if the help function shows that it's changable?

Thanks for the help.

Bob

  Dim objApp As New MapPoint.Application

  'Set up the application
  objApp.Visible = True
  objApp.UserControl = True

////

// a different function

    Dim objApp As New MapPoint.Application
    Dim objMap As MapPoint.Map
    Dim objLocNY As MapPoint.Location
    Dim objLocLA As MapPoint.Location
    Dim objCenter As MapPoint.Location
    Dim objTextbox As MapPoint.Shape

    'Set up application and create Location objects
    Let objApp.Visible = True
    Let objApp.UserControl = True
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ba272
ba272

ASKER

What do yo umake of my exception?  "Access denied"??
Can you post the complete error message with the additional info.
Avatar of ba272

ASKER

private AxMapPoint.AxMappointControl axMappointControl1;


GetMap().Application.Visible = true; /// XXX dies here

private MapPoint.Map GetMap()
{
      try
      {
            return axMappointControl1.ActiveMap;
      }
      catch ( Exception ex )
      {
      handles.LogException( "UpdateStreetsDatabase.DeletePushpin()", ex, "" );
      }
return null;
}
Can You post the message that is thrown when it gives the error. You normally get a message box with the message and additional information.
Avatar of ba272

ASKER

sorry.  coming right up.
Avatar of ba272

ASKER

     StackTrace      "   at MapPoint.Application.set_Visible(Boolean pVal)\r\n   at DMS.UpdateStreetsDatabase.inButton_Click(Object sender, EventArgs e) in c:\\texselogic\\projects\\dms\\updatestreetsdatabase.cs:line 712"      string
Avatar of ba272

ASKER

This line:

GetMap().Application.Visible = true; /// XXX dies here

is inside a button click handler
Avatar of ba272

ASKER

Fernando,

Here's the code from the Help function pertaining to setting the UserControl variable.


  Sub LeaveAppRunningAfterQuit()

  Dim objApp As MapPoint.Application
  Set objApp = CreateObject("mappoint.application")

  'Make the application visible
  objApp.Visible = True

  'Give the user control of the application
  objApp.UserControl = True

  End Sub
Hi Bob;

I have not used MapPoint before in a project. I have MapPoint 2006 on my system and if you would like I can attempt to run your code on my system to see if I can find the problem. If you would like me to help in that way if you would upload your complete project to the EE web site http://www.ee-stuff.com/login.php and login with your user name and password and then click on the Expert Area tab. Then you will be able to upload a zip file of your project. After the upload they will give you a link, if you post that link I then will be able to download the file and have a look at it.

Fernando
Avatar of ba272

ASKER

Fernando,

Thanks so much for offering to help.  I had no idea that  EE had such a site for transmissions.

Maybe I can put together a small example program that we can work on together.

Thanks,
Bob

Very Good. Also what version of MapPoint are you using, 2002, ..., 2006?
Avatar of ba272

ASKER

2004
Have you completed the test project as you were going to do and upload it to the EE web site yet?