Something about LibMaker I forgot to mention.
The libmaker source that ships with Clarion has a couple of problems with “Unmanaged Exports” DLLs. It only works with short filenames and it prefixes the labels with a “\”. These can be easily fixed in the source of LibMaker but I have created a compiled fixed version that should do the job.
Alternatively use the LoadLibrary API to dynamically load the DLL http://www.clarionmag.com/search/find?searchTerm=author%3Asand+loadlib  (sub required).

What?

ClarionMag article –Mixing Clarion with .NET, Part 1

“To call any .NET procedure from Clarion, you have a few choices. You can expose any .NET class to COM, which makes it visible to any COM client. Once you’ve done that, you can either use Clarion’s OLE control or write some Clarion wrapper classes.” “You can also make a Managed C++ wrapper, which is stored inside your .NET assembly. You then call this wrapper the same way you would call an API function.”

Robert Giesecke – C# Project Template for Unmanaged ExportsVisual Studio C# Project Template to “export managed code to native applications without the need of COM registrations”

And finally, a similar technique using Clarion# – http://clarionsharp.com/blog/2011/05/clarion-net-update-2/

Why?

Using .net allows you to tap into the vast amount of examples and libraries available in the .net world to help you create solutions. There is significantly less need to try and take a C++ or C# example and translate it to clarion code and API calls when you can just wrap up the functionality you need in .net and call it from clarion.

Unless you need to embed .net user controls in a clarion window I cannot see any reason not to use the DLLExport technique. It has the advantage that you don’t need to register the .net assembly using regasm.exe and is likely much faster to execute.

Color picker example

This example uses the Zeta Color Editor from an article on The Code Project website. The same editor is used in my InsertClarionColor addin.

ColorPicker.zip – Clarion 8 and Visual studio C# solutions. (one day I will move it to GitHub!)

  1. Create a C# project using the Unmanaged Exports template in visual studio
  2. Export a method that can be called by clarion which handles the calling of the editor dialog
  3. Create a clarion friendly lib file from the .net dll
  4. Create a clarion project to use the dll!

I had been using the C# Project Template for Unmanaged Exports quite a lot and while upgrading a project to VS 2012 I noticed that it is now available as a nuget package. There is only one catch… make sure your project has a specific CPU target set. It took me a little while to work that one out, otherwise the nuget package works perfectly. Go get it and start integrating .NET with your Clarion projects now!! Smile

This is a topic that comes up on the newsgroups from time to time. A while back, more than 6 years back IIRC, I spent some time researching and testing the different scenarios for a project I was involved in. I will attempt to summarise the finding here with a few additional comments picked up in NG threads along the way.

Update 21 Sept 2012: I have just tested with Clarion 8.0.9304 and it looks like it uses the new Native Client just fine. This is what is shown in the trace log:

Some terms:

Clarion MSSQL Accelerator driver – C60MSS.DLL or more recently, ClaMSS.dll  \

ODBC SQL Server Driver – This is what Trace.exe reports when you have no SQL Native Client installed. There is likely a more technical explanation for the name but it doesn’t really matter. This is what Clarion will do when there is not other choice. The default…

SQL Native Client – “…contains the SQL Server ODBC driver and the SQL Server OLE DB provider in one native dynamic link library (DLL) supporting applications using native-code APIs (ODBC, OLE DB and ADO) to Microsoft SQL Server.” – source

I have not personally taken any serious benchmarks of using the ODBC driver or the Native client. My general impression is that it seems you get a faster experience with the Native Client and others have reported significant differences, especially when connecting to a remote server. Also, if you want your application to use MARS support introduced in Clarion6 (6.3 I think) then you must have the Native Client installed or you will likely see BUSYHANDLING errors very soon.

Getting it right

For an application compiled with Clarion6 you must

How to Enable Code Snippets

Add .appclw and .APPCLW (no “*” in front of it) to the list in the Code Snippets setup. This tells the IDE to show snippets in the code completion list for the embed editor and the embeditor.

In my IDE I have this set of extensions for Clarion snippets:

How to Enable Code Snippets

Using Code Snippets

If you are getting a lot of \bin\*.xlog files you might want to try the following.

Note: If you are curious you can use my free IdeDebug addin to view the contents of the xlog files before you delete them. For my own personal curiosity, let me know if you are seeing anything other than what is mentioned here.

 

The most common one is this:

SoftVelocity.TextTransform has not been loaded because it requires
SoftVelocity.GeneratorX.

To stop it, delete or rename this file: