Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calling methods on .net object from coldfusion

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.

like image 285
Nick Van Brunt Avatar asked Jun 10 '11 17:06

Nick Van Brunt


1 Answers

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

like image 58
Henry Avatar answered Sep 23 '22 17:09

Henry