calling methods on .net object from coldfusion
Asked Answered
P

2

7

I am trying to instantiate and call methods on a .net object created from a dll from coldfusion. This works when I call methods with one or zero arguments but fails with -

System.MissingMethodException: Could not find the generic method coldfusion2net.test.setvars

when I try to call a method with more than one arg.

Here is my simple C# class:

namespace coldfusion2net
{
    public class test
    {
        protected string myvar;
        protected string myvar2;
        public void setvars(string v, string v2) {
            myvar = v;
            myvar2 = v2;
        }
        public void setvar(string v) {
            myvar = v;
        }
        public string getvar(){
            return myvar;
        }
    }
}

and here is my ColdFusion test:

<cfset dll = ExpandPath('./coldfusion2net.dll')>
<cfobject type=".NET" name="test" class="coldfusion2net.test" assembly="#dll#">
<cfset test.init()>
<!--- object has been loaded --->
<cfdump var="#test#">
<!--- so far so good --->
<cfset test.setvar("foo")>
<cfset s = test.getvar()>
<cfoutput>#s#</cfoutput>
<!--- wtf??? --->
<cfset test.setvars("foo","bar")>

To compile the dll, I am using visual studio 2010 targeting the .net 3.5 runtime (which is what we have on our servers). I am using ColdFusion 8,0,0,176276 to try and load the dll.

Has anyone else seen anything like this? Am I doing something wrong? Is this a CF bug?

I looked in the article on the Adobe live docs on .NET Interoperability Limitations but the closest thing I found is "ColdFusion cannot determine the correct data type conversion if a method has multiple signatures that have the same number of parameters and differ only in the parameter data types". This does not seem to be the problem here.

Pseudohemophilia answered 10/6, 2011 at 17:11 Comment(11)
CFdump the #test# object. Do you see the setVars() method?Amu
have you tried javacast("string","foo") ?Compressibility
@Amu when I dump the object I see all the methods. The method in question says - setvars(java.lang.String, java.lang.String)Pseudohemophilia
@Compressibility tried the javacast, got the same errorPseudohemophilia
hmm... maybe you can make that .dll available for us to test in CF9.0.1?Compressibility
@Nick - Maybe a bug/compatibility issue? Seemed to work okay for me with 9,0,1,274733 and VS2005. Let me test it with 8.0.1Amu
I put up the zipped dll here - physle.com/publicPseudohemophilia
edited - I just looked and apparently our dev server was never updated to 8.0.1 the version in use is correct now.Pseudohemophilia
@Nick - Sorry, no luck finding a CF8 test box right now. But your dll does work under CF9. So maybe it is an issue that was fixed .. ?Amu
@Compressibility - My take was he was just correcting a typo. But that it still did not work. So @Nick .. is it fixed or still broken? ;)Amu
I just updated the server info in the question. It's not fixed. I think we have a test server with 9 on it. I will give it a shot therePseudohemophilia
C
3

Not sure if this helps, but...

upgrading the .NET version to 3.5 caused the problem, since the ColdFusion .NET integration service had configured itself to use the earlier version of the .NET framework. Uninstalling and then reinstalling ColdFusion .NET integration service fixed the problem in my case.

http://forums.adobe.com/thread/25391?tstart=0

Compressibility answered 10/6, 2011 at 19:50 Comment(0)
P
0

Just a follow up here. Moving to CF9 fixed this. I never did figure out how to get it working under 8.

Pseudohemophilia answered 28/6, 2011 at 15:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.