Exception dialog

S

Steve Long

Help,
I'm running VS.NET 2003 and when I try to start my application, I get the
"unhandled exception" dialog instead of the IDE highlighting the offending
line of code. The problem appears to be instantiating a particular class in
my project but the dialog doesn't tell me what code in the class is causing
the problem (and it a large class).

How can I get the IDE to take me to the offending line of code?
If I put this line in my machine.config file:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

the IDE tells me that there's something wrong with that line in
machine.config.
The registry contains the correct values for the debugger.
for instance
DbgJITDebugLaunchSetting is set to 2
and
DbgManagedDebugger is set to "C:\Program Files\Common Files\Microsoft
Shared\VS7Debug\vs7jit.exe" PID %d APPDOM %d EXTEXT "%s" EVTHDL %d

If anybody has any ideas on this one, I would sure appreciate the help.

Thanks
Steve
 
G

Greg Young

look at the stack trace of the exception (and possibly recurse
innerexceptions) ...
 
S

Steve Long

I didn't want to post this but here's the message text and I don't really
get much out of it. The IDE isn't breaking on the exception so I'm not
getting anything but this.

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.TypeLoadException: Signature of the body and declaration in a method
implementation do not match. Type: iMap.GUIMgr. Assembly: iMap,
Version=1.0.1634.22071, Culture=neutral, PublicKeyToken=null.
at iMap.frmMain.frmMain_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
iMap
Assembly Version: 1.0.1634.22071
Win32 Version: 1.0.1634.22071
CodeBase: file:///C:/Projects2003/Vb.net/iMap/bin/iMap.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
Logger
Assembly Version: 1.0.1301.18847
Win32 Version: 1.0.1301.18847
CodeBase: file:///C:/Projects2003/Vb.net/iMap/bin/Logger.DLL
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
SharpUI.Toolbars
Assembly Version: 1.1.0.1208
Win32 Version: 1.1.0.1208
CodeBase:
file:///c:/windows/assembly/gac/sharpui.toolbars/1.1.0.1208__f517ee9424cd48d0/sharpui.toolbars.dll
----------------------------------------
ESRI.MapObjects2.Control
Assembly Version: 2.2.1.0
Win32 Version: 2.2.1.0
CodeBase:
file:///c:/windows/assembly/gac/esri.mapobjects2.control/2.2.1.0__8fc3cc631e44ad86/esri.mapobjects2.control.dll
----------------------------------------
TransparentLabel
Assembly Version: 1.0.1585.23801
Win32 Version: 1.0.1585.23801
CodeBase: file:///C:/Projects2003/Vb.net/iMap/bin/TransparentLabel.DLL
----------------------------------------
ActiveReports.XlsExport
Assembly Version: 3.2.1.1978
Win32 Version: 3.2.1.1978
CodeBase:
file:///c:/windows/assembly/gac/activereports.xlsexport/3.2.1.1978__cc4967777c49a3ff/activereports.xlsexport.dll
----------------------------------------
ActiveReports.TextExport
Assembly Version: 3.2.1.1978
Win32 Version: 3.2.1.1978
CodeBase:
file:///c:/windows/assembly/gac/activereports.textexport/3.2.1.1978__cc4967777c49a3ff/activereports.textexport.dll
----------------------------------------
SharpUI.Shared
Assembly Version: 1.1.0.1208
Win32 Version: 1.1.0.1208
CodeBase:
file:///c:/windows/assembly/gac/sharpui.shared/1.1.0.1208__f517ee9424cd48d0/sharpui.shared.dll
----------------------------------------
ESRI.MapObjects2.Core
Assembly Version: 2.2.1.0
Win32 Version: 2.2.1.0
CodeBase:
file:///c:/windows/assembly/gac/esri.mapobjects2.core/2.2.1.0__8fc3cc631e44ad86/esri.mapobjects2.core.dll
----------------------------------------
Accessibility
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/accessibility/1.0.5000.0__b03f5f7f11d50a3a/accessibility.dll
----------------------------------------
RegGisDLL1
Assembly Version: 1.0.1630.17941
Win32 Version: 1.0.1630.17941
CodeBase: file:///C:/Projects2003/Vb.net/iMap/bin/RegGisDLL1.DLL
----------------------------------------
Managers
Assembly Version: 1.0.1626.25141
Win32 Version: 1.0.1626.25141
CodeBase: file:///C:/Projects2003/Vb.net/iMap/bin/Managers.DLL
----------------------------------------
CCMapTools_Net
Assembly Version: 1.0.1630.24830
Win32 Version: 1.0.1630.24830
CodeBase: file:///C:/Projects2003/Vb.net/iMap/bin/CCMapTools_Net.DLL
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
 
B

bclegg

Steve said:
Help,
I'm running VS.NET 2003 and when I try to start my application, I get the
"unhandled exception" dialog instead of the IDE highlighting the offending
line of code. The problem appears to be instantiating a particular class in
my project but the dialog doesn't tell me what code in the class is causing
the problem (and it a large class).

How can I get the IDE to take me to the offending line of code?
If I put this line in my machine.config file:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

the IDE tells me that there's something wrong with that line in
machine.config.
The registry contains the correct values for the debugger.
for instance
DbgJITDebugLaunchSetting is set to 2
and
DbgManagedDebugger is set to "C:\Program Files\Common Files\Microsoft
Shared\VS7Debug\vs7jit.exe" PID %d APPDOM %d EXTEXT "%s" EVTHDL %d

