cancel
Showing results for 
Search instead for 
Did you mean: 

Error OpenFileDialog

Former Member
0 Kudos

Hi Friends

I'm an addon DEVELOPING SAP 8.81, when generating an error generatedOpenFileDialog

El subproceso actual debe establecerse en el modo de subprocesamiento controlado simple (Single Thread Apartment, STA) para poder realizar llamadas OLE. Asegúrese de que la función Main tiene marcado STAThreadAttribute. Esta excepción sólo se desencadena

My code is as follows


Public Function abrirOpenFileDialog()

        Try

            Dim MyTest As New OpenFileDialog

            Dim MyProcs As Process()

            MyProcs = Process.GetProcessesByName("SAP Business One")

            If MyProcs.Length > 0 Then

                'For i As Integer = 0 To MyProcs.Length - 1

                'Dim MyWindow As New WindowWrapper(MyProcs(i).MainWindowHandle)

                Dim MyWindow As New WindowWrapper(MyProcs(0).MainWindowHandle)

                MyTest.Filter = "Text Documents (*.txt)|*.txt"

                If MyTest.ShowDialog(MyWindow) = DialogResult.OK Then

                    coForm.DataSources.UserDataSources.Item("txt_archiv").Value = MyTest.FileName

                    System.Windows.Forms.Application.ExitThread()

                Else

                    System.Windows.Forms.Application.ExitThread()

                End If

                'Next

            Else

                oAplicacionSBO.SetStatusBarMessage("No SBO instances found.")

            End If

        Catch ex As Exception

            oAplicacionSBO.MessageBox("Error al Abrir OpenFileDialog. " & ex.Message)

        End Try

    End Function

Help Me!


Accepted Solutions (0)

Answers (1)

Answers (1)

former_member183750
Active Contributor
0 Kudos

Sorry, but you posted into an incorrect Discussion Forum. See from the Overview of this forum:

This space is dedicated to development and deployment of .NET applications that connect and interact with SAP BusinessObjects Enterprise, SAP BusinessObjects Edge, or SAP Crystal (Reports) Server. This includes the development of applications using the BusinessObjects Enterprise, Report Application Server, Report Engine, and Web Services SDKs.

To find the correct forum for your issue, please consult the Forum Finder for the New SCN documentation.

- Ludek