Select to view content in your preferred language

ArcGIS 10 VB6 compatibility - DocumentEvents

1715
10
12-21-2010 05:56 AM
FedericoAlbesano
Emerging Contributor
Hi,

even if a know VB6 is no more supported on ArcGIS 10 as a development tool, it has also been said that applications written in VB6 for earlier versions of ArcGIS (read 9.3.1) are expected to run on version 10 (http://events.esri.com/uc/QandA/index.cfm?fuseaction=answer&conferenceId=2F6DC1A1-1422-2418-883C3868...).

We have a VB6 ArcMap extension and for now we cannot afford migrating all that code to VB.NET.
I thing we're not alone in this kind of situation.
So we are now trying to make that extension work on ArcGIS 10.
We needed to hook some document events, so we put this code:


Private WithEvents m_DocEvt As DocumentEvents    

Private Sub IExtension_Startup(ByRef initializationData As Variant)
  On Error GoTo ErrorHandler
  
  Set objApplication = initializationData
    
  Exit Sub
ErrorHandler:
  MsgBoxShow "IExtension_Startup: " & Err.Number & " " & Err.Source & " " & Err.Description, vbCritical
End Sub

Private Property Let IExtensionConfig_State(ByVal ExtensionState As esriSystem.esriExtensionState)
  On Error GoTo ErrorHandler
  
  If ExtensionState <> m_extState Then
    'Activate
    If ExtensionState = esriESEnabled Then
      If InitializeExtension Then            'Our stuff  
        Set m_DocEvt = objApplication.Document   'Hook events (*) 
      Else
        ExtensionState = esriESUnavailable       
      End If
    ElseIf ExtensionState = esriESDisabled Then 
      Set m_DocEvt = Nothing
      StopExtension True                     'Our stuff                 
    End If
    m_extState = ExtensionState
  End If
  
  Exit Property
ErrorHandler:
  MsgBoxShow "IExtensionConfig_State LET: " & Err.Number & " " & Err.Source & " " & Err.Description, vbCritical
End Property


In ArcGIS 10, if we hook DocumentEvents in (*), when the first event is fired (NewDocument, OpenDocument, CloseDocument), even without writing any code in events procedure, ArcMap exits with AV ("ArcGIS Desktop has encountered a serious application error....")

Is someone experiencing this same problem?
Maybe ESRI forgot to update this class (DocumentEvents) that is specific for VB6? But what about VBA code?

Thanks in advance
Federico Albesano
0 Kudos
10 Replies
RichardWatson
Deactivated User
Try implementing all the events, i.e. write a function for every document event even if you do nothing.
0 Kudos
FedericoAlbesano
Emerging Contributor
It worked! Thanks for help.
We implemented only some events of IDocumentEvents (as common in VB6) and, until 10, it worked fine.
I wouldn't ever tryed your solution by myself.
Thanks again.
0 Kudos
GangYang
Emerging Contributor
It worked! Thanks for help.
We implemented only some events of IDocumentEvents (as common in VB6) and, until 10, it worked fine.
I wouldn't ever tryed your solution by myself.
Thanks again.


I have a similar problem. I tried also to implement all other events that were not used before ArcGIS 10. But the problem (arcgis crashes at exiting) remains! Have you or someone else really tried the suggestion?

Thank you.
0 Kudos
RichardWatson
Deactivated User
Yes, I had this same problem with VB6 code in version 10 and resolved it by implementing all the events.  I figured this out because the code was branching to address 0 which is intentionally reserved by the operating system.  This was the hint I needed.

Is the crash you are experiencing related to branching to address 0?  If so then you have the same problem.  Make sure that you implement >all< the events as defined in version 10.

If not then what is the unmanaged call stack when it crashes?
0 Kudos
FedericoAlbesano
Emerging Contributor
I have a similar problem. I tried also to implement all other events that were not used before ArcGIS 10. But the problem (arcgis crashes at exiting) remains! Have you or someone else really tried the suggestion?

Thank you.


Yes, I tryed that suggestion (implementing all events in IDocumentEvents) and it worked perfectly for me.
Please note that in my case ArcMap crashed only if I hooked DocumentEvents and on first event raised, not only on exit.
0 Kudos
BrianKrebs
Deactivated User
We still have some older apps that are built with VB6 and I'm having some issues. After uninstalling 9.3 and installing 10.0, I can run my apps that use map, ToC, toolbar and license controls directly within VB6, but I get "out of memory" or "ClassFactory cannot supply requested class" when I try to run the stand-alone apps that were compiled from VB6. Any suggestions?
0 Kudos
RichardWatson
Deactivated User
Standalone applications which call ArcObjects have to do some additional intialization in version 10.

In version 10, ESRI started to support side by side deployments but then abandoned the effort.  What that resulted in was additional complexity with no benefit.  If you do not set the version to use then the class factory cannot create the correct object.  ESRI plays a game here which you can see if you dig through the registry.
0 Kudos
FedericoAlbesano
Emerging Contributor
We still have some older apps that are built with VB6 and I'm having some issues. After uninstalling 9.3 and installing 10.0, I can run my apps that use map, ToC, toolbar and license controls directly within VB6, but I get "out of memory" or "ClassFactory cannot supply requested class" when I try to run the stand-alone apps that were compiled from VB6. Any suggestions?


Even if it's not well documented by ESRI for VB6 (there is no more SDK!), for running our VB6 standalone application on ArcGIS 10 runtime, we only added the following code before using any ArcObjects call or component:

Dim pVer As IArcGISVersion
  
Set pVer = New VersionManager
pVer.LoadVersion esriArcGISEngine, "10.0"       
 

This code require a reference to "ArcGisVersion 1.0 Type Library"

Hope this helps
0 Kudos
BrianKrebs
Deactivated User
Even if it's not well documented by ESRI for VB6 (there is no more SDK!), for running our VB6 standalone application on ArcGIS 10 runtime, we only added the following code before using any ArcObjects call or component:

Dim pVer As IArcGISVersion
  
Set pVer = New VersionManager
pVer.LoadVersion esriArcGISEngine, "10.0"       
 

This code require a reference to "ArcGisVersion 1.0 Type Library"

Hope this helps


In 9.3, you had to add a License Control to your form and you could right-click and go to properties and check the types of Product licenses you wanted your app to work with(ArcGIS Engine, ArcGIS Engine Enterprise GeoDatabase, ArcView, ArcEditor and ArcInfo).  When your app ran, it would automatically pick the correct license.  Since I now would have to pass productCode to pVer.LoadVersion, can I call pVer.LoadVersion multiple times passing it different productCodes to get the same effect?  Or do I have to try and determine the correct productCode license through code to use or maybe have the user select what license they have in order to apply the correct one?
0 Kudos