Select to view content in your preferred language

vb.net console application does not close

648
1
01-24-2019 06:42 AM
JoseSanchez
Regular Contributor

Hello everyone,

When I run vb.net Esri Console application, inside visual studio it works fine and it exist with code 0, but when I run the .exe alone it does not escape and it stays blocked in the Command Prompt window.

Module Module1

Private m_AOLicenseInitializer As LicenseInitializer = New LicenseInitializer()

<STAThread()> _

Sub Main()

'ESRI License Initializer generated code.

If (Not m_AOLicenseInitializer.InitializeApplication(New esriLicenseProductCode() {esriLicenseProductCode.esriLicenseProductCodeAdvanced},

New esriLicenseExtensionCode() {})) Then

Console.WriteLine(m_AOLicenseInitializer.LicenseMessage())

Console.WriteLine("This application could not initialize with the correct ArcGIS license and will shutdown.")

m_AOLicenseInitializer.ShutdownApplication()

Return

End If

Console.WriteLine("Start Processingon " & DateTime.Now.ToShortDateString)

 

InitializeData()

'ESRI License Initializer generated code.

'Do not make any call to ArcObjects after ShutDownApplication()

m_AOLicenseInitializer.ShutdownApplication()

 

Console.WriteLine("Completed Processing on " & DateTime.Now.ToShortDateString)

 

 

End Sub

End Module

0 Kudos
1 Reply
JoseSanchez
Regular Contributor

Good morning everyone,

This console application adds features in a feature class. This behavior appears only when the feature class is versioned, if the feature class is not versioned, the application exits when running as stand alone in a command prompt window.

I was able to find the reason why this behavior happens. It was caused by the "gputilities" object.

Replacing  gputilities.OpenFeatureClassFromString   with pWorkspaceFactory.OpenFromFile(strFile, 0) worked.

It looks like the "gputilities" object has some  strange behavior.

Hope it helps.

Dim pFeatureClassParcel As IFeatureClass
pFeatureClassParcel = gputilities.OpenFeatureClassFromString(strFC)

By

Dim pWorkspaceFactoryParcel As IWorkspaceFactory = New SdeWorkspaceFactoryClass()
Dim pFeatureWorkspaceParcel As IFeatureWorkspace
Dim pWorkspaceParcel As IWorkspace = Nothing
pWorkspaceParcel = pWorkspaceFactory.OpenFromFile(strFile, 0)
pFeatureWorkspaceParcel = CType(pWorkspaceParcel, IFeatureWorkspace)
Dim pFeatureClassParcel As IFeatureClass
pFeatureClassParcel = pFeatureWorkspaceParcel.OpenFeatureClass(strFC)

0 Kudos