Beyond
As already hinted this workspace only covers a fraction of what DevIL has to offer. More cover functions can easily be built for the facilities that are not already "covered". It should not present great difficulty to find the desired API function call in the mentioned lib\include\IL\il.h file, and once the structure of its arguments and result has been established a suitable ⎕NA call can be built. The ones provided in the #.DevIL.New function should provide all information required to perform this task.
Interesting aspects to explore could be DevIL’s capabilities of e.g. keeping several images in the same instance or the interface to OpenGL.
Heading on
Though the framework presented here is limited in scope there are a number of uncertainties and missing answers, which would require a more thorough examination of the C source code. One such is e.g. if generation of GIF image files is indeed supported or not. The DLL itself refuses to save GIF files whereas the project front page at SourceForge seems to imply that the required code is actually present. Judging from messages in one of the forums it’s the expiry of the Unisys patent that has not been fully adopted.
Another very interesting aspect about DevIL is its WinCE/PocketPC distribution, which would allow for its use even with Dyalog on a PocketPC. At least there used to be one such distribution but I have not investigated if it is even generatable anymore.
Building C# COM DLLs for APL
by Ajay Askoolum (ajayaskoolum@ntlworld.com)
Introduction
In this article, I present a visual guide to building and deploying a C# COM (Component Object Model) Interrop DLL (Dynamic Link Library) for APL using Visual C# 2005 Express Edition. This is not a tutorial on either C# or on Visual C# 2005 Express Edition, but simply an illustration of the process for building COM DLLs in C#.
For a limited period and subject to conditions, Visual C# 2005 Express Edition is available as a free-download, together with installation instructions [1].
The continuing evolution of the .Net platform has spawned a lot of documentation on the internet which appears to be misleading, at least from an APL point of view; a contributing factor in this confusion is that the documentation applies to several versions of the .Net framework and Visual Studio.net. This article redresses the situation by providing a template for building COM DLLs for APL. The actual code in the DLL is of a trivial nature and intended solely to illustrate how to build it.
A COM DLL is a server to a client; in the present context, the client is APL. The COM server exposes methods, properties, and events that the client can use irrespective of the native language of the DLL. In order to deploy such a DLL, the target computer must have the .Net Framework 2.0 installed; this is available as a free download [2]. Visual Studio.Net 2005 uses the same framework and although the interface presented by the Express and full versions are different, it is possible to use Visual Studio 2005 instead of the Express edition. This article is based on the Express edition.
File|New Project
Start the Express edition and click File|New Project. Figure 1 shows the dialogue that appears.
Figure 1. Selecting the type of project
S
Figure 2. Naming the class
elect the Class Library template and specify the name as QuoteQuad, as shown above. This ensures that QuoteQuad is the name of the DLL. By default, the class library is not configured for COM usage.
I
Figure 3. Properties
n order to modify the properties of the DLL to enable it for COM, click View|Properties Window and then select Class1.cs; the objective is to change the class name. Figure 2 shows the class name after class1.cs has been renamed Demo.cs.
Clients will instantiate the DLL by using the Library.Classname convention; in this context, the reference is QuoteQuad.Demo.
Setting COM properties
Next, click Project|Quote Quad Properties; this step is shown in Figure 3.
Next, Figure 4 shows the screen that becomes visible.
Figure 4. Specifying COM properties
Click Assembly Information in order to display the dialogue shown in Figure 5.
Figure 5. COM visibility
Tick the Make assembly COM-Visible the option.
Next, click Build in the left pane and specify the output path and tick Register for COM interop as shown in Figure 6.
Figure 6. COM Registration
Save the project
Click File|Save All in order to save the project. The dialogue shown in Figure 7 appears:
Figure 7. Location of DLL
For Location specify the fully qualified name of the location and then click Save to save all the files for the project. Note the option to Create directory for solution.
Compiling the DLL
The DLL is ready for compilation. Click Build|Build Solution or press F6. However, the DLL does not have any methods, properties, or events to expose; therefore, there is little point in creating the DLL at this stage.
Contents of the assembly
The first file, Assembly.cs, is ready and contains the following information:
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("QuoteQuad")]
[assembly: AssemblyDescription("C# COM Interrop DLL: Step-by-step guide")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Ajay Askoolum")]
[assembly: AssemblyProduct("QuoteQuad")]
[assembly: AssemblyCopyright("Copyright © 2006")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("49a5c035-e8c5-46b0-8317-499b7bc5e511")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Note that the code in this file is auto-generated from the configurations set using the graphical user interface dialogues.
Share with your friends: |