3

I am currently faced with a dilemma in regards to adding any kind of DLL to a ColdFusion project. I have done a ton of research but nothing seems to be simplistic enough to grasp an understanding. I have a Winform that uses the same DLL in the Reference which makes life easy. When looking to add the same DLLs to a ColdFusion project, it doesn't seem to be working. I have tried using the following:

<cfobject type="com" name="myObj" assembly="C:\DocViewer\AxInterop.SHDocVw.dll">

Here is the error message I am receiving as well:

Attribute validation error for tag CFOBJECT. It has an invalid attribute combination: assembly,name,type.

This site has been very helpful in the past and I am hoping to learn how this DLL in CF9 works so that I do not have to completely rewrite an entire program when the current one works perfectly.

From comments

I tried adding the DLL using the regsvr32 but here is my error now:

the module was loaded but the entry-point dllregisterserver was not found
Miguel-F
  • 13,450
  • 6
  • 38
  • 63
clerktech
  • 141
  • 3
  • 18
  • 2
    I think you should be able to use a registered COM object in ColdFusion. What error message are you getting from that code? Looking at [the documentation for COM objects](http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-714e.html) it seems like you are missing required attributes (class) and have an unsupported attribute for COM objects (assembly). Check the reference I included. – Miguel-F Jan 22 '14 at 15:44
  • 1
    In addition - are you using 32 or 64 bit CF? (COM is not supported under 64 bit.) Also, what exactly does the dll do? – Leigh Jan 22 '14 at 15:59
  • you'll also need to register the dll with Windows. Run this from the command line to register `regsvr32 C:\DocViewer\AxInterop.SHDocVw.dll` – Matt Busche Jan 22 '14 at 16:14
  • Please also add the error message you are getting – Matt Busche Jan 22 '14 at 16:15
  • @Miguel-F This is 32 bit CF. Nobody in the office has ever tied a DLLs to a coldfusion application. The multiple DLLs are needed for allowing a viewer to read documents. Here is the error I am receiving: Attribute validation error for tag CFOBJECT. It has an invalid attribute combination: assembly,name,type. – clerktech Jan 22 '14 at 18:12
  • 1
    That is what I suspected. Read up on the documentation that I referred to (http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-714e.html) and try again using the appropriate attributes. Most likely `class`, `name`, `action="create"` and `type="COM"` at least. Then please report back here with your findings. Also, please [edit your question when giving additional information like error messages](http://stackoverflow.com/posts/21286951/edit) as they are easier to find there than in these comments. – Miguel-F Jan 22 '14 at 18:21
  • Here is another documentation reference for you - [Integrating COM and CORBA Objects in CFML Applications](http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7fd2.html) – Miguel-F Jan 22 '14 at 18:28
  • @Miguel-F error message added to the question. Thank you. Any advice regarding the section of "class"? I think that is the portion throwing my team off as we have never done this before. – clerktech Jan 22 '14 at 18:29
  • See the docs that I just referenced. Specifically for `class` this one - [Getting started with COM and DCOM](http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec14713-7ff7.html) – Miguel-F Jan 22 '14 at 18:30
  • @Miguel-F ok. So I have been battling this problem with no luck. I tried adding the DLL using the regsvr32 but here is my error now: 'the module was loaded but the entry-point dllregisterserver was not found' – clerktech Jan 22 '14 at 20:01
  • Searching for that exact message gives you several possibilities. Most likely the answers to these - [Reference 1](http://social.msdn.microsoft.com/Forums/en-US/7cc969ba-716a-46f5-9dee-22673a2dbd45/module-was-loaded-but-the-entrypoint-dllregisterserver-was-not?forum=vbinterop), [Reference 2](http://stackoverflow.com/a/13948856/1636917), [Reference 3](http://stackoverflow.com/a/11369050/1636917), etc. Perhaps you can explain to us what the COM object does for you and we can suggest a different approach? (As @Leigh suggested a few hours ago.) – Miguel-F Jan 22 '14 at 20:29
  • @Leigh ColdFusion is 32 bit. I was able to find that out. As for the DLLs, there are 18 of them and are required to operate a document viewer. These came from a vendor years ago. They are not .NET or COM DLLs though from what I am understanding. I've never had to dive this deep so my knowledge is limited. My apologies – clerktech Jan 22 '14 at 20:42
  • @Miguel-F I really suck at DLLs. I posted my comment back to answer to (@Leigh) as you suggested. – clerktech Jan 22 '14 at 20:43
  • What kind of documents are you viewing with these DLLs? – Miguel-F Jan 22 '14 at 20:57
  • @Miguel-F these are PDFs being stored on a SQL server. I have the hard code to make it work but need the DLLs to complete the cycle. Do you know anything about calling a .NET class from a ColdFusion9 environment? – clerktech Jan 22 '14 at 20:58
  • No I don't know much about calling .NET classes from ColdFusion except that it is supposedly supported (for 32 bit). However, I do know that ColdFusion has built-in support for many PDF functions. So what exactly are you trying to do? – Miguel-F Jan 22 '14 at 21:09
  • @clerktech re Miguels comments - Using .NET is similar to COM and can be done in either 32 bit or 64 bit ColdFusion (though not usually together - or not easily... see my blog for a couple of tricks on that). .NET syntax is not remarkably different from COM for many things. We (CF Webtools) have recommended that folks using COM move to Java/jar equivalents since the advent of CF 6 (The first Java version). But given no Java equivalent .NET is an acceptable choice. – Mark A Kruger Jan 22 '14 at 22:08
  • Maybe I am confused but the title of this post is using a non .NET dll? – Miguel-F Jan 23 '14 at 01:46
  • @Miguel-F is there a way to send you a zip folder of these DLLs? They came from a vendor but I don't know how old. What I do know is that using it in Visual Studio, I couldn't go beyond 3.5 or else it wouldn't work. – clerktech Jan 23 '14 at 11:48
  • @MarkAKruger where can I find your blog? The DLLs were created by one of our vendors but they offer no support outside of the application it was meant for. I have used this in multiple WinForms with ease but trying to save time and money by implementing this into a CF environment. – clerktech Jan 23 '14 at 12:03
  • @clerktech - I am a little confused. If they are not .net or com, what are they ? ;-) Also, you mentioned *both* com and .net. Do you have .net assemblies for this component? Granted java is the best option in terms of compatibility, but as Mark mentioned .net assemblies should work too. Just keep in mind there are limitations. Some things are not supported in com or .net, [like accessing UI components](http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec13e1a-7fd4.html). – Leigh Jan 23 '14 at 16:40
  • 2
    @clerktech - Also, you still have not shared with us what those DLL's are doing for you. You mentioned this _these are PDFs being stored on a SQL server. I have the hard code to make it work but need the DLLs to complete the cycle_ but I still don't know what that means. As I said before, ColdFusion has built-in support for many PDF functions. So what exactly are you trying to do with these PDFs? – Miguel-F Jan 23 '14 at 21:40
  • My blog is coldfusionmuse dot com. my email is mkruger at cfwebtools dot com. Feel free to contact me directly. – Mark A Kruger Feb 17 '14 at 21:59

1 Answers1

0

Well it looks to me like you're using the cfobject attributes for a .NET object instead of for a COM object. The cfobject tag is one of those tags where the attributes vary by action/type, like cfcontent, cffile and cfdirectory (and a bunch of others that don't immediately spring to mind).

