使用 PowerBuilder 中的 COM 对象 - 错误 36:访问外部对象时未找到名称
我正在尝试从 Powerbuilder 中访问第三方 COM 服务器。我可以实例化该对象,但每当我尝试调用该对象的方法或属性时,我都会收到错误 36:“未找到访问外部对象的名称”。
OLEObject PNSession
PNSession = CREATE OLEObject
ll_status = PNSession.ConnectToNewObject("PNSrv9.PNSession")
if ll_status = 0 then
// Set the session printer
try
PNSession.SetSessionPrinter('TIFF Image Printer 9.0', 1, g_pfapp.null_string, False)
catch (oleruntimeerror lole_error2)
messagebox('Set Error', lole_error2.description)
end try
// Turn job tracking on
PNSession.TrackingOn = True
end if
ConnectToNewObject 调用成功,我在任务管理器中看到 COM 服务器,但后续调用失败。根据我查看过的 Word、Excel 的所有 COM 自动化代码示例,上面的内容看起来是正确的。
COM 服务器是 C++ ATL COM 服务器,而不是 .NET COM 对象(如果有什么区别的话)。
有谁知道为什么这不起作用或者我缺少什么?
谢谢。
I'm trying to access a third-party COM server from within Powerbuilder. I can instantiate the object but whenever I try to call a method or a property on the object I get error 36: "name not found accessing external object".
OLEObject PNSession
PNSession = CREATE OLEObject
ll_status = PNSession.ConnectToNewObject("PNSrv9.PNSession")
if ll_status = 0 then
// Set the session printer
try
PNSession.SetSessionPrinter('TIFF Image Printer 9.0', 1, g_pfapp.null_string, False)
catch (oleruntimeerror lole_error2)
messagebox('Set Error', lole_error2.description)
end try
// Turn job tracking on
PNSession.TrackingOn = True
end if
The ConnectToNewObject call succeeds and I see the COM server in my Task Manager, but subsequent calls fail. The above looks correct based on all the COM automation code samples for Word, Excel that I looked at.
The COM server is a C++ ATL COM Server, not a .NET COM object if that makes any difference.
Does anyone have an idea why this isn't working or what I am missing?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的参数类型可能不正确。看看 SetSessionPrinter,我会尝试传递 <代码>0代表
PortsPreCreated
。对于PortBaseName
,请尝试将字符串初始化为""
,并尝试0
。同样,尝试
PNSession.TrackingOn = 0
。You probably don't have the parameter types correct. Looking at SetSessionPrinter, I would try passing
0
forPortsPreCreated
. ForPortBaseName
try a string initialized to""
and also try0
.Similarly, try
PNSession.TrackingOn = 0
.