Skip to main content
Participant
April 23, 2011
Answered

Can't consume vb.net object using Coldfusion

  • April 23, 2011
  • 1 reply
  • 1760 views

Hi All,

I am running Coldfusion 9 Standard on Windows 2003 server and have dot net 3.5 installed. I am developing VB dotnet class using visual studio 2005. The COM class allows one to read and write to office document custom meta data.

If I create another VB executable I am able to reference this COM object with no problem.

With Coldfusion I keep getting class officeproperties was not found in specified assembly list for the line


<cfobject ".net" name = "officedocinstance" class="OfficeProperties" assembly="C:\build\offproperties.dll">

I have seen a few examples of how to consume these objects on the web but they never come with a no dot net source code and working binary to test with. I was wondering if anyone knew of a URL or could provide me with a very simple vb.net source class, project configuaration and binary that I can consume using coldfusion? It would be a fantastic base for me to develop on.

Also Is there any way of getting Coldfusion to spit out all public classes and methods of a given COM .dll?

As I said I can reference the class fine with in VB studio using another stand alone VB.net application. But Im pretty certain the problem lies in my vb configuration or code as I was able to consume the System.IO.DriveInfo dot net class the comes standard with dot net using <cfobject type=".NET" name="sidiClass" class="System.IO.DriveInfo">

So having a working simple VB.net class that works with coldfusion would be a great base for me to start.

    This topic has been closed for replies.
    Correct answer -__cfSearching__-

    With Coldfusion I keep getting class officeproperties was not found in specified assembly list for the line


    <cfobject ".net" name = "officedocinstance" class="OfficeProperties" assembly="C:\build\offproperties.dll">

    Silly question, but have you tried including a namespace (if any)? That and making sure the class/functions/methods are "public" are common gotchas.

    I am really not familiar with COM. But for what it is worth I was able to compile a simple dll and access it from CF9 with no problems. I did not do anything special in VS2005. Just created a new project and accepted all of the defaults:

                 New Project > Visual Basic > Class Library > "TestVBLibrary"

    If you compile the following can you access it from CF? (I would be happy to share the files/settings if needed)

    Lame VB code:

    Public Class MyTestClass
        Private sName As String


        Public Function multiply(ByVal a As Integer, ByVal b As Integer) As String
            Return a * b
        End Function


        Public Property Name() As String
            Get
                Return sName
            End Get


            Set(ByVal value As String)
                sName = value
            End Set


        End Property


    End Class

    CF :

    <cfset obj = createObject(".net", "TestVBLibrary.MyTestClass", ExpandPath("./TestVBLibrary.dll"))>
    <cfdump var="#obj#" label="Methods">


    <!--- test method --->
    <cfset result = obj.multiply( 5, 3 )>
    result = <cfdump var="#result#">


    <!--- test property --->
    <cfset obj.set_name("bob")>
    <cfset name = obj.get_name()>
    name = <cfdump var="#name#">

    Message was edited by: -==cfSearching==-

    1 reply

    12Robots
    Participating Frequently
    April 23, 2011

    I know NOTHING about .NET or COM objects, so forgive me if this is a stupid thing to say.

    <cfobject> differentiates between .NET objects and COM objects.  Since yours is a COM object, shouldn't you be using type="COM"?  I don't know the difference between a COM object and a .NET object, but since you specifically said yours was a COM object I thought I would bring it up.

    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_m-o_10.html#2581098

    Jason

    GerryMilAuthor
    Participant
    April 26, 2011

    Hi Jason,

    Thank you for your help Jason.

    I tried changing the type to COM and got "An exception insantiating a COM object".

    Im too am also a bit confused between the difference between a dot net and COM objects. Before making my initial post I tried first compiling the class as a dot net class. Then when that failed I compiled it as a dot net class that abides by the COM standards. Im not entirely sure of the suttle differences but Visual studio seemed to do it fine and I could import it as a COM object within visual studio.

    What I find frustrating is there appears no or little documentation from Adobe or else where which shows you how to do this from scratch.

    ie- a walk through guide like this -

    A) Here is some simple VB and/or C# class code. (perhaps something that multiplies to variables together)

    B) Compile the code like this with these settings (download complete source and project files here)

    C) Ensure you have dot net, CF  and anythingt else installed on your server.

    D) Execute this Coldfusion Code to trigger the methods of your VB/C# class.

    There is a dedicated service for readind dot net within Coldfusion and when CF 8 came out it was one of the the big things that it did (DOT NET integration) so im a bit puzzled as to why there seems to be no howto guide to get it up and running. If any one has some source code and project files of a simple class that works with coldfusion I would very much like to see it. Or alternatively a link with a detailed walk through that concerns the VB/C# side of things.

    regards,

    Gerard

    -__cfSearching__-Correct answer
    Inspiring
    April 28, 2011

    With Coldfusion I keep getting class officeproperties was not found in specified assembly list for the line


    <cfobject ".net" name = "officedocinstance" class="OfficeProperties" assembly="C:\build\offproperties.dll">

    Silly question, but have you tried including a namespace (if any)? That and making sure the class/functions/methods are "public" are common gotchas.

    I am really not familiar with COM. But for what it is worth I was able to compile a simple dll and access it from CF9 with no problems. I did not do anything special in VS2005. Just created a new project and accepted all of the defaults:

                 New Project > Visual Basic > Class Library > "TestVBLibrary"

    If you compile the following can you access it from CF? (I would be happy to share the files/settings if needed)

    Lame VB code:

    Public Class MyTestClass
        Private sName As String


        Public Function multiply(ByVal a As Integer, ByVal b As Integer) As String
            Return a * b
        End Function


        Public Property Name() As String
            Get
                Return sName
            End Get


            Set(ByVal value As String)
                sName = value
            End Set


        End Property


    End Class

    CF :

    <cfset obj = createObject(".net", "TestVBLibrary.MyTestClass", ExpandPath("./TestVBLibrary.dll"))>
    <cfdump var="#obj#" label="Methods">


    <!--- test method --->
    <cfset result = obj.multiply( 5, 3 )>
    result = <cfdump var="#result#">


    <!--- test property --->
    <cfset obj.set_name("bob")>
    <cfset name = obj.get_name()>
    name = <cfdump var="#name#">

    Message was edited by: -==cfSearching==-