.Net 4.0 Assemblies

User fd07dcb633

25-02-2015 03:41:52

Hello,


Given that the .Net 4.0 Framework is now 5 years old and that newer versions of Visual Studio are prohibiting the use of .NET 2.0/3.5 in some applications (e.g. VSTO projects), is there any plan to release .net 4.0 assembly files for the JChem/Chemaxon .dlls?


Best Regards,


--Josh

ChemAxon bd13b5bd77

25-02-2015 08:08:48

Hi Josh,


you can use these assemblies from 4.0 or 4.5 frameworks, it will work. Possibly you think of ChemAxon.NET.XX assemblies.


We have couple of consultancy projects that work with 4.5 framework and JChem for Word, PowerPoint, Outlook rely on VSTO technology.


 


The key point here is the IKVM upgrade porting JDK libraries from 1.6 to higher, we perceived recently some compatibility issues of JDBC drivers and new MS SQL server. Not prooved yet through hwoever the assumption is that the IKVm upgrade will solve it. So we are on upgrading in weeks time.


You can simply go ahead with 4, 4.5 framework as is now.


Viktor

User fd07dcb633

25-02-2015 14:35:03

Thanks for the response Victor. I used to use Visual Studio 2010 to generate VSTO add-ins under .NET 3.5 and the ChemAxon.NET.X assemblies all worked fine. However, I have now been switched to Visual Studio 2013 Community -- which only generates VSTO add-ins using the 4.0 framework and things no longer work (same code). I ran this by a .NET guy and he mentioned that the most likely cause was that the ChemAxon.NET assemblies use the CLR 2.0 runtime and are not compatible with the VSTO4.0 runtime.


The problem is that none of the ChemAxon.NET.X assemblies can't be loaded without throwing a BadImageFormat Exception. These exceptions, as I understand are thrown when the format of the dll isn't compatible -- either a 64 vs 32 bit conflict or a .Net Framework conflict.


