Security.Exception when calling .net dll function

lukasfischer

New member
Joined
Dec 22, 2011
Messages
1
Programming Experience
Beginner
I am using a .NET assembly written by a small company for automation of their hardware. it is not signed, etc. and that's not an option.
i am getting security exceptions for certain calls.
Strangely, if i do the calls within a new thread, i don't have these problems, when i call them within the GUI Thread the same functions don't work.
The functions take values by reference, modify them and i process them afterwards. The .net dll is generated with LabVIEW.

This does not work:
VB.NET:
    Private Settings_val As String()
    Public ReadOnly Property Settings As String()
        Get
        If ID_val <> -1 Then
            Try
                Dim ret As API_return
                Dim mids() As String = {}
                Dim bars() As String = {}
                Dim analogs() As String = {}
                ret = ICGetSettingNames(ID, mids, bars, analogs)
                If ret = API_return.Successful Then
                    mids.Union(bars)
                    mids.Union(analogs)
                    quadSettings_val = mids
                End If
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
        End If


            Return Settings_val
        End Get
    End Property
This does work (of course without a return value):
VB.NET:
 Private Sub getSettings()
        If ID_val <> -1 Then
            Try
                Dim ret As API_return
                Dim mids() As String = {}
                Dim bars() As String = {}
                Dim analogs() As String = {}
                ret = ICGetSettingNames(ID, mids, bars, analogs)
                If ret = API_return.Successful Then
                    mids.Union(bars)
                    mids.Union(analogs)
                    quadSettings_val = mids
                End If
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
        End If


    End Sub
    Private Settings_val As String()
    Public ReadOnly Property Settings As String()
        Get
            Dim trd As New Threading.Thread(AddressOf getSettings)
            trd.Start()
            trd.Join()
            Return Settings_val
        End Get
    End Property
 
Top Bottom