If anybody has any ideas on this one, I would sure appreciate the help.

Thanks
Steve
Hi Steve,
As a quick handle to the problem
Put a try /Catch around the code
try
Lots of code...
Catch obj ex as exception
msgbox("Error is " & ex.message)
End try

From the result you can then put in further blocks to narrow it down
HTH Bob
 
S

Steve Long

This is not helpful. It's never getting to the line of code that seems to be
causing a problem. I'm instantiating an object in the Form.Load event and if
I comment that line of code out, all is well. However, if I leave that line
of code in, none of the code in the Form.Load event ever occurs. The best
message I get is:
System.TypeLoadException: Signature of the body and declaration in a method
implementation do not match. Type: iMap.GUIMgr. Assembly: iMap,
Version=1.0.1634.22071, Culture=neutral, PublicKeyToken=null.

Additionally,
I added a handler for the System.Windows.Forms.Application.ThreadException
event to try and trap this error and I get the same message as I just listed
above. I get nothing helpful here. If the CLR can detect an error, why am I
not taken to the offending line of code so I can fix it? I have looked
through the GUIMgr code and don't see anything obvious. I have looked at the
interfaces it implements and also don't see anything obvious. So, is there a
way to make the IDE stop throwing up this dumb Exception dialog and take me
to the error?

Steve
 
G

Greg Young

This is not helpful. It's never getting to the line of code that seems to
be
causing a problem. I'm instantiating an object in the Form.Load event and if
I comment that line of code out, all is well. However, if I leave that line
of code in, none of the code in the Form.Load event ever occurs. The best
message I get is:
System.TypeLoadException: Signature of the body and declaration in a method
implementation do not match. Type: iMap.GUIMgr. Assembly: iMap,
Version=1.0.1634.22071, Culture=neutral, PublicKeyToken=null.

sounds like there is an issue with the loading of the type ...
Additionally,
I added a handler for the System.Windows.Forms.Application.ThreadException
event to try and trap this error and I get the same message as I just listed
above. I get nothing helpful here. If the CLR can detect an error, why am I
not taken to the offending line of code so I can fix it? I have looked
through the GUIMgr code and don't see anything obvious. I have looked at the
interfaces it implements and also don't see anything obvious. So, is there a
way to make the IDE stop throwing up this dumb Exception dialog and take me
to the error?

The CLR is taking you to the line of code ... it is failing loading the
type.

Can you put up the code for the type ?
 
S

Steve Long

I didn't want to cause I didn't want to put anybody through looking at it.
It's huge. Here goes. You asked for it:

Option Explicit On
Imports Managers
Imports CCMapTools_Net
Imports NonComCCCollection
Imports ESRI.MapObjects2.Core
Imports DataDynamics.SharpUI
Imports DataDynamics.SharpUI.Input
Imports DataDynamics.SharpUI.Toolbars
Imports ADODB
Imports PlugIns
Imports RegGisDLL1
Imports CCSharpUITools
Imports LinkedList
Imports System.Reflection
Friend Class GUIMgr
Implements Managers.IGUIMgr


#Region "Constants"
Private Const DEFSRC As String = "CGUIMgr"
Private Const MENU_USAGE_FILE As String = "MenuUsage"
Private Const AB_LAYOUT As String = "ab.tbr"
Private Const PLUGINS_MENU_TEXT As String = "Plu&gIns"
Private Const PLUGINS_MENU_NAME As String = "putPlugIns"
Private Const MAIN_MENU As String = "mnuMain"
Private Const PLUGINS_SUBMENU_NAME As String = "smPlugins"
#End Region

#Region "Private member variables"
Private m_iResize_Interval As Short
Private m_iMapBottomBuffer As Short
Private m_sCurrentMap As String
Private m_sPreviousMap As String
Private m_sMLQName As String
Private m_bOrthosOn As Boolean
Private m_sPlugInNames() As String
Private m_CurrentMap As String
#End Region

#Region "Private Complex objects"
Private mSharpTBM As UiToolbarManager
Private WithEvents m_oPictBox As System.Windows.Forms.PictureBox
Private m_oMap As ESRI.MapObjects2.Core.AxMap
Private WithEvents m_oToc As CCMapTools_Net.CToc
'Private m_oTab As AxMSComctlLib.AxTabStrip
'Private m_oLegend As AxCCMO2legend23.Axlegend
Private WithEvents m_cPrefMgr As CPreferencesMgr
Private m_cMapTips As CMaptips
Private m_ccolMLQs As NonComCCCollection.CCCollection
Private m_ccolViewTools As NonComCCCollection.CCCollection
Private m_ccolPlugIns As NonComCCCollection.CCCollection
Private m_ccolPlugInsLoaded As NonComCCCollection.CCCollection
Private m_cNavMgr As NavigationMgr
Private m_cImageLib As CImageLib
Private m_cSpatialQry As SpatialQryMgr
Private m_cImageMgr As CImageMgr
Private m_cSymDisp As CSymDisplayMgr '
Private m_cParcelSM As CParcelsSelectionMgr
Private m_oPlugInStrings As StringsLX
Private m_oLayersStrings As StringsLX
#End Region

#Region "Events"
Public Event NewFavoriteMap(ByVal MapName As String)
#End Region

