Hi,
I've been trying to create a multithreaded dll to be used for simple
error logging to a file. The DLL will need to be imported into a .NET
framework based application (Wonderware). I am having a problem
importing into wonderware, getting the error message "...Denotes a
field where a class was expected".
I carry out the threading using the Mutex object, can this be used in a
DLL class? It also imports System.IO and System.Threading - could this
be a factor?
The DLL seems to work when I use a dummy VB application to call it -
although it does get the logging mixed up (i.e. time not in sequence)
but it does prevent any file locking errors.
The structure of the class is as follows:
Public Class logMessageToFile
Private Shared FileLockMutex As New Mutex
Private Class loggerClass
Public strMessageText As String
*Some more public vars declared here*
Public Sub LogMessage()
* use mutex here*
* log messages to file*
* release mutex *
End sub
End Class
Public Shared Sub writeToLog(ByVal MsgText As String, *other params*)
Dim cLog As New loggerClass
Dim thread1 As System.Threading.Thread
thread1 = New Threading.Thread(AddressOf cLog.LogMessage)
cLog.strMessageText = MsgText
* store other params*
thread1.Start()
End sub
End class
As you can see I had difficulty ensuring that the variables remained
private to each thread so I [thought] had to use a class to store them.
If anyone can see any issues as to why this wouldn't work then let me
know and I will resolve them and try again in wonderware.
Thanks in advance,
Colly Mitchell