Project

Profile

Help

System.Reflection.TargetInvocationException when trying to run SaxonCS 11.1 on Windows from command line

Added by Martin Honnen about 2 years ago

I have just received my Saxon license but while SaxonCS 11.0 works well from the command line (with that license or my old Saxon-EE license) SaxonCS 11.1 refuses to start and throws a System.Reflection.TargetInvocationException

PS C:\Users\Martin Honnen\OneDrive\Documents\xslt> & 'C:\Program Files\Saxonica\SaxonCS-11.1\SaxonCS.exe' query -t -qs:"current-dateTime()"
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentException: The path is empty. (Parameter 'path')
   at System.IO.Path.GetFullPath(String path)
   at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
   at Org.XmlResolver.XmlResolverConfiguration..ctor(List`1 propertyFiles, List`1 catalogFiles)
   at Saxon.Callbacks.CatalogResourceResolver..ctor()
   at Saxon.Hej.Configuration.init()
   at Saxon.Hej.Configuration..ctor()
   at Saxon.Eej.config.ProfessionalConfiguration..ctor()
   at Saxon.Eej.config.EnterpriseConfiguration..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
   at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean   at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type)
   at Saxon.Hej.Configuration.newConfiguration()
Unhandled exception. System.Exception: Cannot instantiate a Configuration
 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentException: The path is empty. (Parameter 'path')
   at System.IO.Path.GetFullPath(String path)
   at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
   at Org.XmlResolver.XmlResolverConfiguration..ctor(List`1 propertyFiles, List`1 catalogFiles)
   at Saxon.Callbacks.CatalogResourceResolver..ctor()
   at Saxon.Hej.Configuration.init()
   at Saxon.Hej.Configuration..ctor()
   at Saxon.Eej.config.ProfessionalConfiguration..ctor()
   at Saxon.Eej.config.EnterpriseConfiguration..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
   at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type)
   at Saxon.Hej.Configuration.newConfiguration()
   --- End of inner exception stack trace ---
   at Saxon.Hej.Configuration.newConfiguration()
   at Saxon.Hej.Query.doQuery(String[] args, String command)
   at Saxon.Hej.Query.main(String[] args)
   at Saxon.Cmd.Command.Main(String[] args)

Same for

PS C:\Users\Martin Honnen\OneDrive\Documents\xslt> & 'C:\Program Files\Saxonica\SaxonCS-11.1\SaxonCS.exe' transform -t -xsl:.\processorTest3.xml -s:.\processorTest3.xml
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentException: The path is empty. (Parameter 'path')
   at System.IO.Path.GetFullPath(String path)
...

Am I doing anything wrong, i.e. has anything changed between the command line call and 11.0 and 11.1? Or just a Windows issue that testing didn't catch?


Replies (5)

Please register to reply

RE: System.Reflection.TargetInvocationException when trying to run SaxonCS 11.1 on Windows from command line - Added by Michael Kay about 2 years ago

It's clearly related to the introduction of the XML resolver (Org.XmlResolver) but beyond that I can't tell without getting onto a Windows machine. Diagnosing things that happen with the built executable when they work in the development environment is always tough, especially when OS-specific, and we only run a subset of tests on the built executables.

It's probably related to https://saxonica.plan.io/issues/5269 - I found a few issues there with resolving relative file names on the command line, and of course filename handling is always a bit different on Windows.

RE: System.Reflection.TargetInvocationException when trying to run SaxonCS 11.1 on Windows from command line - Added by Martin Honnen about 2 years ago

I also tried now under Ubuntu Linux 20.04 (admittedly only in the Window Linux subsystem) but I get a similar stack trace there:

mh@liberty-main-hp:~$ /opt/SaxonCS-11.1/SaxonCS query -t -qs:'current-dateTime()'
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentException: The path is empty. (Parameter 'path')
   at System.IO.Path.GetFullPath(String path)
   at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
   at Org.XmlResolver.XmlResolverConfiguration..ctor(List`1 propertyFiles, List`1 catalogFiles)
   at Saxon.Callbacks.CatalogResourceResolver..ctor()
   at Saxon.Hej.Configuration.init()
   at Saxon.Hej.Configuration..ctor()
   at Saxon.Eej.config.ProfessionalConfiguration..ctor()
   at Saxon.Eej.config.EnterpriseConfiguration..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
   at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type)
   at Saxon.Hej.Configuration.newConfiguration()
Unhandled exception. System.Exception: Cannot instantiate a Configuration
 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentException: The path is empty. (Parameter 'path')
   at System.IO.Path.GetFullPath(String path)
   at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
   at Org.XmlResolver.XmlResolverConfiguration..ctor(List`1 propertyFiles, List`1 catalogFiles)
   at Saxon.Callbacks.CatalogResourceResolver..ctor()
   at Saxon.Hej.Configuration.init()
   at Saxon.Hej.Configuration..ctor()
   at Saxon.Eej.config.ProfessionalConfiguration..ctor()
   at Saxon.Eej.config.EnterpriseConfiguration..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
   at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type)
   at Saxon.Hej.Configuration.newConfiguration()
   --- End of inner exception stack trace ---
   at Saxon.Hej.Configuration.newConfiguration()
   at Saxon.Hej.Query.doQuery(String[] args, String command)
   at Saxon.Hej.Query.main(String[] args)
   at Saxon.Cmd.Command.Main(String[] args)
Aborted

Is that a license issue? https://www.saxonica.com/html/documentation11/about/license/checklicense.html says "SaxonCS will fail and exit if no license file is found." without detailing which error/exit message you should get

For it's worth, I installed the license under both Windows and Linux in the SaxonCS 11.1 installation directory (i.e. in my case C:\Program Files\Saxonica\SaxonCS-11.1 on Windows and /opt/SaxonCS-11.1 for Ubuntu) and set up an environment variable (e.g. export SAXON_LICENSE_DIR=/opt/SaxonCS-11.1 for Ubuntu which printenv then shows as set).

So far I haven't tried to run my own .NET code with SaxonCS 11.1 under Ubuntu but under Windows they work fine so in the case of my own .NET code the license is found.

RE: System.Reflection.TargetInvocationException when trying to run SaxonCS 11.1 on Windows from command line - Added by Martin Honnen about 2 years ago

I have now tried to run the SaxonCS 11.1 command line tool on MacOS and there it works (but it is rather ridiculous and insane to have to allow all those libraries with explicit permissions step by step).

While investigating the zip files to be downloaded for Windows and Linux compared to the one for MacOS, I notice that the one for MacOS, like the previous 11.0.1 for Windows, contains lots of separate dll files, meanwhile for SaxonCS 11.1.1 and Linux there is a huge SaxonCS file in the zip with only a few dlls.

On Windows, I find only clrcompression.dll, clrjit.dll,coreclr.dll, mscordaccore.dll, SaxonCS.exe, SaxonCS.pdb, and SaxonCS.xml.

On the Mac, there are dozens of dll files.

Is the zip for Windows correctly built?

Is anyone able to run SaxonCS 11.1 for Windows or Linux off that installation from the downloadable zip?

RE: System.Reflection.TargetInvocationException when trying to run SaxonCS 11.1 on Windows from command line - Added by Martin Honnen about 2 years ago

Will this be looked at once you have resolved other bugs? Or it is better to raise this as a bug issue to ensure it will not be overlooked?

RE: System.Reflection.TargetInvocationException when trying to run SaxonCS 11.1 on Windows from command line - Added by Michael Kay about 2 years ago

We're aware of it, but it is much harder to track issue status for forum posts than for bug issues, so it's certainly less likely to be overlooked if you move it. Thanks.

    (1-5/5)

    Please register to reply