Project

Profile

Help

Problem calling .NET instance methods

Added by Anonymous over 15 years ago

Legacy ID: #6117018 Legacy Poster: Dennis Brothers (dbrothers)

This one is driving me crazy. In my stylesheet element I have xmlns:aClass="clitype:myNamespace.myClass?from=file:///c:/myFile.dll" In the body of the stylesheet I have <xsl:variable name="myInstance" select="aClass:new()"/> <xsl:variable name="theResult" select="aClass:Test( $myInstance )"> Test is a public method of myClass that takes no arguments and returns a string. The consructor call apparently succeeds, but the method call on the instance throws the error "Cannot find a matching 1-argument function named {clitype:myNamespace.myClass?from=file:///c:/myFile.dll}Test()". This is a simplification; the problem originally manifested itself with a method having four int arguments; the error was that Saxon couldn't find a 5-argument function. It appears that Saxon is only looking for static methods, and treating the instance variable as an argument. I'm guessing I'm doing something dumb, but I can't see it. Thanks for any insight - - Dennis Brothers


Replies (3)

Please register to reply

RE: Problem calling .NET instance methods - Added by Anonymous over 15 years ago

Legacy ID: #6129177 Legacy Poster: Michael Kay (mhkay)

I'm afraid I can't see from this what you are doing wrong either. It's certainly NOT the case that Saxon only supports static methods. Showing the C# source code of myClass might reveal something (on the other hand, it might not!) Are you running from the command line or from the .NET API? The -TJ option on the command line can be useful for diagnosing this kind of problem. There's an equivalent setting in the API if needed, though I would try and get this working from the command line first if that's feasible.

RE: Problem calling .NET instance methods - Added by Anonymous over 15 years ago

Legacy ID: #6131379 Legacy Poster: Dennis Brothers (dbrothers)

Thanks for the -TJ tip - I hadn't thought of trying it from the command line. That showed me that I had a typo in the path to my .NET assembly (I hadn't looked too hard for such things, because it appeared that the constructor call was succeeding - the error message only mentioned the instance method call). I'm not out of the woods yet, however - now I'm getting the errors I've appended to the end of this post, specifically that the format of the assembly is invalid. I don't understand that, since the assembly works with a .NET test harness. The "No Java class ... could be loaded" is also puzzling. I'll understand if you wash your hands of .NET plumbing problems, and I'll keep poking at this, but if you have any thoughts to share I'd be grateful. - Dennis Brothers C:&gt;saxon90\bin\transform -TJ -s:doc.xml -xsl:wticategorizercaller.xsl -o:result .xml Warning: at xsl:stylesheet on line 6 of file:///C:/wticategorizercaller.xsl: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor Loading Inmagic.Mercury.Components.Categorizer.dll No Java class Inmagic.Mercury.Components.Categorizer.dll could be loaded Absolute location URI: file:///c:/WTI/categorization/bin/Inmagic.Mercury.Compone nts.Categorizer.dll Failed to load assembly Inmagic.Mercury.Components.Categorizer.Categorizer?from= file:///c:/WTI/categorization/bin/Inmagic.Mercury.Components.Categorizer.dll: Th e format of the file 'Inmagic.Mercury.Components.Categorizer.dll' is invalid. (c li.System.BadImageFormatException) Loading Inmagic.Mercury.Components.Categorizer.dll No Java class Inmagic.Mercury.Components.Categorizer.dll could be loaded Absolute location URI: file:///c:/WTI/categorization/bin/Inmagic.Mercury.Compone nts.Categorizer.dll Failed to load assembly Inmagic.Mercury.Components.Categorizer.Categorizer?from= file:///c:/WTI/categorization/bin/Inmagic.Mercury.Components.Categorizer.dll: Th e format of the file 'Inmagic.Mercury.Components.Categorizer.dll' is invalid. (c li.System.BadImageFormatException) Error on line 28 of file:///C:/wticategorizercaller.xsl: Cannot find a matching 1-argument function named {clitype:Inmagic.Mercury.Components.Categorizer.Categorizer?from=file:///c:/WT I/categorization/bin/Inmagic.Mercury.Components.Categorizer.dll}test() Transformation failed: Run-time errors were reported C:&gt;

RE: Problem calling .NET instance methods - Added by Anonymous over 15 years ago

Legacy ID: #6131639 Legacy Poster: Michael Kay (mhkay)

The reference to a "Java class" is just a bad error message, caused by reusing code from the Java product in the .NET product. Read it as ".NET type". I'm afraid I have no idea what the message about the invalid file format is trying to say. Is it perhaps a question of the .NET version? The C# documentation for the exception says: "For example, this exception is thrown when unmanaged code is passed to Assembly.Load for loading." - does that give any clues? Further tips at http://msdn.microsoft.com/en-us/library/k7137bfe(VS.80).aspx

    (1-3/3)

    Please register to reply