#Region "Public Properties"
Public WriteOnly Property Map() As ESRI.MapObjects2.Core.AxMap
Set(ByVal Value As ESRI.MapObjects2.Core.AxMap)
m_oMap = Value
End Set
End Property
Public Property PreferencesMgr() As CPreferencesMgr
Get
End Get
Set(ByVal Value As CPreferencesMgr)
End Set
End Property
'Public Property CurrentLegend() As Object
' Get
' Return m_oLegend
' End Get
' Set(ByVal Value As Object)
' m_oLegend = Value
' End Set
'End Property
Public Property ToolbarManager() As
DataDynamics.SharpUI.Toolbars.UiToolbarManager Implements
IGUIMgr.ToolbarManager
Get
Return mSharpTBM
End Get
Set(ByVal Value As DataDynamics.SharpUI.Toolbars.UiToolbarManager)
mSharpTBM = Value
End Set
End Property
Public Property Toc() As CToc Implements Managers.IGUIMgr.Toc
Get
Return m_oToc
End Get
Set(ByVal Value As CToc)
m_oToc = Value
End Set
End Property
Public ReadOnly Property PlugInNames() As String()
Get
Static bInitialized As Boolean
Dim i As Short
If Not bInitialized Then
bInitialized = True
ReDim m_sPlugInNames(m_oPlugInStrings.Count - 1)
For i = 0 To m_oPlugInStrings.Count - 1
m_sPlugInNames(i) = m_oPlugInStrings.Item(i)
Next i
End If
Return m_sPlugInNames
End Get
End Property
Public ReadOnly Property PlugInShowName(ByVal CreateName As String) As
String
Get
Dim cItem As RegGisDLL1.CItemData
For Each cItem In m_ccolPlugInsLoaded
If cItem.regData = CreateName Then
Return cItem.Item
End If
Next cItem
End Get
End Property
Public Property PluginLoaded(ByVal PlugInName As String) As Boolean
Get
If m_ccolPlugInsLoaded(PlugInName).Tag = "Loaded" Then
Return True
Else
Return False
End If
End Get
Set(ByVal Value As Boolean)
If Value Then
m_ccolPlugInsLoaded(PlugInName).Tag = "Loaded"
Else
m_ccolPlugInsLoaded(PlugInName).Item = ""
End If
End Set
End Property
Public ReadOnly Property DynamicViewTools() As CCCollection
Get
Return m_ccolViewTools
End Get
End Property
Public Property ImageMgr() As CImageMgr
Get
Return m_cImageMgr
End Get
Set(ByVal Value As CImageMgr)
m_cImageMgr = Value
End Set
End Property
Public Property MLQName() As String
Get
Return m_sMLQName
End Get
Set(ByVal Value As String)
m_sMLQName = Value
End Set
End Property
Public Property ShowMapTipCombos() As Boolean
Get
Return
mSharpTBM.Bands.Item("barMapTools").Tools.Item("miVcboLayers").Visible
End Get
Set(ByVal Value As Boolean)
Dim band As Toolbars.Band
band = mSharpTBM.Bands.Item("barMapTools")
With band
..Tools.Item("miVcboLayers").Visible = Value
..Tools.Item("miVcboFields").Visible = Value
If Value = True Then
Dim tol As DataDynamics.SharpUI.Toolbars.EditTool =
..Tools.Item("miVcboLayers")
Dim cb As UiComboBox = tol.Control
cb.SelectedIndex = -1
tol = .Tools.Item("miVcboFields")
cb = tol.Control
cb.SelectedIndex = -1
End If
' I'm not sure I need these next three lines. We'll see
'If band.Tag = -1 Then
' mSharpTBM.Bands.Item("barParcels").DockingOffset = 0 ' band.DockingOffset
+ band.DockedVertWidth
'End If
' .Bands("barParcels").Left = .Bands("barMapTools").Left +
..Bands("barMapTools").Width
mSharpTBM.Refresh()
If Not Value Then
' Clear the maptip comboboxes
End If
End With
band = Nothing
End Set
End Property
Public Property CurrentMap() As String Implements
Managers.IGUIMgr.CurrentMap
Get
Return m_oToc.Activemap
End Get
Set(ByVal Value As String)
m_sCurrentMap = Value
m_cPrefMgr.StartupMap = Value
End Set
End Property
Public Property MapTips() As CMaptips
Get
Return m_cMapTips
End Get
Set(ByVal Value As CMaptips)
m_cMapTips = Value
End Set
End Property
#End Region

#Region "Constructors"
Public Sub New()
MyBase.New()
Init()
End Sub
#End Region

