Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Can't consume vb.net object using Coldfusion

New Here ,
Apr 22, 2011 Apr 22, 2011

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.

1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Apr 28, 2011 Apr 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

...
Translate
Advocate ,
Apr 23, 2011 Apr 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 26, 2011 Apr 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 28, 2011 Apr 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==-

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 02, 2011 May 02, 2011

CFSearching you have made my day!

That simple class worked perfectly!

I haven't as yet looked at as to why my class failed (I am using alot of 3rd party DLLs) but I did check the namespace time and time again and everything was set to public.

You have helped me into ways - before the error I had was saying that no such method exsisted in the class. Using CFDUMP to dump the dot net class gives me all the methods CF can see. Lol - why didn't I think of using CFDUMP!

Further more I can now use that simple class as a template and slowly build my complexity in. Fingers crossed that it will work.

Coldfusion rocks with the ability to combine it with dot net. My one criticism with it was that while being extreamly fast you couldn't do that much with it. Now with combination of dot net and Coldfusion one can combine advanced functionality with fast speed of development.

Im thinking of putting on a step by step guid with screen shots on exactly how to do this for others as there wasn't too much on the web.

Thanks once again. Really, really appreciated.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 03, 2011 May 03, 2011
LATEST
Lol - why didn't I think of using CFDUMP!


You probably did, but were not able to get that far. The original error sounded like you could not even create the .net object. ie In which case there is obviously nothing to dump. So it may have been a catch 22.

Coldfusion rocks with the ability to combine it with dot net. My one criticism with it was that while being extreamly fast you couldn't do that much with it. Now with combination of dot net and Coldfusion one can combine advanced functionality with fast speed of development

I have always been able to do some pretty advanced stuff with CF. With it being built on java, I tend to take advantage of the many java libraries out there rather than dll's. But the nice thing about the .net integration is now I can now take advantage of both 😉

Im thinking of putting on a step by step guid with screen shots on exactly how to do this for others as there wasn't too much on the web.


That is a great idea. If you do - definitely post the link here. That would be big help to others getting started with .net and CF.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources