Windows Help?

By Norm Tovey-Walsh on November 03, 2025 at 05:45p.m.

I’m asking for help, but first, a little background. Saxon 10.x is the last Saxon release that supported Microsoft .NET Framework. The Saxon 11 and 12 releases only run on .NET Core. But we still have customers with applications that need .NET Framework and Microsoft continues to support it on Windows.

We’d like to be able to provide a .NET Framework version of SaxonCS built from the current sources. In principle, this should be possible because we build SaxonCS by transpiling Java source code to C# source code (mixed in with some hand-written C#).

I undertook to see if I could make that work. I took a SaxonCS 12.x build and attempted to compile it with .NET Framework. I worked back and forth on the transpiler and on the generated C# code until I got something that compiled.

But a simple identity transformation fails with an AccessViolationException:


C:\tmp>.\SaxonCS transform -s:\tmp\identity.xsl -xsl:\tmp\identity.xsl
file:/C:/tmp/identity.xsl
Processing item <xsl:stylesheet/> ::
Processing item @exclude-result-prefixes ::
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Saxon.Hej.trans.rules.ShallowCopyRuleSet.process(...) in ...generated\Saxon\Hej\trans\rules\ShallowCopyRuleSet.cs:line 93
   at Saxon.Hej.trans.Mode.applyTemplates(...) in ...generated\Saxon\Hej\trans\Mode.cs:line 186
   at Saxon.Hej.trans.rules.ShallowCopyRuleSet.process(...) in ...generated\Saxon\Hej\trans\rules\ShallowCopyRuleSet.cs:line 58
   at Saxon.Hej.trans.Mode.applyTemplates(...) in ...generated\Saxon\Hej\trans\Mode.cs:line 186
   at Saxon.Hej.expr.instruct.ApplyTemplates.ApplyTemplatesPackage.processLeavingTail() in ...generated\Saxon\Hej\expr\instruct\ApplyTemplates.cs:line 243
   at Saxon.Hej.trans.Mode.applyTemplates(...) in ...generated\Saxon\Hej\trans\Mode.cs:line 153
   at Saxon.Hej.trans.XsltController.applyTemplates(...) in ...generated\Saxon\Hej\trans\XsltController.cs:line 206
   at Saxon.Hej.s9api.Xslt30Transformer.applyTemplates(...) in ...generated\Saxon\Hej\s9api\Xslt30Transformer.cs:line 76
   at Saxon.Hej.Transform.processFile(...) in ...generated\Saxon\Hej\Transform.cs:line 805
   at Saxon.Hej.Transform.doTransform(...) in ...generated\Saxon\Hej\Transform.cs:line 547
Fatal error during transformation: AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Exiting with code 2

No amount of effort on my part has enabled me to find out where that problem occurs, or why. In the debugger, it’s on a perfectly harmless looking statement and taking one step forward immediately crashes the process. We got a Windows consultant (he’s helping us with some performance analysis, but he knows a lot more about Windows than I do) to take a look.

Thing is, it works on his machine. My build works on his machine, his build fails on my machine. And those builds fail on some other machines too.

I expressed some frustration (*cough*) at a team meeting and threatened to just pull the plug on the whole thing. But, we seem to be so close…

Mike said, “why don’t we ask the internet”. So that’s what I’m doing. If you’re a Windows developer, you can get the entirely janky SaxonCS-net481-12-99-99.zip build and run it through your favorite debugging tools. If you can show me what I’ve done wrong, I would be ever so grateful. (To the tune of a free individual license, if you like.)

A few points about the build:

The failure isn’t related to the version of Windows (at least not the major version number). We aren’t able to see any obvious differences in the SDKs installed or the build tools used between machines where it succeeds and where it fails.

Can you:

  1. Explain why it succeeds on some machines and fails on others?
  2. Tell me what to change so that it will always succeed?

Clues most humbly solicited, if it’s the sort of puzzle that interests you. I recognize that not being able to provide the source code and build environment is a serious limitation.

If it helps, here are the build commands I used:

dotnet restore SaxonCS.sln --verbosity Normal -p:Configuration=Release -p:Platform="Any CPU"
dotnet build SaxonCS.sln --verbosity Normal /nodereuse:false --no-restore \
       -p:Version=12.99.99 -p:PackageVersion=12.99.99 -p:Configuration=Release \
       -p:Platform="Any CPU" -p:DefineConstants=EE
dotnet publish SaxonCS.sln -r win-x64 --self-contained true -p:PublishSingleFile=false \
       -p:Version=12.99.99 -p:PackageVersion=12.99.99 -p:Configuration=Release \
       -p:Platform="Any CPU"

🤞