#Region "Public Methods"
Public Function MLQMapObj(ByRef MLQName As String) As CMLQMaps
MLQMapObj = m_ccolMLQs(MLQName)
End Function
Public Sub CallPlugIns(ByRef PlugInType As modMain.PlugInCalls, ByRef
PlugInParm() As Object)
Select Case PlugInType
Case modMain.PlugInCalls.epcSubjectSet
PlugIn_SetSubject(PlugInParm(0))
Case modMain.PlugInCalls.epcAddParcel
PlugIn_AddParcel(PlugInParm(0))
Case modMain.PlugInCalls.epcRemoveParcel
PlugIn_RemoveParcel(PlugInParm(0))
Case modMain.PlugInCalls.epcNewParcelSet
PlugIn_ParcelSetSelected(PlugInParm(0))
Case modMain.PlugInCalls.epcClearSelectedParcels
PlugIn_ClearSelectedParcels()
Case modMain.PlugInCalls.epcNewIdentity
If UBound(PlugInParm) < 1 Then
PlugIn_NewIdentity(CStr(PlugInParm(0)))
Else
PlugIn_NewIdentity(CStr(PlugInParm(0)), CBool(PlugInParm(1)))
End If
Case modMain.PlugInCalls.epcNewMailing
PlugIn_NewMailing(PlugInParm(0))
Case modMain.PlugInCalls.epcFeatureSelected
PlugIn_FeatureSelected(PlugInParm(0))
Case modMain.PlugInCalls.epcClearSelectedFeatures
PlugIn_ClearSelectedFeatures()
Case modMain.PlugInCalls.epcFeatureSetSelected
PlugIn_FeatureSetSelected(PlugInParm(0))
Case modMain.PlugInCalls.epcNewMLQ
PlugIn_NewMLQ(PlugInParm(0))
Case modMain.PlugInCalls.epcMapAdded
PlugIn_MapAdded(PlugInParm(0))
Case modMain.PlugInCalls.epcReleaseMoSelect
PlugIn_ReleaseMoSelect()
End Select
End Sub
Public Sub ChangeMap(ByVal newMap As String, ByVal resetToc As Boolean)
Implements Managers.IGUIMgr.ChangeMap
If newMap <> m_CurrentMap Then
ShowMapTipCombos = False
mSharpTBM.Commands.Item(CType(modMain.ToolIDs.etiMapTips, String)).Checked =
False
End If
m_sPreviousMap = m_CurrentMap
m_CurrentMap = newMap
'Clear selected features if necessary
If m_sPreviousMap <> m_CurrentMap Then
frmMaps.DefInstance.ShowNodeCurrentMap()
With m_cSpatialQry
Try
If .SelectedFeatures.Count > 0 Then
..Clear()
End If
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End With
End If
' Turn off photos if necessary
Dim cFld As CField
cFld = New CField
If OrthosOn(cFld) = 0 Then
UnCheckOrthos(cFld.Name)
m_cImageMgr.doOrthos(False)
End If
' If m_oActiveBar.Tools(CStr(etiOrthos)).Checked = True Then
' m_oActiveBar.Tools(CStr(etiOrthos)).Checked = False
' m_cImageMgr.doOrthos (False)
' End If
m_cPrefMgr.StartupMap = newMap
If resetToc Then
With m_oToc
..Activemap = newMap
..IsLoading = True
..Refresh()
End With
' this next thing could be a problem until I get the legend converted to
..NET
'With m_oLegend
' .set_ColTextLayers(m_oToc.TextLayerCollection)
' .LoadLegend(True)
'End With
m_oToc.IsLoading = False
End If
BuildLayersStrings()
doMapContext()
doZoomLayerContext()
doCBOLayersDropDown()
End Sub
Public Function CheckiMapTool(ByVal toolName As String) As Boolean
Implements Managers.IGUIMgr.CheckiMapTool
' Implement this before doing any plugins
End Function
Public Sub DocPlugin(ByVal frm As System.Windows.Forms.Form) Implements
Managers.IGUIMgr.DocPlugin
End Sub
Public Function GetiMapForm() As System.Windows.Forms.Form Implements
Managers.IGUIMgr.GetiMapForm
End Function
Public Function UnCheckAlliMapTools() As Boolean Implements
Managers.IGUIMgr.UnCheckAlliMapTools
End Function
Public Sub doHistoricPhotos()
Dim ATLStrings As StringsLX
Dim cLink As CLinkedList
Dim abTool As DataDynamics.SharpUI.Toolbars.Tool
Dim bnd As DataDynamics.SharpUI.Toolbars.Band
Dim i As Short
Dim cFld As CField
Dim s As String
Dim pic As System.Drawing.Image
pic = mSharpTBM.Commands("miVOrthos").Image()
mSharpTBM.Bands("mbMain").Tools("mbiMVOrthos").Visible = False
ATLStrings = New StringsLX(True, True)
bnd = mSharpTBM.Bands.Item("mnuHistoric")
bnd.Tools.Clear()
For Each cLink In m_cImageMgr.OrthoImageResolutions
ATLStrings.Add(cLink.Key)
Next cLink
' Get the highest tool id in the View category
'For Each abTool In mSharpTBM.Bands.Item("mnuView").Tools
' With abTool
' ' If (.ID Mod 700) < 100 Then
' If .ID > iToolCount Then
' iToolCount = .ID
' End If
' ' End If
' End With
'Next abTool
'abTool = Nothing
'frmMain.DefInstance.HistoricToolIDMin = iToolCount + 1
If m_ccolViewTools Is Nothing Then
m_ccolViewTools = New CCCollection
End If
' PrintAllTools App.Path & "\AllTools.txt", m_oActiveBar, "Before Adding
Photos", False
Dim cmd As DataDynamics.SharpUI.Toolbars.Command
bnd = mSharpTBM.Bands("miVOrthos")
Dim td As ToolDefine
td.sTooltype = SharpUIUtilities.ToolType.eButtonTool
With ATLStrings
For i = 0 To .Count - 1
cmd = New DataDynamics.SharpUI.Toolbars.Command("cmd" & .Item(i), "View")
cFld = New CField
' Add the tool
With abTool
s = LCase(.Name)
If s <> "current" And Left(s, 1) <> "2" Then
s = "19" & .Name & " year photos"
ElseIf Left(s, 1) = "2" Then
s = .Name & " year photos"
Else
s = .Name & " year photos"
End If
abTool = AddTool(s, ATLStrings(i), td, cmd, bnd)
cmd.Text = s
If s <> "current" And s <> "2000" Then
cmd.Tooltip = "Displays 19" & .Name & " Year photos"
Else
cmd.Description = "Displays " & .Name & " Year photos"
cmd.Tooltip = "Displays " & .Name & " Year photos"
End If
With cFld
..Name = abTool.Name
'.Value = abTool.ID
End With
End With
' Insert the tool on the Historic photos band
abTool.Image = pic
mSharpTBM.Bands.Item("mnuHistoric").Tools.Add(abTool)
m_ccolViewTools.Add(cFld.Name, cFld)
cFld = Nothing
Next i
'frmMain.DefInstance.HistoricToolIDMax = iToolCount
End With
' PrintAllTools App.Path & "\AllTools.txt", m_oActiveBar, "After Adding
Photos"
ATLStrings = Nothing
cLink = Nothing
abTool = Nothing
cFld = Nothing
pic = Nothing
End Sub
Public Sub doMapContext()
' Adds the tools to the map context dropdown
' Steve Long 8/28/2000
'--------------------------------------------
Dim oTool As DataDynamics.SharpUI.Toolbars.Tool
Dim oBand As DataDynamics.SharpUI.Toolbars.Band
Dim i As Short
Dim s As String
' Dim lyr As MapObjects2.MapLayer
oBand = mSharpTBM.Bands.Item("popMapContext")
oBand.Tools.Clear()
' For Each lyr In m_oMap.Layers
' WHEN TOC IS REDEVELOPED, WE WILL GET THIS INFORMATION ABOUT WHETHER
' TO INCLUDE THE LAYER FROM IT.
For i = 0 To m_oLayersStrings.Count - 1
' If LCase(Left(lyr.Name, 3)) <> "txt" And LCase(Left(lyr.Name, 5)) <>
"image" Then
s = m_oLayersStrings.Item(i)
oTool = New DataDynamics.SharpUI.Toolbars.ButtonTool
oTool.Text = s
oBand.Tools.Add(oTool)
Next i
End Sub
Public Sub doMapTips(Optional ByVal LayerName As String = "", _
Optional ByVal FieldName As String = "", _
Optional ByRef Visible As Boolean = True)
Dim clyr As CLyrAttribute
If Not Visible Then
m_cMapTips.Visible = False
Return
End If
Dim sLayer, sField As String
clyr = CType(m_oToc.LayerAttributes.Item(sLayer),
CCMapTools_Net.CLyrAttribute)
If LayerName = "" Then
sLayer = m_cPrefMgr.MapTipLayer
If sLayer = "" Then
sLayer = "Taxlots"
sField = "Serial_num"
Else
sField = clyr.LabelField
End If
Else
sLayer = LayerName
If FieldName = "" Then
sField = clyr.LabelField
Else
sField = FieldName
End If
End If
With m_cMapTips
..SetLayer(m_oMap.Layers.Item(sLayer), sField)
..Visible = True
End With
End Sub
Public Sub doZoomLayerContext()
' Adds the tools to the ZoomLayer
' context menu
'--------------------------------
Dim oTool As DataDynamics.SharpUI.Toolbars.Tool
Dim oBand As DataDynamics.SharpUI.Toolbars.Band
Dim i As Short
Dim s As String
oBand = mSharpTBM.Bands.Item("popZoomLayer")
oBand.Tools.Clear()
For i = 0 To m_oLayersStrings.Count - 1
oTool = New DataDynamics.SharpUI.Toolbars.ButtonTool
oTool.Text = m_oLayersStrings.Item(i)
oBand.Tools.Add(oTool)
Next i
End Sub
Public Sub doMLQDropDown()
Dim bRet As Boolean
Dim oTool As CCSharpUITools.DDButtonTool
Dim oBand As DataDynamics.SharpUI.Toolbars.PopupMenu
Dim cmd As DataDynamics.SharpUI.Toolbars.Command
Dim i As Short
Dim s As String
If m_ccolMLQs Is Nothing Then
bRet = GetMLQs()
End If
oBand = mSharpTBM.Bands.Item("popMLQContext")
oBand.Tools.Clear()

