Dymo

Topics: Developer Forum
Oct 24, 2012 at 5:11 PM

I've add a set proc to dymo.prg additive command,

then called dymoprint("my info") - this is a function inside dymo.prg.

 

ActiveVFP attempts to call this, but I get:

Caught .NET exception, source: MAIN.PRG dymoprint err#= 1426 line= 6 OLE error code 0x80040154: Class not registered.1426 OLE error code 0x80040154: Class not registered. 80040154: Class not registered .NULL. .NULL. .NULL. .NULL. C:\staffwebsite\activevfp.dll message: C:\staffwebsite\activevfp.dll

 

Can this be made to work please? The code works from VFP direct.

Thanks to all !

Coordinator
Oct 24, 2012 at 7:13 PM

Did you remember to use ADDITIVE?

 

Always use ADDITIVE when using SET PROC.  Otherwise you take out all the other libs...

Oct 25, 2012 at 9:01 AM

Thanks for the reply, yes I used ADDITIVE.

The Object can be created normally using VFP, I thought I could so the same in ActiveVFP? IS there something I am missing that is required to make it work ?

 

Thanks

Coordinator
Oct 25, 2012 at 2:11 PM

SET PROC to 'c:\avfp5.61Demo\prg\utiltest' ADDITIVE

works every time for me ...  and do a

RELEASE PROCEDURE 'c:\avfp5.61Demo\prg\utiltest'

at the end if you're working with the library source and don't want it locked in memory so you can change it on the fly..

Oct 25, 2012 at 4:20 PM
Edited Oct 25, 2012 at 4:21 PM

Here is code from an AVFP page:

<%=JustPath(oProp.ScriptPath)+[/dymopower]+oProp.Ext%>, which fires main.prg;

Do Case   && process the request from the URL

 Case oProp.Action == 'dymopower'
 SET PROCEDURE TO  oProp.AppStartPath+"prg\dymopower" additive
 DymoPrint(TTOC(DATETIME()))

Here is DymoPower.Prg:

Function DymoPrint
 Parameters whattoprint
 #Define IDymoAddInName 'Dymo.DymoAddIn'
 #Define IDymoLabelsName 'Dymo.DymoLabels'
 Public DL, LB
 DL = Createobject(IDymoAddInName)
 LB = Createobject(IDymoLabelsName)

Line 6 causes the error:

Caught .NET exception, source: MAIN.PRG dymoprint err#= 1426 line= 6 OLE error code 0x80131902: Unknown COM status code.1426 OLE error code 0x80131902: Unknown COM status code. 80131902: Unknown COM status code .NULL. .NULL. .NULL. .NULL. C:\staffwebsite\activevfp.dll message: C:\staffwebsite\activevfp.dll

===

Any ideas what I'm doing wrong would be appreciated !

 

Coordinator
Oct 25, 2012 at 5:49 PM

 

"...which fires main.prg"

 

wrong.  If you mean the normal main.prg, it ALWAYS runs before any of your AVFP scripts.  Which is also why it's a pretty good place to add Procedure Libraries (and remove them from memory.  

My code above is in main.prg.  The ADD PROC is before the CASE statement and the REMOVE is after the CASE statement.

Oct 30, 2012 at 10:47 PM

Have you registered the Dymo DLLs on the machine serving as the web server?

Jul 29, 2013 at 4:46 PM
Yes, the code works on my box locally, just not from the web app. I'd love a resolution to this as it would be a great feature.

I get:
Caught .NET exception, source: MAIN.PRG dymoprint err#= 1426 line= 10 OLE error code 0x80131902: Unknown COM status code.1426 OLE error code 0x80131902: Unknown COM status code. 80131902: Unknown COM status code .NULL. .NULL. .NULL. .NULL. C:\staffwebsite\activevfp.dll message: C:\staffwebsite\activevfp.dll

When I run the .Avfp page which tries to print a dymo label. Same code as from the command window.

AFAIK I've set everything, including permission and interactive user etc.

Any ideas from similar issues appreciated
Jul 29, 2013 at 4:58 PM
In addition, not sure if this helps, I created a simple DLL, which I registered in my PRG folder.

Now from the command window I can type;
me=createobject("Dymo.dymo")
me.printlabel("hello")


This works.

When I try from ActiveVFP .avfp page, I get ;

Caught .NET exception, source: MAIN.PRG 00005ueh000i err#= 1429 line= 347 OLE IDispatch exception code 1426 from dymo.dymo dymo.dymo: dymoprint.printlabel c:\staffwebsite\prg\dymo.prg Error in line 14 OLE error code 0x80040154: Class not registered. 1426..1429 OLE IDispatch exception code 1426 from dymo.dymo dymo.dymo: dymoprint.printlabel c:\staffwebsite\prg\dymo.prg Error in line 14 OLE error code 0x80040154: Class not registered. 1426.. dymoprint.printlabel c:\staffwebsite\prg\dymo.prg Error in line 14 OLE error code 0x80040154: Class not registered. 1426 dymo.dymo dymo.dymo 0 1426 C:\staffwebsite\activevfp.dll message: C:\staffwebsite\activevfp.dll
Coordinator
Jul 29, 2013 at 5:39 PM
Hmm, I don't know anything about Dymo. Can you point me to where I can get the DLLs ?? So I can try.

It's possible it needs an Interactive Interface like VFP printing and GhostScript, etc. In this case, we put all the routines in a COM EXE and createobject and call methods on that COM EXE from the ActiveVFP (mtdll).
Jul 30, 2013 at 4:09 PM
Claude,

