验证是否通过远程处理调用了方法?

发布于 2024-07-14 18:31:13 字数 260 浏览 4 评论 0原文

如何从方法内部验证它是否在远程处理上下文中执行? 我有一个基本的客户 -> NT-Service 设置,其中服务作为特定用户执行。 该用户有权访问 SQL Server。

我正在寻找一种解决方案,可以更轻松地捕获远程处理配置丢失或错误(未指定的方法等)时发生的问题。 我希望能够失败并显示更好的错误消息(“此方法需要远程处理上下文才能正常工作。”),而不是因登录错误而失败。 当原始用户对数据库具有只读访问权限并且在写入数据之前不会抛出错误时,情况会更加棘手。

How can I, from within a method, verify that it executes inside a remoting context? I've got a basic Client -> NT-Service setup where the service executes as a specific user. This user has access to a SQL Server.

I am looking for a solution that would make it easier to catch problems that occur when the remoting configuration is missing or bad (a method that wasn't specified, etc). I would like to be able to fail with a better error message ("This method requires a remoting context to work properly.") instead of failing with login errors. It's even more tricky when the original user has readonly access to the database and the error isn't thrown until data is written.

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

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

发布评论

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

评论(2

随风而去 2024-07-21 18:31:13

那么,您可以使用 System.Diagnostics 中的 stacktrace 类来检查方法调用来自何处。 :)

Well, you could use use the stacktrace class in System.Diagnostics to check where the method call is coming from. :)

通知家属抬走 2024-07-21 18:31:13

我喜欢使用 MS 企业库 进行调试,您可以尝试使用日志记录和异常处理块来处理错误。

I like using the MS enterprise Library for debugging purposes, you can try using the logging and the exception handling blocks to handle the error.

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