Dim cmlq As CMLQMaps
For Each cmlq In m_ccolMLQs
Try
cmd = mSharpTBM.Commands("cmd" & cmlq.MLQName)
Catch ex As Exception
'
End Try
If cmd Is Nothing Then
cmd = New DataDynamics.SharpUI.Toolbars.Command("cmd" & cmlq.MLQName,
"Other", cmlq.MLQName)
End If
oTool = New CCSharpUITools.DDButtonTool(cmlq.MLQName)
oTool.Text = cmlq.MLQName
oBand.Tools.Add(oTool)
Next cmlq
End Sub
Public Sub doCBOFieldsDropDown()
Dim oTool As DataDynamics.SharpUI.Toolbars.EditTool
Dim s As String
Dim rsMo As ESRI.MapObjects2.Core.Recordset
Dim fld As ESRI.MapObjects2.Core.Field
Dim i As Integer
oTool = mSharpTBM.Bands.Item("barMapTools").Tools.Item("tbMcboFields")
s = mSharpTBM.Bands.Item("barMapTools").Tools.Item("tbMcboLayers").Text
rsMo = CType(m_oMap.Layers.Item(s), ESRI.MapObjects2.Core.MapLayer).Records
oTool.Items.Clear()
For i = 0 To rsMo.Fields.Count - 1
fld = rsMo.Fields.Item(i)
oTool.Items.Add(fld.Name)
Next
oTool = Nothing
rsMo = Nothing
fld = Nothing
End Sub
Public Sub doCBOLayersDropDown()
Dim i As Short
Dim oTool As DataDynamics.SharpUI.Toolbars.EditTool
Try
oTool = mSharpTBM.Bands.Item("barMapTools").Tools.Item("tbMcboLayers")
Catch ex As Exception
Return
End Try