If you have some time, can you try to reproduce this issue?



  1. In Visual Studio 2013 community create a new Excel 2010 add-in (visual basic)

  2. VS auto-generates a vb file with the startup and shutdown methods

  3. paste the following code into the startup method (this is just dummy code to get the runtime to try to load a ChemAxon.NET.X dll)


        Using molData As New ChemAxon.NET.Base.Chemistry.Data.MoleculeData("c1ccccc1", ChemAxon.NET.Base.Chemistry.Formats.MoleculeFormat.SMILES)
            Dim molecule As JChemMolecule = New JChemMolecule(molData)
        End Using


  1. add this import statement to the top of the file "Imports ChemAxon.NET.IKVM.Chemistry"

  2. add references to ChemAxon.NET.Base and ChemAxon.NET.IKVM (15.2.1600.2347) assemblies

  3. Build the project and run.

  4. Upon execution of the Startup method a BadImageFormat exception is thrown when the ChemAxon.Net.Base assembly is loaded.


  • System.BadImageFormatException was unhandled
  •   FileName=ChemAxon.NET.Base, Version=15.2.1600.2347, Culture=neutral, PublicKeyToken=d25ce09139c726a9
  •   FusionLog=""
  •   HResult=-2146234076
  •   Message=Could not load file or assembly 'ChemAxon.NET.Base, Version=15.2.1600.2347, Culture=neutral, PublicKeyToken=d25ce09139c726a9' or one of its dependencies. Index not found. (Exception from HRESULT: 0x80131124)
  •   Source=ExcelAddIn2
  •   StackTrace:
  •        at ExcelAddIn2.ThisAddIn.ThisAddIn_Startup()
  •        at ExcelAddIn2.ThisAddIn._Lambda$__2(Object a0, EventArgs a1) in c:\users\jhoran\documents\visual studio 2013\Projects\ExcelAddIn2\ExcelAddIn2\ThisAddIn.Designer.vb:line 0
  •        at Microsoft.Office.Tools.AddInImpl.OnStartup()
  •        at Microsoft.Office.Tools.AddInImpl.AddInExtensionImpl.Microsoft.Office.Tools.EntryPoint.OnStartup()
  •        at Microsoft.Office.Tools.AddInBase.OnStartup()
  •        at ExcelAddIn2.ThisAddIn.FinishInitialization() in c:\users\jhoran\documents\visual studio 2013\Projects\ExcelAddIn2\ExcelAddIn2\ThisAddIn.Designer.vb:line 57
  •        at Microsoft.Office.Tools.AddInBase.Microsoft.Office.Tools.EntryPoint.FinishInitialization()
  •        at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.ExecutePhase(ExecutionPhases executionPhases)
  •        at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.ExecuteEntryPoints()
  •   InnerException: System.BadImageFormatException
  •        HResult=-2146234076
  •        Message=Index not found. (Exception from HRESULT: 0x80131124)
  •        InnerException: 

  • Best,
    --Josh

    ChemAxon bd13b5bd77

    25-02-2015 15:01:27

    I think the Bad image format can be caused by the reason of using


    Client Profile ... Please use the configuration without the CLient Profile post fix.

    User fd07dcb633

    25-02-2015 16:00:19

    Hi Victor. This error occurs when using the client profile of 4.0 or the full 4.0 framework or the full 4.5 framework... pretty much every configuration I've tried.

    ChemAxon bd13b5bd77

    25-02-2015 16:18:14

    Hi Josh,


    this is strange because as I mentioned one of our projects was done in 4.5 framework.


    However it is true that the solution was set up in VS2010. Anyway VS2010 also supports 4.0.


    Maybe then VS2013 introduced something new.


     


    What I can promise is that this year the team is planning to upgrade the VS environment to 2013,


    but first what we have to do is to upgrade the IKVM and framework compilation to 4.0. It will be coming in the next upcoming weeks though.


    So 4.0 and IKVm 7x can be a step ahead to get your VS2013 working ...


    I hope this helps. I try to keep you posted when this happens. 


     


    Viktor

    User fd07dcb633

    26-02-2015 15:16:08

    Thanks Viktor.


    Please keep me posted.

    User fd07dcb633

    03-03-2015 22:42:34

    An update from my side:


    I've tried to use the most recent dll files in a number of situations and wanted to give an update. Under all circumstances where the .NET 4.0 framework is used, I get an BadImageFormat exception error.


    If I switch to .NET 3.5 this fixes itself, but there are other run-time problems with accessing methods in the interop.JchemExcelCOMInterfaces library that pop-up.


    My goal is to write an add-in for Excel 2013 using Visual Studio 2013 (which mandates the use of .NET 4.0) so I will continue to try to make progress under this scenario.









































    .NET Framework Excel Version Visual Studio Version Result
    4.0 2007 2010 BadImageFormat (ChemAxom.NET.IVKM)
    4.0 2007 2013 BadImageFormat (ChemAxom.NET.IVKM)
    4.0 2013 2013 BadImageFormat (ChemAxom.NET.IVKM)
    3.5 2007 2010 ChemAxom.NET.IVKM loads okay! but JChem4Excel Interops do not work properly
    3.5 2013 2013 NA: Can't create VSTO modules with .NET 3.5 in VS 2013

    User fd07dcb633

    04-03-2015 05:59:52

    One more question along these lines: I've been trying to trace down why the .NET 4 runtime refuses to load the ChemAxon.NET  assemblies. One thing I came across is a suspicious looking reference in these.NET assemblies. If I peek inside the two dlls, I notice that they both contain a strange reference to mscorlib with version=65535.65535.65535.65535 -- this is in addition to the legitimate mscorelib version 2 . Is this supposed to be in there? or are these rogue references which could be causing problems with runtime loading?


    --Josh

    ChemAxon bd13b5bd77

    04-03-2015 11:11:12

    So far you did not mention that the loaded assembly will be interfering with JChem Excel .NET domain and loaded framework version.


     


    What I wrote down to you that there is NO compatibility issue with 4.0 and 4.5 is still valid, since we have couple projects like SpotFire where the host program requires higher framework versions. Our 3.5 assemblies can cooperate with the 4.5 SpotFire framework together.


    Please try it out that you create a project with no Client Profile and use 4.0 as a frmaework version and try to display a molecule. It will work.


    I think the key point here is that you wnat to use assemblies the same assemblies that JChem for Excel loaded with different fframework versions. That is my opinion.


     


     


     

    ChemAxon bd13b5bd77

    05-03-2015 14:10:24

    Josh post:


    Great, thanks Viktor!


    Since the .NET forum board is locked to everyone except moderators, let me post my update on getting the >NET dlls to work with a .NET 4.0 VSTO plugin:


    Your idea of checking assembly versions was a good one. However I found that it wasn't just a matter of making sure the assemblies were the same version across JC4XL, JChem & Marvin. What I found was that none of the 15.2.X.X assemblies worked (I downloaded multiple versions from the archives). in fact, all of these assemblies all were marked as corrupted or invalid by the various .dll validation/verifying tools I used to help diagnose this situation -- and all had that suspicious extra reference to "mscorlib version=35565.35565.35565.35565".


     


    However, if I down-graded even further to any assembly version 14.X.X.X or lower, everything works fine! All of these earlier .dlls are validated as "good" using the same .dll checking software mentioned above and none of them have an extra invalid reference to mscorlib.


    So the final solution is to downgrade JC4XL, JChem and Marvin tools back to the last release of version 14. Hopefully this can help out others who might be having similar problems.

    ChemAxon bd13b5bd77

    05-03-2015 14:18:28

    Josh,


    thank you for your report, as I wrote in a mail to you we have reproduced the issue and see the wrong reference in the dlls manifest region.


    The fix will be rolled out as soon as possible, we keep you and other users informed about it on this forum topic ...


     


    Thank you,


    Viktor