简体   繁体   中英

GMAP Control ".NET is not a member of 'GMapControl'"

I am getting solution errors when trying to run my application using the GmapControl package. Deleted the lines with errors does not seem to affect the application in any way but allows me to run the application, shortly after a while of debugging the lines reappear in the designer.vb file and the errors return.

Me.GMap.Bearing = 0!
Me.GMap.CanDragMap = True
Me.GMap.Dock = System.Windows.Forms.DockStyle.Fill
Me.GMap.EmptyTileColor = System.Drawing.Color.Navy
Me.GMap.GrayScaleMode = False
Me.GMap.HelperLineOption = GMap.NET.WindowsForms.HelperLineOptions.DontShow 'Error Line
Me.GMap.LevelsKeepInMemory = 5
Me.GMap.Location = New System.Drawing.Point(3, 3)
Me.GMap.MarkersEnabled = True
Me.GMap.MaxZoom = 2
Me.GMap.MinZoom = 2
Me.GMap.MouseWheelZoomEnabled = True
Me.GMap.MouseWheelZoomType = GMap.NET.MouseWheelZoomType.MousePositionAndCenter 'Error Line
Me.GMap.Name = "GMap"
Me.GMap.NegativeMode = False
Me.GMap.PolygonsEnabled = True
Me.GMap.RetryLoadTile = 0
Me.GMap.RoutesEnabled = True
Me.GMap.ScaleMode = GMap.NET.WindowsForms.ScaleModes.[Integer] 'Error Line
Me.GMap.SelectedAreaFillColor = System.Drawing.Color.FromArgb(CType(CType(33, Byte), Integer), CType(CType(65, Byte), Integer), CType(CType(105, Byte), Integer), CType(CType(225, Byte), Integer))
Me.GMap.ShowTileGridLines = False
Me.GMap.Size = New System.Drawing.Size(658, 455)
Me.GMap.TabIndex = 1
Me.GMap.Zoom = 0R

The problem is a name clash. GMap is a namespace and that is what .NET is a member of but you have added a GMapControl with the name GMap as well, so that is what the compiler is interpreting that name as. Notice how those lines all have Me.GMap on the left? The ones with GMap on the right are being interpreted as referring to that same GMapControl rather than the appropriate namespace. If you change the name of the control then the issue will go away.

You may need to either delete those lines first or edit them by hand afterwards though, because the rename may change the name of the namespace as well.

This is an example of why it's important to put some thought into your control and other names. If you use names that are descriptive in your specific scenario then name clashes are less likely.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM