Coldfusion Accessing parent methods on .net objects

For some reason, Coldfusion has a problem accessing the parent methods of one of the objects it creates.

consider this code:

<cfscript>
  variables.sHTML = '<html><head><title></title></head><body><p>Hello <strong>World</strong></p></body></html>';

  try{
    variables.sAltChunkID = "altChunk1";
    variables.sExportDirectory = application.sSecureExportPath&'int'&'\word\';
    variables.sDLLPath = 'C:\Program Files (x86)\Open XML SDK\V2.0\lib\DocumentFormat.OpenXml.dll';

    variables.sFileName = "testI.docx";

    variables.sFileToWrite = variables.sExportDirectory&'#variables.sFileName#';

    variables.enumWordProcessingDocumentType = createObject("dotnet","DocumentFormat.OpenXml.WordprocessingDocumentType","#variables.sDLLPath#").init().Document;

    variables.oDocument = createObject("dotnet","DocumentFormat.OpenXml.Packaging.WordprocessingDocument","#variables.sDLLPath#").Create(variables.sFileToWrite,variables.enumWordProcessingDocumentType);

    variables.oMainDocument = variables.oDocument.AddMainDocumentPart();

    variables.oEncoding = createObject("dotnet","System.Text.UTF8Encoding").init();
    //variables.oMemoryStream = createObject("dotnet","System.IO.MemoryStream").init(variables.oEncoding.GetBytes(variables.sHTML));

    variables.enumAltChunk = createObject("dotnet","DocumentFormat.OpenXml.Packaging.AlternativeFormatImportPartType","#variables.sDLLPath#").html;

    variables.oFormatImportPart = variables.oMainDocument.AddAlternativeFormatImportPart(variables.enumAltChunk,variables.sAltChunkID);
    writeDump(variables.oFormatImportPart);

    variables.oFormatImportPart.FeedData(createObject("dotnet","System.IO.MemoryStream").init(variables.oEncoding.GetBytes(variables.sHTML)));
  } catch(Any e) {
    writeDump(e);
  }
</cfscript>

variables.oFormatImportParthas a parent method FeedData(System.IO.Stream), however, when I get to this line, Coldfusion hits me, with the exception of:

Either there are no methods with the specified method name and argument types, or the FeedData method is overloaded with argument types that ColdFusion cannot reliably decrypt. ColdFusion found 0 methods that match the arguments provided. If it is a Java object and you have confirmed that the method exists, use the javacast function to reduce ambiguity.

But, as you can see from my Dump, FeedData really exists as a method:

Coldfusion mocks me about the existance of a method

+4
1

FeedData Stream. , createObject .

0

Source: https://habr.com/ru/post/1540727/


All Articles