|
|
Clarion Language and Runtime Library
Started by Anand at 04-13-2008 11:17 PM. Topic has 9 replies.
 
 
|
|
Sort Posts:
|
|
|
|
04-13-2008, 11:17 PM
|
Anand
Joined on 04-14-2008
Posts 8
|
How to call clarion dll into a .NET environment
|
|
|
|
|
Can anyone help me on calling Clarion DLL's in .NET application??
|
|
|
|
|
Report
|
|
|
|
04-13-2008, 11:31 PM
|
Shankar
Joined on 10-24-2005
Dubai, UAE
Posts 219
|
Re: How to call clarion dll into a .NET environment
|
|
|
|
|
Hi Anand,
From my knowledge base - Author unknown
--------------------------------------------------
Here's an example of a real running application based on the FrameWork 2.0
I wrote a "wrapper" class around all the Clarion DLL function...
Public Class ClarionWrapper
Private Declare Ansi Sub AttachThreadToClarion Lib "c60runx.dll" Alias
"AttachThreadToClarion" (ByVal blnAllocateInstanceOfClarionThreadedData As
Boolean)
Private Declare Ansi Function GAVInitialize Lib "gavfpbq.dll" Alias
"GAVInitialize" (ByVal strDataPath As String, ByVal intLanguage As Integer)
As Integer
Private Declare Ansi Sub GAVGetLastError Lib "gavfpbq.dll" Alias
"GAVGetLastError" (ByRef oGAVErrorStructure As Structures.GAVErrorStructure)
Public Sub New()
AttachThreadToClarion(True)
End Sub
Public Sub Initialize(ByVal strDataPath As String, ByVal intLanguage As Integer)
If GAVInitialize(strDataPath, intLanguage) <> cwSuccess Then
Me.ThrowGAVError()
End If
End Sub
Protected Sub ThrowGAVError()
Try
Dim oGAVError As New Structures.GAVErrorStructure
GAVGetLastError(oGAVError)
Throw New Classes.GAVException(oGAVError)
Catch ex As Exception
Throw ex
End Try
End Sub
Regards
Shankar
|
|
|
|
|
Report
|
|
|
|
04-14-2008, 3:04 AM
|
Anand
Joined on 04-14-2008
Posts 8
|
Re: How to call clarion dll into a .NET environment
|
|
|
|
|
|
Hello Sankar,
Thanks for this quick response.
But what i am looking for is calling the clarion DLL through - DllImport - P/Invoke....
If you have idea on this.. then plz let me know...I am facing a problem with certain exceptions....
Thanks anyways..!!!
Regards,
Anand Vyas
|
|
|
|
|
Report
|
|
|
|
04-14-2008, 6:23 AM
|
Tony Tetley

