locked
Error - Adding ClosedXML to BIDS project RRS feed

  • Question

  • BIDS - 2008 R2 and OpenXMl 2.5, trying to add ClosedXML.dll to script taks and getting an error:

    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: 
    Could not load file or assembly 'ClosedXML, Version=0.65.2.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b' or one of its dependencies. The system cannot find the file specified.
    File name: 'ClosedXML, Version=0.65.2.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b'
       at ST_627b3180ca4c4e15a00f7f3fba2cbc4e.csproj.ScriptMain.create_report()
       at ST_627b3180ca4c4e15a00f7f3fba2cbc4e.csproj.ScriptMain.Main()

    The dll in the reference folder and able to add reference in the script task and in GAC_MSIL  It compiles correctly, but when run the script task I get the above error

    Also, have remove the Block on the dll.
    • Edited by Angel1953 Tuesday, November 5, 2013 5:57 PM
    Tuesday, November 5, 2013 5:49 PM

Answers

  • Are there other assemblies that ClosedXML.dll depends on that are not available for loading?
    • Marked as answer by Angel1953 Thursday, November 3, 2016 1:05 PM
    Tuesday, November 5, 2013 6:18 PM

All replies

  • Are there other assemblies that ClosedXML.dll depends on that are not available for loading?
    • Marked as answer by Angel1953 Thursday, November 3, 2016 1:05 PM
    Tuesday, November 5, 2013 6:18 PM
  • Not sure what assemblies you are talking about? I have added OpenXml as well.  Please give example of assemblies that might need.
    Tuesday, November 5, 2013 6:21 PM
  • Any assembly that ClosedXML.dll depends on that is not loaded on your system. You could use a .Net assembly browser like .Net Reflector to see dependent assemblies or look at the source code for ClosedXML to see what other assemblies it needs.
    Tuesday, November 5, 2013 6:29 PM
  • CodeReflect displays files in the reference folder matches what I have in the script task reference folder.

    Could the problem with ClosedXML and/or OpenXML versions I am using?


    • Edited by Angel1953 Wednesday, November 6, 2013 7:14 PM Another thought
    Wednesday, November 6, 2013 4:30 PM
  • Just like Jim have stated you have to make sure all the other related libraries are not only available but also deployed in GAC. Can you make a small test? Try to execute your package in 32bit mode. Did it work ?

    SSIS Tasks Components Scripts Services | http://www.cozyroc.com/

    Thursday, November 7, 2013 1:41 AM
  • @Angel1953, 

    Are you using the MS Open XML SDK?  If so, the reference would be DocumentFormat.OpenXml.dll -- Like CozyRoc and Jim, I'd advise you the same--you'll have to GAC it.

    Thursday, November 7, 2013 2:26 AM
  • This might be my problem, not sure.

    In the C:\Windows\assembly the ClosedXML does not show up.  Than in the C:\Windows\Microsoft.NET\assembly\GAC_64 I added the new folder ClosedXML and copied the downloaded Dll into the folder. And ran RegAsm.exe and it and did not get any errors and it appeared it worked. But the dll is not showing in the C:\Windows\assembly, would it mean the RegAsm.exe did not work. When I added the ClosedXML.dll to my SSIS project I selected the dll from the C:\Windows\Microsoft.NET\assembly\GAC_64. At the moment using the ClosedXML version 0.69.0.0. Did I put the dll into the wrong place?

    Thursday, November 7, 2013 2:38 PM
  • I think wherever you registered the assembly is where vs will try to find it. If I have it right, then when you ran RegAsm.exe,  ClosedXML was under C:\Windows\Microsoft.NET\assembly\GAC_64. If you pulled the reference from this location, you pulled it from the correct place. If you were able to add it from Browse, you are further along.

    To help determine which dependency isn't registered... take BIDS/SSIS out of the mix by generating a new .net project.  Add the ClosedXML assembly you registered as a reference to that project, use any method intellisense can see. Try to compile it. If that fails, ping back the group.

    example:

    using System;
    using ClosedXML.Excel;
    
    namespace ClosedXML_Anything
    {
        public class TestDependancies
        {
            public void Create(String filePath)
            {
                var workbook = new XLWorkbook();
                var worksheet = workbook.Worksheets.Add("Any SheetName");
                worksheet.Cell("A1").Value = "Success!";
                workbook.SaveAs(filePath);
            }
        }
    }

     If that succeeds, import whatever you were trying to do related to ClosedXML from your BIDS project into the new throw away project--If the error returns, go to books online to see the lineage of the method -- which should point you to the missing assembly ClosedXML is dependent upon (e.g DocumentFormat.OpenXml.dll)

    • Proposed as answer by Mike Yin Monday, November 11, 2013 12:50 PM
    • Unproposed as answer by Angel1953 Wednesday, November 13, 2013 3:15 PM
    Friday, November 8, 2013 11:57 PM