How would I construct a <DllImport("xFx.dll")> into a compiled VB.net DLL Class.
I am coding a plugin for LCDStudio,(A C#.net app.), that compiles to a VB.net
dll. If I use a module my code compiles, but it throws an exception when I call
the sub "Listen" from my UserControl.
##############################################################
Unhandled Exception:
The type initializer for 'xAPPlugin.xAPListen' threw an exception.
System.TypeInitializationException
Stack Trace:
at xAPPlugin.xAPListen.Listen()
at xAPPlugin.UserControl1.Button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button,
Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr
wparam, IntPtr lparam)
Inner Exception:
Unhandled Exception:
The given path's format is not supported.
System.NotSupportedException
Stack Trace:
at System.Security.Util.StringExpressionSet.CanonicalizePath(String path,
Boolean needFullPath)
at
System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str,
Boolean needFullPath)
at
System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess
access, AccessControlActions control, String[] pathListOrig, Boolean
checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess
access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
at System.IO.Directory.CreateDirectory(String path, DirectorySecurity
directorySecurity)
at System.Windows.Forms.Application.GetDataPath(String basePath)
at System.Windows.Forms.Application.get_LocalUserAppDataPath()
at
ERSP.Utilities.Configuration.LocalFileModuleSettingsProvider.GetPropertyValues(S\
ettingsContext context, SettingsPropertyCollection collection)
at
System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider
provider)
at System.Configuration.SettingsBase.GetPropertyValueByName(String
propertyName)
at System.Configuration.SettingsBase.get_Item(String propertyName)
at System.Configuration.ApplicationSettingsBase.GetPropertyValue(String
propertyName)
at System.Configuration.ApplicationSettingsBase.get_Item(String propertyName)
at xFx.Properties.Settings.get_xAPHeaderUseExtendedUID()
at KCS.xAP.Framework.Message.xAPHeaderUID..ctor()
at KCS.xAP.Framework.Message.xAPHeaderBase..ctor()
at KCS.xAP.Framework.Message.xAPHeartbeat..ctor()
at KCS.xAP.Framework.Transport.xAPHubClientListener..ctor()
at xAPPlugin.xAPListen..cctor()
###################################################################
Here is the simple module. I can compile an exe sending its message recieved to
a textbox on a form and it works just fine. The compiled plugin runs just fine
in LCDStudio, till I call the "Listen" sub. Then "Something Bad Has Happened".
:)
#################################################################
Imports System
Imports KCS.xAP.Framework.Transport
Imports KCS.xAP.Framework.Message
Public Module xAPListen
Public Message1 As String
Public WithEvents listener As New xAPHubClientListener
Public Sub Listen()
On Error Resume Next
listener.Start()
'Message1 = (String.Format("My address={0}, UID={1}",
listener.Heartbeat.Source, listener.Heartbeat.UID))
End Sub
Sub Listener_EventHandler(ByVal sender As Object, ByVal msgEvent As
xAPMessageEventArgs) Handles listener.eventMessageReceived
On Error Resume Next
Dim msg As xAPMessage = msgEvent.Message
Dim hdr As xAPHeaderBase = msg.Header
Dim body As xAPMessageBody = msg.Body
Dim strhdr As String
Dim strbdy As String
Dim strmsg As String
strhdr = (String.Format("Received {0} from {1}, UID {2}", hdr.Class,
hdr.Source, hdr.UID))
If InStr(strhdr, "Message.Display") Then
For Each block As xAPMessageBlock In body
Message1 = ""
strbdy = (String.Format("Block: {0}", block.Name))
For Each parameter As String In block.Keys
Dim v As xAPPairValue = block(parameter)
strmsg = (String.Format("{0} = {1}", parameter, v.Value))
Message1 = Message1 & v.Value & vbCr
Next
Next
End If
End Sub
End Module
####################################################################
I have the reference set to the xFx.dll. I have searched google for an answer as
to why.
I believe I need to do a <DllImport("xFx.dll")>? But I cant seem to pull the
proper way to construct the Function from the xAP Framework xFx v2 Help file.
Any ideas? Am I on the right track?
...JJG