Question

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
Was it helpful?

Solution

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">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top