?
Solved

Having trouble converting VB to C#

Posted on 2006-10-21
14
Medium Priority
?
229 Views
Last Modified: 2008-02-26
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
0
Comment
Question by:ba272
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
14 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 2000 total points
ID: 17781741
Hi Bob;

I translated the VB code and tested it. Try this it worked for me.

      MapPoint.Application objApp = new MapPoint.Application();

      // Set up the application
      objApp.Visible = true;
      objApp.UserControl = true;

////

// a different function

      MapPoint.Application objApp = new MapPoint.Application();
      MapPoint.Map objMap;
      MapPoint.Location objLocNY;
      MapPoint.Location objLocLA;
      MapPoint.Location objCenter;
      MapPoint.Shape objTextbox;

      // Set up application and create Location objects
      objApp.Visible = true;
      objApp.UserControl = true;


Fernando
0
 

Author Comment

by:ba272
ID: 17781754
What do yo umake of my exception?  "Access denied"??
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 17781909
Can you post the complete error message with the additional info.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ba272
ID: 17781934
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;
}
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 17781950
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.
0
 

Author Comment

by:ba272
ID: 17781959
sorry.  coming right up.
0
 

Author Comment

by:ba272
ID: 17781977
     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
0
 

Author Comment

by:ba272
ID: 17781982
This line:

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

is inside a button click handler
0
 

Author Comment

by:ba272
ID: 17782006
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
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 17782645
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
0
 

Author Comment

by:ba272
ID: 17782670
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

0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 17782674
Very Good. Also what version of MapPoint are you using, 2002, ..., 2006?
0
 

Author Comment

by:ba272
ID: 17792180
2004
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 17792235
Have you completed the test project as you were going to do and upload it to the EE web site yet?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question