So you need the documentation for accessing COM objects specifically, which for the latest version of Adobe's CFML engine is located here: https://wikidocs.adobe.com/wiki/display/coldfusionen/cfobject%3A+COM+object

There's a typo on the docs page, but it looks like this should work for you (although I'll admit it's been a while since I've invoked a COM object):

<cfobject 
    type = "com"
    class = "path.to.com.Class" 
    name = "myObj"
    action = "create|connect">

It looks like you would use action="connect" if you have it installed as a Windows Service, or create if you want CF to instantiate the DLL, but I would guess having it installed as a service would be easier. I'm just guessing, but I think "path.to.com.Class" would be the name of the service if you're using it that way, or it would be the logical path to the .dll file if the CF server is instantiating it. If neither of those options work, then there might either be a version incompatibility if this is being moved to a newer OS, or the service might be misconfigured.

The error message from registering the DLL sounds like (and I'm guessing because I've never created a windows service DLL) it's looking for a specific class or function in the DLL in order to register it as a service in Windows and it can't find that "entry point" in the DLL (i.e. in the same way that Java will look for a "public static void Main(String args)" as the entry-point to a Java program). That may be necessary for a Service, but it's probably not necessary for a generic DLL that might be accessed and used in some other way, so it's possible this DLL might work, but not be compatible with Service registration.

So going back to your sample code, this might work:

<cfobject type="com" name="myObj" action="create" 
    class="C:\DocViewer\AxInterop.SHDocVw.dll">
Samuel Dealey
  • 263
  • 1
  • 7
  • 1
    `class` should be `ProgID` in the COM context, not path of the dll. – Henry Apr 03 '14 at 00:02
  • I said I was guessing. I notice now that the documentation had been mentioned in the comments. I didn't read them, because I expect answers to be posted in answers, not in comments. – Samuel Dealey Apr 03 '14 at 00:20
  • 1
    _"I didn't read them, because..."_ well then you'll need to (a) adjust your expectations, and (b) start reading comments regardless because they often contain/request clarifications to the question that are relevant for anyone about to answer. – Peter Boughton Apr 03 '14 at 08:47
  • *"adjust your expectations"* My expectations should be different from the site creators' expectations, that answers be in answers as they intended and not in comments? I should expect that programmers will not read the instructions on a tech site and misuse the tools? – Samuel Dealey Apr 03 '14 at 16:33