oTool.Items.Clear()
For i = 0 To m_oLayersStrings.Count - 1
oTool.Items.Add(m_oLayersStrings.Item(i))
Next i
End Sub
Public Function GetPlugIn(ByVal PlugInName As String) As PlugIns.IPlugIn
Try
Return m_ccolPlugIns(PlugInName)
Catch ex As Exception
Return Nothing
End Try
End Function
Public Function IsPlugIn(ByVal PlugInName As String) As Boolean
Dim iPlug As PlugIns.IPlugIn
Try
iPlug = m_ccolPlugIns(PlugInName)
Return True
Catch ex As Exception
Return False
End Try
End Function
Public Function PlugIns(ByRef SymDispMgr As ISymbolDisplayMgr, _
ByRef ParcelSM As IParcelsSelectionMgr) As Integer
' Gets the available plugins and adds them to the
' plugins collection.
' Function must not be called before other object
' variable have been set.
' 0 = no error
' -1 = No plugins
' 91 = Some object variable not set
' err.number for all other errors
'--------------------------------------------------
Dim sPlugin As String
Dim vArray() As RegGisDLL1.CItemData
Dim i As Short
Dim abTool As DataDynamics.SharpUI.Toolbars.Tool
Dim abMenuTool As DataDynamics.SharpUI.Toolbars.Tool
Dim obj As Object
Dim popTool As DataDynamics.SharpUI.Toolbars.PopupTool
Dim iPlug As PlugIns.IPlugIn
Dim lABError As Integer
vArray = m_cPrefMgr.GetPlugins()
If vArray.GetUpperBound(0) > -1 Then
If m_oPlugInStrings Is Nothing Then
m_oPlugInStrings = New StringsLX(False, True)
End If
With mSharpTBM
popTool = .Bands.Item(MAIN_MENU).Tools(PLUGINS_MENU_NAME)
If popTool Is Nothing Then
popTool = AddMenu(PLUGINS_MENU_NAME, PLUGINS_MENU_TEXT)
End If
If popTool.SubBand Is Nothing Then
popTool.SubBand = AddMenuItem()
popTool.SubBand.Name = PLUGINS_SUBMENU_NAME
Else
popTool.SubBand.Tools.Clear()
End If
popTool.Text = "Plug-ins"
popTool.Visible = True
End With
Else
Return -1
End If
If m_ccolPlugIns Is Nothing Then
m_ccolPlugIns = New NonComCCCollection.CCCollection
End If
If m_ccolPlugInsLoaded Is Nothing Then
m_ccolPlugInsLoaded = New NonComCCCollection.CCCollection
End If
Dim td As ToolDefine
Dim cmd As DataDynamics.SharpUI.Toolbars.Command
td.sTooltype = SharpUIUtilities.ToolType.eButtonTool
Dim regdat As String()
For i = 0 To vArray.GetUpperBound(0)
If lABError = 0 Then
cmd = New DataDynamics.SharpUI.Toolbars.Command("cmd" & vArray(i).Item,
"Other", vArray(i).Item)
abTool = AddTool(vArray(i).Item, vArray(i).Item, td, cmd, popTool.SubBand)
cmd.Description = "Enables the " & vArray(i).Item & " plugin"
regdat = ParseRegData(vArray(i).regData)
abTool.Tag = regdat(1) & "." & regdat(2)
' this next line should be getting done in AddTool
'popTool.SubBand.Tools.Add(abTool)
End If
obj = LoadPlugin(regdat(0), regdat(1) & "." & regdat(2))
iPlug = DirectCast(obj, IPlugIn)
If Not iPlug Is Nothing Then
' set all the iPlugin object variables and add obj to the collection
With iPlug
..GUIMgr = Me
..ParcelSelectionMgr = ParcelSM
..SymbolDisplayMgr = SymDispMgr
..NavigationMgr = m_cNavMgr
..SpatialQueryMgr = m_cSpatialQry
End With
m_ccolPlugIns.Add(vArray(i).Item, obj)
m_ccolPlugInsLoaded.Add(vArray(i).Item, vArray(i))
m_oPlugInStrings.Add(vArray(i).Item)
iPlug = Nothing
obj = Nothing
End If
obj = Nothing
Next i
mSharpTBM.Refresh()
abTool = Nothing
abMenuTool = Nothing
iPlug = Nothing
Return 0
End Function
Public Function ShowOrthos(ByRef OrthosOn As Boolean) As Boolean
' Turns orthos photos on and off.
Dim reg As RegGisDLL1.RegGIS
If OrthosOn Then
If m_cImageLib Is Nothing Then
m_cImageLib = New CImageLib
reg = g_RegCtl.Reg
With m_cImageLib
..Ortho2Path = reg.Ortho2Path
..Ortho4Path = reg.Ortho4Path
..Ortho10Path = reg.Ortho10Path
..Ortho20Path = reg.Ortho20path
End With
End If
End If
End Function
Private Sub UnCheckOrthos(ByVal commandName As String)
mSharpTBM.Commands(commandName).Checked = False
End Sub
Public Sub UnDocControl(ByRef toolWindow As
DataDynamics.SharpUI.Toolbars.ToolWindow, _
ByRef ctl As Windows.Forms.Control)
If toolWindow.HostedControl Is ctl Then
toolWindow.HostedControl = Nothing
End If
End Sub
Public Sub Resize()
'With m_oMap
' .Width = m_oPictBox.Width
' .Height = VB6.TwipsToPixelsY(VB6.PixelsToTwipsY(m_oPictBox.Height) -
m_iMapBottomBuffer)
' .Left = 0
' .Top = 0
'End With
'With m_oTab
' .Width = m_oPictBox.Width
' .Top = m_oPictBox.Height - 7
'End With
With m_oToc
..MapHeight = m_oMap.Height
..MapWidth = m_oMap.Width
..MapTop = m_oMap.Top
..MapLeft = m_oMap.Left
End With
End Sub
#End Region

