Skip to main content
Participating Frequently
April 20, 2011
Question

using .net object

  • April 20, 2011
  • 1 reply
  • 2046 views

Hi,

Im not a CF programmer so please excuse my ignorance, Im trying to help my CF programmer who is having trouble talking to a .net DLL.

We seem to be able to reference anything that is just a plain method no problem - the issue comes when we expect the method to return a value.

If we just call a method to do something it works fine - if we call a method that returns a value, it throws an error saying that the method does not exist?

so we create an object - works fine

<cfset obj2 = createobject(".net, "CLASS", "PATH to dll")>

run the method that doesn't return anything - works fine

<cfset str = obj2.method("var","var","var")>

but how do we get a method that returns a value?

i.e. we want to set the variable result to be the return value from obj2.returningmethod with 3 parameters

<cfset result - obj2.returningmethod("var","var","var")>

can anyone help or point out what we are doing wrong?

Thanks

This topic has been closed for replies.

1 reply

Inspiring
April 20, 2011

but how do we get a method that returns a value?

Just like you said:

<cfset str = obj2.method("var","var","var")>

run the method that doesn't return anything - works fine

<cfset str = obj2.method("var","var","var")>

No.  That's be:

<cfset obj2.method("var", "var", "var")>

If it doesn't return a value, then don't attempt to stick the value that isn't being returned into a variable ;-)

can anyone help or point out what we are doing wrong?

You're over-complicating things in your head.  A function call is a function call: it doesn't matter whether the function is a CFC method, a Java object method, a .net object method, or a built-in CF function, the syntax is always the same:

<cfset theResult = theFunction(theArguments)>

--

Adam

Participating Frequently
April 20, 2011

Adam,

thanks for clearing that up - its kind of what we thought.

Do you have any ideas why would be getting the method could not be found error? It only seems to be the case for those methods that return values?

We have looked inside the DLL and checked the type the method is expecting - but it just will not run if it has a return value.

Are we missing something simple again?

thanks

Aidan

Inspiring
April 20, 2011

What is the EXACT error message (down to where the stack-trace starts), and what is the EXACT code you are running that causes it.

--

Adam