Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: .NET COM object not being created for Service Application


This question is answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Mar 1, 2018 12:48 PM Last Post By: ken pfeiffer Threads: [ Previous | Next ]
ken pfeiffer

Posts: 15
Registered: 5/11/98
.NET COM object not being created for Service Application  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2018 3:23 PM
I have been successfully using a .NET COM object in a application created with Delphi 7.
However, when I try to same routines in a service, it does not work. The code I am using
is:
..........
var
PrintToPACS: oleVariant;
..........
try
CoInitialize(nil);
PrintToPacs:=CreateOLEObject('Sonultra.PrintToPacs'); //from registered dll: PrintToPacs.dll
except on E: Exception do begin
writeln(Logfile,'Error creating PTP client, '+E.Message);
flush(logfile);
end;
end;

This works fine in an application, which will run in any directory on the Win7 target machine.
However, when attempting the same code in a service, I always get the error message
"Error creating PTP client, OLE error 80131534"
This is true with the firewall off, antivirus off, and with the PrintToPacs.dll available in
the start directory, \windows\system32, windows\syswow64, and with changing
directory to any other directory where the dll exists before calling CreateOLEObject.

Any help on this will be greatly appreciated. Thanks much!
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: .NET COM object not being created for Service Application
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2018 4:38 PM   in response to: ken pfeiffer in response to: ken pfeiffer
ken pfeiffer wrote:

This works fine in an application, which will run in any directory on
the Win7 target machine. However, when attempting the same code in a
service, I always get the error message "Error creating PTP client,
OLE error 80131534"

COM error codes in the 0x8013xxxx range are indeed from .NET:

Interpreting HRESULTS returned from .NET/CLR: 0x8013XXXX
https://blogs.msdn.microsoft.com/yizhang/2010/12/17/interpreting-hresults-returned-from-netclr-0x8013xxxx/

In this case, error code 0x80131534 is COR_E_TYPEINITIALIZATION
("Uncaught exception during type initialization").

IOW, the type's constructor threw an exception. Now you have to figure
out why. Do you have the DLL's source code? Can you debug the
constructor of the 'Sonultra.PrintToPacs' class type? Maybe it is
trying to access some resource that is not accessible in a service due
to the fact that a service runs in a different user session than a
normal app does.

--
Remy Lebeau (TeamB)
ken pfeiffer

Posts: 15
Registered: 5/11/98
Re: .NET COM object not being created for Service Application  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 1, 2018 12:48 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thank you very much Remy! That is very helpful...

All the best,

Ken

Remy Lebeau (TeamB) wrote:
ken pfeiffer wrote:

This works fine in an application, which will run in any directory on
the Win7 target machine. However, when attempting the same code in a
service, I always get the error message "Error creating PTP client,
OLE error 80131534"

COM error codes in the 0x8013xxxx range are indeed from .NET:

Interpreting HRESULTS returned from .NET/CLR: 0x8013XXXX
https://blogs.msdn.microsoft.com/yizhang/2010/12/17/interpreting-hresults-returned-from-netclr-0x8013xxxx/

In this case, error code 0x80131534 is COR_E_TYPEINITIALIZATION
("Uncaught exception during type initialization").

IOW, the type's constructor threw an exception. Now you have to figure
out why. Do you have the DLL's source code? Can you debug the
constructor of the 'Sonultra.PrintToPacs' class type? Maybe it is
trying to access some resource that is not accessible in a service due
to the fact that a service runs in a different user session than a
normal app does.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02