#Region "Private Methods"
Private Function OrthosOn(ByRef cFld As CField) As Integer
' Return in cFld the cFld object that contains the
' Tool name and Tool ID.
' Return Values:
' 0 = no error.
' error number for any other error.
' -1 = tool not found.
'--------------------------------------------------
Dim fld As CField
Dim bFound As Boolean = False
With mSharpTBM.Commands
For Each fld In m_ccolViewTools
If .Item(CStr(fld.Value)).Checked Then
cFld = fld
bFound = True
Exit For
End If
Next fld
End With
fld = Nothing
If Not bFound Then
Return -1
Else
Return 0
End If
End Function
Private Sub m_cPrefMgr_MapAdded(ByVal MapName As String) Handles
m_cPrefMgr.MapAdded
RaiseEvent NewFavoriteMap(MapName)
End Sub
Private Function GetMLQs() As Boolean
Dim rs As ADODB.Recordset
Dim cData As CDataMgr
Dim bRet As Boolean
Dim sql As String
Dim cMLQ As CMLQMaps
If m_ccolMLQs Is Nothing Then
cData = New CDataMgr
bRet = cData.OpenDB(Application.StartupPath & "\sql2K.mdb")
If bRet Then
m_ccolMLQs = New CCCollection
sql = "SELECT M.MLQName, M.MLQMap, L.LegendName FROM MLQs AS M, " & _
"MLQLayers AS L WHERE M.BaseLayer = L.LID"
rs = New ADODB.RecordsetClass
rs.Open(sql, cData.DB, CursorTypeEnum.adOpenStatic,
LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText)
With rs
If Not .EOF And .RecordCount > 0 Then
..MoveFirst()
Do While Not .EOF
cMLQ = New CMLQMaps
cMLQ.MLQName = .Fields("MLQName").Value
cMLQ.MLQMap = .Fields("MLQMap").Value
cMLQ.BaseLayer = .Fields("LegendName").Value
m_ccolMLQs.Add(cMLQ.MLQName, cMLQ)
..MoveNext()
Loop
End If
End With
End If
End If
Return True
End Function
Private Sub BuildLayersStrings()
Dim lyr As ESRI.MapObjects2.Core.MapLayer
Dim i As Integer
If m_oLayersStrings Is Nothing Then
m_oLayersStrings = New StringsLX(True, True)
Else
m_oLayersStrings.Clear()
End If
For i = 0 To m_oMap.Layers.Count - 1
lyr = m_oMap.Layers.Item(i)
If LCase(Left(lyr.Name, 3)) <> "txt" And LCase(Left(lyr.Name, 5)) <> "image"
Then
m_oLayersStrings.Add(lyr.Name)
End If
Next
' WHEN TOC IS REDEVELOPED, WE WILL GET THIS INFORMATION ABOUT WHETHER
' TO INCLUDE THE LAYER FROM IT.
End Sub
Private Sub ResizeMap(ByRef Height As Integer, ByRef Width As Integer)
With m_oMap
..Width = Width 'VB6.TwipsToPixelsX(Width)
..Height = .Height 'VB6.TwipsToPixelsY(Height)
..Left = 0
..Top = 0
End With
End Sub
Private Sub Init()
m_iResize_Interval = 50
m_iMapBottomBuffer = 350
m_cPrefMgr = New CPreferencesMgr
m_cPrefMgr.GetPreferences()
m_cMapTips = New CMaptips
GetMLQs()
End Sub
Private Sub LoadMenu()
' Figure this out later
End Sub
#End Region

#Region "Reflection for Plugins"
Private Function LoadPlugin(ByVal assemblyName As String, ByVal createName
As String, _
Optional ByVal assemVersion As String = "") As Object
Dim a As System.Reflection.Assembly
Dim tp As Type
Dim ass As String
If assemVersion = "" Then
ass = assemblyName & ", Version=" & assemVersion & ", Culture=nuetral,
PublicKeyToken=null"
Else
ass = assemblyName
End If
Try
a = [Assembly].Load(ass)
Catch ex As Exception
Return Nothing
End Try
If Not tp Is Nothing Then
tp = a.GetType(createName)
a = Nothing
Return tp
Else
a = Nothing
Return Nothing
End If
End Function
Private Function ParseRegData(ByVal obj As Object) As String()
If TypeOf obj Is String Then
Dim s As String = CType(obj, String)
Dim ipos As Integer
Dim chr(1) As Char
chr(0) = "."
Return s.Split(chr, 4)
End If
End Function
#End Region