Joined on 10-25-2005
Missouri, USA
Posts 80
|
Re: How to call clarion dll into a .NET environment
|
|
|
|
|
There are a series of articles on Clarion calling .NET and .NET calling Clarion in Clarion Mag.
Tony
|
|
|
|
|
Report
|
|
|
|
04-14-2008, 8:07 AM
|
Shankar
Joined on 10-24-2005
Dubai, UAE
Posts 219
|
Re: How to call clarion dll into a .NET environment
|
|
|
|
|
Hi Anand,
I don't use .NET and hence cannot help you but I found something else in my Knowledgebase - Author Unknown.
1.1 Procedure whitout input parameters or return value
Clarion
EjemploClarion PROCEDURE(), PASCAL, NAME(‘EJEMPLOCLARION’)
C#
[DllImport("clarion.dll", EntryPoint = "EJEMPLOCLARION", CharSet = CharSet.Ansi)] public static extern void EjemploClarion();
1.2 Procedure whitout input parameters and LONG return value
Clarion
EjemploClarion PROCEDURE(), LONG, PASCAL, NAME(‘EJEMPLOCLARION’)
C#
[DllImport("clarion.dll", EntryPoint = "EJEMPLOCLARION", CharSet = CharSet.Ansi)] public static extern int EjemploClarion();
Comments:
Same mechanism apply if clarion function returns another integer presicion, then in C# we switch to corresponding type, see the type equivalency table.
1.3 Procedure whitout input parameters and STRING return value
STRING clarion data type is propietary, doesn’t exists in other languages with this implementation, to work around this issue we use memory addresses in this way:
Clarion
EjemploClarion PROCEDURE(), LONG, PASCAL, NAME(‘EJEMPLOCLARION’) RetVal CSTRING(255) CODE
!Codigo del procedimiento
Return Address(RetVal)
C#
[DllImport("clarion.dll", EntryPoint = "EJEMPLOCLARION", CharSet = CharSet.Ansi)] public static extern String EjemploClarion();
Comments: Plataform invoke of .NET Framework Marshalls the *char[], \0 finished in a String C# Object, also you can use StringBuilder.
1.4 Procedure whit LONG input parameter
Clarion
EjemploClarion PROCEDURE(LONG par), PASCAL, NAME(‘EJEMPLOCLARION’)
C#
[DllImport("clarion.dll", EntryPoint = "EJEMPLOCLARION", CharSet = CharSet.Ansi)] public static extern void EjemploClarion(Int32 par);
Comments:
Same mechanism apply if clarion function receives another integer presicion, then in C# we switch to corresponding type, see the type equivalency table.
1.5 Procedure whit *LONG input parameter
Clarion
EjemploClarion PROCEDURE(*LONG par), PASCAL, NAME(‘EJEMPLOCLARION’)
C#
[DllImport("clarion.dll", EntryPoint = "EJEMPLOCLARION", CharSet = CharSet.Ansi)] public static extern void EjemploClarion(ref Int32 par);
Comments:
Same mechanism apply if clarion function receives another integer presicion, then in C# we switch to corresponding type, see the type equivalency table.
1.6 Procedure whit STRING input parameter
STRING clarion data type is propietary, doesn’t exists in other languages with this implementation, to work around this issue we use memory addresses in this way:
Clarion
EjemploClarion PROCEDURE(LONG val), PASCAL, NAME(‘EJEMPLOCLARION’) ParVal CSTRING(255) CODE
!El string enviado se guarda en la variable ParVal PEEK(val, ParVal)
!Codigo del procedimiento
C#
[DllImport("clarion.dll", EntryPoint = "EJEMPLOCLARION", CharSet = CharSet.Ansi)] public static extern void EjemploClarion(String val);
1.7 Procedure whit *STRING or *CSTRING input parameter
STRING clarion data type is propietary, doesn’t exists in other languages with this implementation, to work around this issue we use memory addresses in this way:
Clarion
EjemploClarion PROCEDURE(LONG val), PASCAL, NAME(‘EJEMPLOCLARION’) ParVal CSTRING(255) CODE
!El string enviado se guarda en la variable ParVal PEEK(val, ParVal)
!Codigo del procedimiento
!El string enviado se pisa con la variable ParVal POKE(val, ParVal)
C#
[DllImport("clarion.dll", EntryPoint = "EJEMPLOCLARION", CharSet = CharSet.Ansi)] public static extern void EjemploClarion(StringBuilder val);
1.8 Procedure whit DATE input parameter
DATE clarion data type is propietary, doesn’t exists in other languages with this implementation, to work around this issue we use memory addresses for pass a STRING representing the DateTime
Use the class System.Globalization.DateTimeFormatInfo to transform a System.DateTime in an String and DateTime.Parse to do the reverse operation.
1. References
http://msdn2.microsoft.com/en-us/library/ms172270(VS.80).aspx http://msdn2.microsoft.com/en-us/library/26thfadc(VS.80).aspx http://msdn2.microsoft.com/en-us/library/04fy9ya1(VS.80).aspx
1.9 Type Equivalency Table
Descripción Tipo Clarion Tipo C# 32bits Integer whit sign LONG Int32 32bits Integer whitout sign ULONG Uint32 16bits Integer whit sign SHORT Int16 16bits Integer whitout sign USHORT Uint16 8bits Integer whitout sign BYTE Byte
Addendum 1
ClarionProc(*cstring), long, pascal
Would be in c# :-
[DllImport("clarion.dll", CharSet = CharSet.Ansi)] private static extern int ClarionProc(int sizeCString, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder strCString);
You pass the hidden string size as the first parameter.
Addendum 2
Clarion
EjemploClarion PROCEDURE(*CSTRING val), PASCAL, NAME(‘EJEMPLOCLARION’)
C#
[DllImport("clarion.dll", EntryPoint = "EJEMPLOCLARION", CharSet = CharSet.Ansi)] public static extern void EjemploClarion(Int32 valLength, StringBuilder val);
Comments:
Call like this
StringBuilder str = new StringBuilder(255); str.Append("aca va un texto"); SomeClass.EjemploClarion(str.Length, str);
Regards
Shankar
|
|
|
|
|
Report
|
|
|
|
04-14-2008, 9:14 PM
|
Anand
Joined on 04-14-2008
Posts 8
|
Re: How to call clarion dll into a .NET environment
|
|
|
|
|
|
Hello Shankar,
Thanks a lot once again for your response.
Actually I tried this (what you have provided).. but am getting exceptions raised from .NET while calling the Procedure.
The Expections i am getting are :-
(1) Entry Point Not Found Exceptions -
System.EntryPointNotFoundException was unhandled Message="Unable to find an entry point named 'temp' in DLL 'OK.dll'." Source="WindowsApplication3" TypeName="" StackTrace: at WindowsApplication3.Form1.temp() at WindowsApplication3.Form1.button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\avyas\My Documents\Visual Studio 2005\Projects\WindowsApplication3\WindowsApplication3\Form1.cs:line 42 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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at WindowsApplication3.Program.Main() in C:\Documents and Settings\avyas\My Documents\Visual Studio 2005\Projects\WindowsApplication3\WindowsApplication3\Program.cs:line 17 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
Can anyone please help me on this.
I have checked the same in other forums but the solution of replacing the "msvcr71.DLL" has not worked.
|
|
|
|
|
Report
|
|
|
|
04-14-2008, 9:16 PM
|
Anand
Joined on 04-14-2008
Posts 8
|
Re: How to call clarion dll into a .NET environment
|
|
|
|
|
|
Hello Tony,
I tried checking the details provided but could not find the same.
Please check my response to Shankar for further details on the issue.
Thanks in advance.
|
|
|
|
|
Report
|
|
|
|
04-15-2008, 5:11 AM
|
Anand
Joined on 04-14-2008
Posts 8
|
Re: How to call clarion dll into a .NET environment
|
|
|
|
|
|
Hello Guys,
After a lot of head banging have solved the exception by checking all the dependencies.
Now i am getting the following error :-
'WindowsApplication3.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WindowsApplication3.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WindowsApplication3.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WindowsApplication3.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WindowsApplication3.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WindowsApplication3.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WindowsApplication3.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\avyas\My Documents\Visual Studio 2005\Projects\WindowsApplication3\WindowsApplication3\bin\Release\WindowsApplication3.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WindowsApplication3.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WindowsApplication3.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Deployment\2.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WindowsApplication3.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0xd34 has exited with code 0 (0x0).
The thread 0x16cc has exited with code 0 (0x0).
The thread 0x16a0 has exited with code 0 (0x0).
'WindowsApplication3.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\avyas\My Documents\Visual Studio 2005\Projects\WindowsApplication3\WindowsApplication3\bin\Release\WindowsApplication3.exe', Symbols loaded.
The program '[5880] WindowsApplication3.vshost.exe: Managed' has exited with code 1 (0x1).
Guys i would be really greatful if anybody could help me solving this.
Also just for FYI the application exits as soon as the DLL procedure is called.
Any help on this would be precious on my part...!!!
Thanks in Advance..
|
|
|
|
|
Report
|
|
|
|
04-15-2008, 6:04 AM
|
Tony Tetley

Joined on 10-25-2005
Missouri, USA
Posts 80
|
Re: How to call clarion dll into a .NET environment
|
|
|
|
|
Here is a link to the first of the multi-part articles on Clarion Mag:
http://www.clarionmag.com/cmag/v7/v7n08dotnetinterop1.html
Subscription is required, but it will be the best money you ever spent.
Tony
|
|
|
|
|
Report
|
|
|
|
|
|