开发者

calling methods on .net object from coldfusion

开发者 https://www.devze.com 2023-03-12 06:17 出处:网络
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 -

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开发者_C百科 of parameters and differ only in the parameter data types". This does not seem to be the problem here.


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消