从 WCF 服务访问 QuickBooks 时,在 QBUtilities.dll 中找不到 AccessExceptionViolation、SEHException 和/或过程入口点

发布于 2024-10-27 14:43:46 字数 844 浏览 1 评论 0原文

我有一个 WCF 服务(实际上是几个),由 WPF 应用程序调用,全部在 .NET 4.0 下。使用 nsoftware 的 QuickBooks Integrator 5.0(QuickBooks SDK 的 .NET 包装器库),我的大部分例程都运行良好。然而,当其中一些从新线程运行时,并且出现错误,特别是无法打开 QuickBooks 文件的错误,那么我会收到各种各样奇怪的错误,包括 SEHException,两者都是“无效的参数状态” util”和 QBUtilities.dll 中“未找到过程入口点”,以及访问异常违规。

例如,当直接从客户端调用该例程时,该例程将按预期工作。假设我故意加载错误的 QuickBooks 文件(意味着 QuickBooks 无法打开我的应用程序期望的文件;一个致命的可捕获错误)并调用它:

GetCustomerWithQB(int CustID)
{
 .. set up code
 ..
 try {
   ..
   ..
   toReturn.QBCustomer.QBCustomer.Get(QuickBooksId); // this goes to QB to do the fetch
 }
 catch (nsoftware.InQB.InQBException x)
 { 
   // we get, correctly, a 602 "there is a different file open" error.
 }
} 

但是,如果我从服务内调用该例程,生成一个新线程:

Task.Factory.StartNew(delegate { GetCustomerWithQB(CustID); });

然后我得到上述各种错误。咕噜咕噜。帮助?

I have a WCF Service (several, actually) called by a WPF application, all under .NET 4.0. Using the QuickBooks Integrator 5.0 from nsoftware (a .NET wrapper library for the QuickBooks SDK), most of my routines work fine. However, when some of them are run from a new thread, AND there's an error, particularly one where the QuickBooks file can't be opened, then I get a wide variety of strange errors, including an SEHException, both an "invalid arg status util" and a "procedure entry point not found" in QBUtilities.dll, and an access exception violation.

For example, the routine when called directly from the client, works as expected. Let's say I deliberately load the wrong QuickBooks file (meaning QuickBooks cannot open the file my application is expecting; a fatal trappable error) and call it:

GetCustomerWithQB(int CustID)
{
 .. set up code
 ..
 try {
   ..
   ..
   toReturn.QBCustomer.QBCustomer.Get(QuickBooksId); // this goes to QB to do the fetch
 }
 catch (nsoftware.InQB.InQBException x)
 { 
   // we get, correctly, a 602 "there is a different file open" error.
 }
} 

However, if I call that routine from within the service, spawning a new thread:

Task.Factory.StartNew(delegate { GetCustomerWithQB(CustID); });

Then I get the variety of errors above. GRRRR. Help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幽蝶幻影 2024-11-03 14:43:47

经过大量的调试和一天的研究后,事实证明,只有当我同时调用两个例程时,我才会遇到奇怪的错误。这促使我研究了多种途径,其中最有用的是 这个问题。最重要的是,我创建了一个静态单线程 StaTaskScheduler(来自 Microsoft 的并行扩展 库):

_staSchedulerForQBCalls = new StaTaskScheduler(numberOfThreads:1);

并将其用于调用 QuickBooks 的所有任务:

Task.Factory.StartNew(delegate { GetCustomerWithQB(CustID); }, CancellationToken.None, TaskCreationOptions.None, _staSchedulerForQBCalls);

正如这些事情通常所做的那样,事后看来似乎相当明显,但奇怪的错误和有限的问题情况肯定一开始并没有给我指出这个方向。

After extensive debugging and a day's worth of research, it turns out that I only got the weird errors when I had TWO routines calling at once. This led me to investigate a number of avenues, the most useful of which was this question. Bottom line, I created a static single-threaded StaTaskScheduler (from the Microsoft's Parallel Extensions library):

_staSchedulerForQBCalls = new StaTaskScheduler(numberOfThreads:1);

and used it for all the tasks calling QuickBooks:

Task.Factory.StartNew(delegate { GetCustomerWithQB(CustID); }, CancellationToken.None, TaskCreationOptions.None, _staSchedulerForQBCalls);

As these things usually do, it seems reasonably obvious in hindsight, but the bizarre errors and limited circumstances of problems certainly didn't point me in this direction at first.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文