Recently we had a client that wanted to upgrade their web application containing modules we had written for them a long time ago for DotNetNuke 4.3 and they hadn’t had any upgrades since. Fortunately the content on the site was fairly minimal so we decided just to set up a new instance of DNN 6 and move the content over. This means we had to take modules written for DotNetNuke 4.3 all the way to DotNetNuke 6.0. For the most part it really wasn’t too bad. There were some issues with ajax and script manager as DNN 4.3 pre-dated DNN’s inclusion of a scriptmanager automatically, but the biggest problem was ApacheFop.Net and J#.
The original developers of the modules used ApacheFop.Net for the PDF generation for all reports.
Step 0:
First I had to install the J# redistributable.
Step 1:
After doing that I moved over assembly entries from the 4.3 web config:
<assemblies>
<add assembly="vjscor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="vjslib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
</assemblies>
Step 2:
This got close. Now when trying to generate a report I got the following error:
Could not load file or assembly ‘vjscor, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies.
Okay, well, then let’s use a binding redirect in the assembly binding section of the runtime of the web.config. I’m not sure why it was trying to load 1.0.5000.0 when I told it to load 2.0.0.0, but we’ll correct that:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" >
<probing privatePath="bin;binHttpModules;binProviders;binModules;binSupport;"/>
<dependentAssembly>
<assemblyIdentity name="vjslib" publicKeyToken="b03f5f7f11d50a3a"/>
<bindingRedirect oldVersion="1.0.0.0-1.0.5000.0" newVersion="2.0.0.0"/ >
</dependentAssembly >
<dependentAssembly >
<assemblyIdentity name="vjsnativ" publicKeyToken="b03f5f7f11d50a3a"/>
<bindingRedirect oldVersion="1.0.0.0-1.0.5000.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="vjscor" publicKeyToken="b03f5f7f11d50a3a"/>
<bindingRedirect oldVersion="1.0.0.0-1.0.5000.0" newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Step 3:
One step closer. Now I get the error:
A critical error has occurred.The type initializer for ‘java.lang.System’ threw an exception.
Well, at least it looks like it’s trying to load the J# libraries.
Finally after much googling around I finally hit upon the last step in the enigma at
http://blogs.windwardreports.com/davidt/2011/02/calling-j-code-from-net-40.html
I added to my Default.aspx the external call for manually loading libraries:
//used for loading J# libraries
[DllImport("kernel32", SetLastError = true)]
static extern IntPtr LoadLibrary(string lpFileName);
and then to the OnInit I added:
//load needed J# libraries
if (Environment.Version.Major >= 4)
{
string folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), @"..Microsoft.NETFrameworkv2.0.50727");
folder = Path.GetFullPath(folder);
LoadLibrary(Path.Combine(folder, "vjsnativ.dll"));
LoadLibrary(Path.Combine(folder, "vjscor.dll"));
LoadLibrary(Path.Combine(folder, "vjslib.dll"));
}
I tried removing each step and the only step that you can do without is step one since we’re manually loading the libraries manually anyways. Oddly, even though I’m now manually loading the libraries, I still need to do step two. Oh well, this is what works for me but as always YMMV.
Thanks,
Brian