#Region "Private Plugin support"
Private Sub PlugIn_AddParcel(ByVal sn As Double)
Dim iPlug As PlugIns.IPlugIn
Dim dicEntry As DictionaryEntry
For Each dicEntry In m_ccolPlugIns
iPlug = dicEntry.Value
iPlug.AddParcel(sn)
Next dicEntry
iPlug = Nothing
End Sub
Private Sub PlugIn_ClearSelectedFeatures()
Dim iPlug As PlugIns.IPlugIn
Dim dicEntry As DictionaryEntry
For Each dicEntry In m_ccolPlugIns
iPlug = dicEntry.Value
iPlug.ClearSelectedFeatures()
Next dicEntry
iPlug = Nothing
End Sub
Private Sub PlugIn_ClearSelectedParcels()
Dim iPlug As PlugIns.IPlugIn
Dim dicEntry As DictionaryEntry
For Each dicEntry In m_ccolPlugIns
iPlug = dicEntry.Value
iPlug.ClearSelectedParcels()
Next dicEntry
iPlug = Nothing
End Sub
Private Sub PlugIn_FeatureSelected(ByVal feature As PlugIns.IFeature)
Dim iPlug As PlugIns.IPlugIn
Dim dicEntry As DictionaryEntry
For Each dicEntry In m_ccolPlugIns
iPlug = dicEntry.Value
iPlug.FeatureSelected(feature)
Next dicEntry
iPlug = Nothing
End Sub
Private Sub PlugIn_FeatureSetSelected(ByVal features() As PlugIns.IFeature)
Dim iPlug As PlugIns.IPlugIn
Dim dicEntry As DictionaryEntry
For Each dicEntry In m_ccolPlugIns
iPlug = dicEntry.Value
iPlug.FeatureSetSelected(features)
Next
iPlug = Nothing
End Sub
Private Sub PlugIn_MapAdded(ByVal MapName As String)
Dim iPlug As PlugIns.IPlugIn
Dim dicEntry As DictionaryEntry
For Each dicEntry In m_ccolPlugIns
iPlug = dicEntry.Value
iPlug.MapAdded(MapName)
Next
iPlug = Nothing
End Sub
Private Sub PlugIn_NewIdentity(ByVal LayerName As String, Optional ByRef
AddTo As Boolean = False)
Dim iPlug As PlugIns.IPlugIn
Dim dicEntry As DictionaryEntry
For Each dicEntry In m_ccolPlugIns
iPlug = dicEntry.Value
iPlug.NewIdentify(LayerName, AddTo)
iPlug.LayerIdentify(LayerName, 0)
Next
iPlug = Nothing
End Sub
Private Sub PlugIn_NewMailing(ByVal LayerName As String)
Dim iPlug As PlugIns.IPlugIn
Dim dicEntry As DictionaryEntry
For Each dicEntry In m_ccolPlugIns
iPlug = dicEntry.Value
iPlug.NewMailing(LayerName)
Next
iPlug = Nothing
End Sub
Private Sub PlugIn_NewMLQ(ByRef pnt As ESRI.MapObjects2.Core.Point)
Dim iPlug As PlugIns.IPlugIn
Dim dicEntry As DictionaryEntry
For Each dicEntry In m_ccolPlugIns
iPlug = dicEntry.Value
iPlug.NewMLQ(pnt)
Next
iPlug = Nothing
End Sub
Private Sub PlugIn_ParcelSetSelected(ByRef SNs As Double())
Dim iPlug As PlugIns.IPlugIn
Dim dicEntry As DictionaryEntry
For Each dicEntry In m_ccolPlugIns
iPlug = dicEntry.Value
iPlug.ParcelSetSelected(SNs)
Next
iPlug = Nothing
End Sub
Private Sub PlugIn_ReleaseMoSelect()
Dim iPlug As PlugIns.IPlugIn
Dim dicEntry As DictionaryEntry
For Each dicEntry In m_ccolPlugIns
iPlug = dicEntry.Value
iPlug.ReleaseMoSelect()
Next
iPlug = Nothing
End Sub
Private Sub PlugIn_RemoveParcel(ByVal SN As Double)
Dim iPlug As PlugIns.IPlugIn
Dim dicEntry As DictionaryEntry
For Each dicEntry In m_ccolPlugIns
iPlug = dicEntry.Value
iPlug.RemoveParcel(SN)
Next
iPlug = Nothing
End Sub
Private Sub PlugIn_SetSubject(ByVal SN As Double)
Dim iPlug As PlugIns.IPlugIn
Dim dicEntry As DictionaryEntry
For Each dicEntry In m_ccolPlugIns
iPlug = dicEntry.Value
iPlug.ParcelSelected(SN)
Next
iPlug = Nothing
End Sub
#End Region

#Region "Event Handlers"
Private Sub MLQEventHandler(ByVal sender As Object, ByVal e As
CCSharpUITools.ToolEventArgs)
End Sub
#End Region
End Class
 

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