10

I am .net coder and I am really really new to ColdFusion. I wrote a .dll library which automatically generates an invoice. I needed to use the library from a ColdFusion application. I have successfully loaded the classes in my library as coldfusion objects as I can call the methods. However, there is one method in my class which uses WordprocessingDocument which is a class of DocumentFormat.OpenXml.Packaging. I am actually getting this error :

System.IO.FileNotFoundException: Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. File name: 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at InvoiceLibrary.DocumentHandler.ConvertDocumentToDOCX(String file)
at InvoiceLibrary.DocumentHandler.ProcessDocument()

I have imported the DocumentFormat.OpenXml.dll so is the WindowsBase.dll files

<cfObject type=".NET" name="WordprocessingDocument"
     class="DocumentFormat.OpenXml.Packaging.WordprocessingDocument" 
     assembly="C:\Users\mydocs\Documents\Visual Studio 2012\Projects\InvoiceGenerator\InvoiceLibrary\bin\Release\DocumentFormat.OpenXml.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\WindowsBase.dll">

I need your guidance to what am I doing wrong or what am I missing here?

Sam Hanley
  • 4,707
  • 7
  • 35
  • 63
jmesolomon
  • 563
  • 5
  • 15
  • 1
    ooh thanks to that Leigh! Yeah, that looks a lot better now :) – jmesolomon Oct 07 '14 at 03:17
  • Welcome :) Unfortunately, I do not have an answer, but did you check the jnbridge (used for .net interop) logs? See `{cf_install}/jnbridge/error.log`. *Sometimes* that log contain additional details about .net errors. – Leigh Oct 07 '14 at 18:20
  • No, I have not yet. I'll try it now. I've been stuck on this problem for quite a while now. Sucks balls! I could call methods in .dll library successfully, but this particular method which implements WordprocessingDocument class is where it fails. I'm sure I've included all dependencies. Could it be a class loader issue? Anyways, Thank you for your suggestion, I'll check right away – jmesolomon Oct 07 '14 at 18:58
  • Did you include all of the dependencies with *every* createObject call? Omitting a few might cause that problem. *Could it be a class loader issue* Possibly, that is sometimes the cause of "method not found .." errors, but it is hard to say. – Leigh Oct 07 '14 at 19:29
  • If you are feeling adventurous, you might try [generating the proxies yourself](http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec13e1a-7ffd.html) with built in tools in `\jnbridge` directory. Also, in case it is relevant what is your full CF version? Check the CF Admin screen or use `` – Leigh Oct 07 '14 at 19:34
  • Right click on the DLL in your binary folder and look at the Details tab. Make sure the version of the file matches your reference Version=2.5.5631.0. Sometimes if the version of the assemblies are different, you can get this error. – Jon Apr 16 '15 at 17:32
  • It seems that your computer hasn't installed OpenXmlSDK. – zhangyiying Apr 24 '15 at 06:07

1 Answers1

0

Use a tool like dependency walker to make sure you are copying all of the required linked dlls that DocumentFormat.OpenXml.dll is using. Also do not forget to copy this file with your output.

Brian from state farm
  • 2,825
  • 12
  • 17