Thanks for the reply. I just downloaded the SDK from Dymo TBH, as there are many DLL and support files and I'm not sure how may are crucial to the operation. Certainly from the command window the code is very easy (post above).

Your last line, can you possible point me more in the right direction? If there is work to do, I'll gladly give it a go just not entirely sure what needs doing there..?

Thanks in advance
Coordinator
Jul 30, 2013 at 4:43 PM
Try putting your existing fox/dymo code in a vfp class and compile to a VFP EXE COM server. Then, within AVFP, do a CREATEOBJECT on the EXE server you just created and call the method you need..

We do the same thing with GhostScript to allow printing VFP reports as PDFs from ActiveVFP. The fact that it involves VFP Reporting means it needs an interactive interface and thus can not be run directly in a MTDLL (like AVFP).
Jul 30, 2013 at 4:50 PM
Edited Jul 30, 2013 at 4:58 PM
Built into .EXE

In browser, open my http://myaddress Add dymopower.avfp to the address, hit enter

In Main.Prg I have;
    Case oProp.Action == 'dymopower'
        me=createobject("Dymo.dymo")
        me.printlabel("hello")
release me


This now gives:
Caught .NET exception, source: MAIN.PRG 0000dpnt000e err#= 1426 line= 346 OLE error code 0x80070005: Access is denied.1426 OLE error code 0x80070005: Access is denied. 80070005: Access is denied .NULL. .NULL. .NULL. .NULL. C:\staffwebsite\activevfp.dll message: C:\staffwebsite\activevfp.dll

For reference here is Dymo.Exe code:
Define Class dymo As Session OlePublic
    Name = "dymoprint"

    Procedure printlabel ( SomeData As Character) As Boolean
        Set Date british
        Set Century On
        Set StrictDate To 0

        #Define IDymoAddInName 'Dymo.DymoAddIn'
        #Define IDymoLabelsName 'Dymo.DymoLabels'
        Public DL, LB


        LB = Newobject("Dymo.DymoLabels")
        DL = Createobject("Dymo.DymoAddIn")
        Store .F. To tlPrintAllRecords
        #Define cEditMode 'Table is in Edit Mode.'
        #Define cNoRecord 'There is no record in the Attendee Table.'
        Local CurRec, cFileName, cPasteObject, cText, cCityStateZip, cRet
        cRet = Chr (13) + Chr (10)
        cFileName = oProp.AppStartPath+"Prg\Address.Lwl"
        cPasteObject = "address"
        *   DL.Open (_Screen.cLabelPath + cFileName)        && open label in DLS
        DL.Open (cFileName)     && open label in DLS
        cText=(somedata)
        LB.SetField (cPasteObject, cText)       && send cText to DLS
        DL.Print (1, .T.)   && print the label
        Release DL
        Release LB
        Release CurRec, cFileName, cPasteObject, cText, cCityStateZip, cRet

        Return .T.
    Endproc


Enddefine
Jul 30, 2013 at 4:59 PM
Altered above message a few times to provide more info for those helping, but that's everything I have at this point in time

Thanks again
Coordinator
Jul 30, 2013 at 5:01 PM
Run DCOMCNFG (For Win 7 or above use mmc comexp.msc /32). Find the EXE COM you just created. Under the Security tab for that EXE COM, add Custom Access and Custom Launch permissions for the IUSR, IWAM, and ASPNET accounts. Under the Identity tab for that EXE COM, make sure the Interactive user is selected.
Jul 30, 2013 at 5:03 PM
Just realised that was the next step, so already on it.

Next question, can't find it in the explorer, how will it be registered there ?
Coordinator
Jul 30, 2013 at 5:22 PM
Edited Jul 30, 2013 at 5:23 PM
You could try calling a single-threaded VFP DLL COM Server first (just recompile a a single threaded DLL). That may do away with all the DCOMcnfg crapola being necessary. (and maybe a better way for AVFP PDF/Reporting if your test proves it).

If you still have to use DCOMcnfg, it should be the name of whatever the EXE COM is you created.
Jul 31, 2013 at 11:48 AM
Claude, thanks for the continued support. I have this working now. I completely overlooked the fact that my site runs on my Windows 7 64-Bit system!

So, I couldn't configure permissions, because I didn't run mmc comexp.msc /32, I ran DCOMCNFG, which as you know, doesn't show the 32-Bit VFP com server EXE..

So, for reference, here is how its setup (its very simple TBH)

Dymo.Exe, in PRG folder, COM server accepts two parameters; information to print on the label, the label filename

Then the .avfp page itself has ;
<%=JustPath(oProp.ScriptPath)+[/dymoaprintuser]+oProp.Ext+"?detail="+ID%>
In Main.Prg;
        Case oProp.Action == 'dymoaprintuser'
            lcfilter = oRequest.QueryString("detail")
            Use Addbs(oProp.DataPath)+"userbook" Shared
            Locate For Id = lcfilter
            me=Createobject("Dymo.dymo")
            me.printlabel(alltrim(Name)+chr(13)+alltrim(ADdress1)+chr(13)+alltrim(Address2)+chr(13)+alltrim(Postcode),oProp.AppStartPath+"Prg\Address.Label")
            Release me
            oResponse.Redirect(oSession.Value("previouspage"))
This now works very well. So thanks again for the help! Now that I'm aware of the 64 bit issue its all very straight forward !