我创建了一个 C# 控制台应用程序,并尝试在 SQL Server 作业上运行它。
我将类型设置为“操作系统”,命令文本为:
"C:\Users\Admin\Documents\Visual Studio 2010\Projects\JobsApp\JobsApp\obj\x86\Release\JobsApp.exe"
当我运行作业时,我得到了这个:
Executed as user: NT Service\SQLSERVERAGENT. Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'FeedLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.
所以我授予 SQLSERVERAGENT 访问 dll 的权限,但现在我得到了这个:
Executed as user: NT Service\SQLSERVERAGENT. The process could not be created for step 1 of job 0x3E702A92E3799D4995984DF6641604F2 (reason: Access is denied). The step failed.
我彻底糊涂了。是否还有其他文件也需要访问?我做错了什么?
我正在使用 SQL Server 2012 并使用 Visual C# Express 2010 创建了 exe。
谢谢。
最佳答案
您的应用位于 C:\Users\Admin 文件夹中(为什么????),因此需要某人以 Admin
身份登录或特别授予对该文件夹的访问权限才能运行它。似乎(谢天谢地)SQLSERVERAGENT
没有以管理员权限运行。
关于c# - 使用 sql server 作业代理运行 .exe 时访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14025664/