Project

Profile

Help

"The type initializer for 'net.sf.saxon.Configuration' threw an exception." in Visual Studio 2012

Added by Shaun Kohanowski over 11 years ago

I'm currently in the process of evaluating Xslt 2.0 processors. I've been using the ExamplesHE.cs code saxon-resources9-4.zip to test it out. I only get the error in VS 2012, not in VS 2010. However I'm using the same runtime from both IDEs, v4.0.30319, and the target framework doesn't seem to make a difference either. Specifically the error occurs when a new processor is created. (line 160 in the ExamplesHE.cs file) I've tried to add Saxon HE 9.4.0.6 using NuGet and manually from the setup package on the Saxonica site. I've also tried to use the older version packaged with the adapter written by Gavin Sinai at http://www.codeproject.com/Articles/24766/XSL-2-0-and-XQuery-1-0-in-NET to no avail.

Any ideas on how I can get this working in VS 2012 or am I out of luck?

These are the exception details:

System.TypeInitializationException was caught HResult=-2146233036 Message=The type initializer for 'net.sf.saxon.Configuration' threw an exception. Source=saxon9he TypeName=net.sf.saxon.Configuration StackTrace: at net.sf.saxon.Configuration.newConfiguration() at Saxon.Api.Processor..ctor() at SaxonHE.XPathSimple.run(Uri samplesDir) in d:\Development\saxontest\saxontest\saxontest\ExamplesHE.cs:line 230 at SaxonHE.ExamplesHE.Main(String[] argv) in d:\Development\saxontest\saxontest\saxontest\ExamplesHE.cs:line 160 InnerException: java.lang.RuntimeException HResult=-2146233088 Message=Failed to load configuration defined in edition.properties Source=saxon9he StackTrace: at net.sf.saxon.Configuration..cctor() InnerException: java.lang.ClassNotFoundException HResult=-2146233088 Message=net.sf.saxon.java.JavaPlatform Source=IKVM.Runtime StackTrace: at IKVM.NativeCode.java.lang.Class.forName0(String name, Boolean initialize, ClassLoader loader) at java.lang.Class.forName0(String , Boolean , ClassLoader ) at java.lang.Class.forName(String className, CallerID ) at net.sf.saxon.Configuration..cctor() InnerException:


Replies (5)

Please register to reply

RE: "The type initializer for 'net.sf.saxon.Configuration' threw an exception." in Visual Studio 2012 - Added by Michael Kay over 11 years ago

This looks horribly to me like a build problem of some kind, which would be surprising as 9.4.0.6 has been out for a couple of months now: but we did build it in a slightly different build environment from previous maintenance releases.

These two messages:

Message=Failed to load configuration defined in edition.properties ... Message=net.sf.saxon.java.JavaPlatform

make me suspect that the edition.properties file held inside the assembly is referencing net.sf.saxon.java.JavaPlatform when it should reference net.sf.saxon.dotnet.DotNetPlatform. But I can't see how it could ever work if that were the case.

We'll look into it.

RE: "The type initializer for 'net.sf.saxon.Configuration' threw an exception." in Visual Studio 2012 - Added by O'Neil Delpratt over 11 years ago

Hi Shaun,

Firstly thanks for reporting the error you have found. Unfortunately I have not been able to reproduce the error in Visual studio 2012. So it seems you may have some setup which may be somewhat different. Maybe you can provide some detail of your environment or any previous Saxon versions you may of installed on your machine.

Further to the above I did some more investigation by disassembling the saxonhe.dll using the ISDASM tool in .Net. I did find through the disassembler relevant CIL to DotNetplatform, but did not find any reference to the edition.properties in the Manifest. Strangely enough in the previous Saxon 9.3HE I found a reference to edition.properties in it's Manifest. It is not enough to go on this, but it leads me to think that the later release of IKVM (i.e. ikvm-0.46.0.2) may be doing something different in Saxon 9.4; specifically to the resources file.

RE: "The type initializer for 'net.sf.saxon.Configuration' threw an exception." in Visual Studio 2012 - Added by Shaun Kohanowski over 11 years ago

Excellent followup! It's very nice to log in in the morning and be met with an enthusiastic reply.

I'm running Windows 7 Ultimate SP1 on an Intel Core2 Quad Q6600 w/ 8GB.

My primary IDE is Visual Studio Professional 2012 v11.051106.01 Update 1. The .Net Framework is v4.5.50709. I first tried the adapter written by Gavin Sinai above. Then I downloaded and installed Saxon9HE 9.4.0.6 from your site. Then I looked in NuGet and added Saxon from there. The first time around with Saxon from NuGet I was thinking I needed the IKVM package too so I added the IKVM.Net v7.2.4630.5. After I was able to get it working in VS 2010 I came back to 2012 and tried it without the IKVM package but it still doesn't work.

My secondary IDE is Visual Studio Professional 2010v10.0.40219.1 SP1Rel. The .Net Framework is v4.5.50709 SP1Rel. The Sample code worked first time on this environment downloading only the Saxon9He package from NuGet.

I have IT spinning up a VM to test a clean install of VS on. I'll let you know how that goes. Thanks for the help guys.

RE: "The type initializer for 'net.sf.saxon.Configuration' threw an exception." in Visual Studio 2012 - Added by O'Neil Delpratt over 11 years ago

Saxon .NET is built with the IKVM.NET v0.46.0.2 and is included in the Saxon installer. There is a possibility IKVM.NET v7.2.4630.5 is the culprit. Try removing it from your machine if not required. You should also remove it from the gac just to make sure.

Let us know how you get along.

RE: "The type initializer for 'net.sf.saxon.Configuration' threw an exception." in Visual Studio 2012 - Added by Shaun Kohanowski over 11 years ago

I tried running the project on the new VM and it failed. I then created a new project added Saxon from NuGet and added the ExamplesHE.cs file and it worked. Then I read your reply and that got me thinking about app.config and, sure enough, IKVM added several redirects to the app.config to point to the new libraries. I cut them out and everything runs great.

Thanks for the help guys. I'm excited to test integrate it into this project. Regards, Shaun

    (1-5/5)

    Please register to reply