Thank you @Brandon , it really helped.
I would add that you need to copy both DLLs (TestDnneCNE.dll and TestDnneC.dll) to Clarion directory, an must have TestDnneC.runtimeconfig.json with:
I would advice you to switch to NativeAoT now it supports 32-bit in Dotnet 9 - as youāll only need the single DLL, you donāt need the runtimeconfig.json anymore
@uriah18 - if you need help, you may PM/DM me - Iāve been doing this for some time and may be able to help you - I recently got it working so I can even pass a GROUP from Clarion to DotNet
@ThaDaSoft
Hi! Iām new to Clarion and want to create a DLL for Clarion using .NET 9. What do I have to do? Can you help me and show an example? Thanks!
Thank you. I did it like you said, using .net9, which is now out of RC. So far everything looks good. I had to jump on another project in the meantime and now Iām back on this. @fabian488 if you need help, ask.
I had a play around yesterday and managed to get it working. I found that I needed to modify my Visual Studio 2022 installation to include the Desktop Development with C++ tools because the Win32 AOT compilation wouldnāt work without them.
Once I installed those tools, I got everything running smoothly.
If youāre using the command line to publish, the PlatformTarget and RuntimeIdentifier arenāt strictly necessary, as the -r option specifies the runtime. However, I left them in so I could publish directly from the IDE.
For publishing via the command line, even if PublishAot isnāt set in the project file, you can still use:
Note: For anyone reading along, this process compiles the runtime components of .NET 8/9 directly into the output, which can make the generated DLL somewhat large. For example, I created a simple DLL with two methods to expose C# regex functionality, and the compiled DLL came out at 1.55 MB.
Edit: Clarification added ā AOT Win32 is only supported in .NET 9 and up. (Edited on 24th Dec 2024)
This was done in .NET 9, which apparently has better trimming to reduce output size.
x86 compilation is only available since DotNet 9 - so itās a requirement when used with Clarion.
I myself donāt use Visual Studio anymore - instead I use Visual Studio Code with the new DotNet extension.
Also, you havenāt set that it trims the output in the project, best is to add:
<PublishTrimmed>true</PublishTrimmed>
To be more precise, I have a Directory.Build.props, which I add by default to each Clarion library I write so itās setup how I want it - NOTE, this also changes where the output is written to so it is easier to use scripts to deploy it, it also sets up some defaults for Source generator as I am working on a Clarion Code generation based on the XML docs file:
<Project>
<PropertyGroup>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ArtifactsPath>$(MSBuildThisFileDirectory)\Out</ArtifactsPath>
<CompilerGeneratedFilesOutputPath>$(MSBuildThisFileDirectory)\Out\.generated</CompilerGeneratedFilesOutputPath>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ImplicitUsings>enable</ImplicitUsings>
<JsonSerializerIsReflectionEnabledByDefault>false</JsonSerializerIsReflectionEnabledByDefault>
<LangVersion>preview</LangVersion>
<!-- Disable warning CS1591: Missing XML comment for publicly visible type or member -->
<NoWarn>1591</NoWarn>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<PublishTrimmed>true</PublishTrimmed>
<RootNamespace>{ROOTNAMESPACE}</RootNamespace>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<TargetFramework>net9.0-windows</TargetFramework>
<TrimMode>link</TrimMode>
<UseArtifactsOutput>True</UseArtifactsOutput>
</PropertyGroup>
</Project>
Everything mentioned here, doesnāt need to be mentioned inside your .csproj file - it sort of works a default for the project by sln file, so each csproj referenced by the sln inherits these defaults (and the paths are based on the sln)