简体   繁体   English

任务计划程序失败.Net 4.5控制台应用程序

[英]Task Scheduler Fails .Net 4.5 Console Application

I have a .Net 4.5 Console Application written in C# that makes a call to SQL using Entity Framework 6.1.3 and generates a PDF. 我有一个用C#编写的.Net 4.5控制台应用程序,它使用Entity Framework 6.1.3调用SQL并生成PDF。 The application runs fine if you run the executable but it fails when ran through Task Scheduler. 如果您运行该可执行文件,则该应用程序可以正常运行,但是在通过Task Scheduler运行时,该应用程序将失败。 It will only run on Task Scheduler with option "Run only when user is logged in" I need it to run when not logged in. 它只能在Task Scheduler上运行,并带有“仅在用户登录时运行”选项。我需要它在未登录时运行。

What I did to test the executable in Task Scheduler was to mock the data gets called from Entity Framework and the application worked just fine so something tells me that Task Scheduler did not like my Entity Framework call. 我在Task Scheduler中测试可执行文件的工作是模拟从Entity Framework调用的数据,并且该应用程序运行良好,因此有些事情告诉我Task Scheduler不喜欢我的Entity Framework调用。 Yet I have other Schedule Tasks Running using Entity Framework.. Not sure what the problem is. 但是我还有其他使用实体框架运行的计划任务。。不确定是什么问题。 Below is one the error seen in Windows Log. 下面是Windows日志中看到的错误之一。

Application: CreatePDFFile.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. 应用程序:CreatePDFFile.exe框架版本:v4.0.30319说明:该进程由于未处理的异常而终止。 Exception Info: System.Data.SqlClient.SqlException Stack: at System.Data.Entity.Internal.RetryAction 1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].PerformAction(System.__Canon) at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(System.Action 1) at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() at System.Data.Entity.Internal.LazyInternalContext.get_ObjectContext() at System.Data.Entity.Internal.InternalContext.ExecuteSqlQuery[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.String, System.Nullable 1<Boolean>, System.Object[]) at System.Data.Entity.Internal.InternalContext.ExecuteSqlQueryAsIEnumerator[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.String, System.Nullable 1, System.Object[]) at System.Data.Entity.Internal.InternalContext.ExecuteSqlQuery(System.Type, System.String, Syste 异常信息:System.Data.SqlClient.SqlException堆栈:位于System.Data.Entity.Internal.RetryAction 1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].PerformAction(System.__Canon) at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(System.Action 1)位于System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()位于System.Data.Entity.Internal.LazyInternalContext.get_ObjectContext() System.Data.Entity.Internal.InternalContext.ExecuteSqlQuery [[System .__ Canon,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089]](System.String,System.Nullable 1<Boolean>, System.Object[]) at System.Data.Entity.Internal.InternalContext.ExecuteSqlQueryAsIEnumerator[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.String, System.Nullable 1,System。 System.Data.Entity.Internal.InternalContext.ExecuteSqlQuery(System.Type,System.String,Syste处的Object []) m.Nullable 1<Boolean>, System.Object[]) at System.Data.Entity.Internal.InternalSqlNonSetQuery.GetEnumerator() at System.Data.Entity.Infrastructure.DbRawSqlQuery 1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].GetEnumerator() at System.Linq.Enumerable+WhereSelectEnumerableIterator 2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext() at System.Collections.Generic.List 1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]..ctor(System.Collections.Generic.IEnumerable 1<System.__Canon>) at System.Linq.Enumerable.ToList[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable 1) at Repository.MyRepository.GetData(System.String, System.String, System.String, Int32) m.Nullable 1<Boolean>, System.Object[]) at System.Data.Entity.Internal.InternalSqlNonSetQuery.GetEnumerator() at System.Data.Entity.Infrastructure.DbRawSqlQuery 1 [[System .__ Canon,mscorlib,Version = 4.0 .0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089]]。GetEnumerator()at System.Linq.Enumerable + WhereSelectEnumerableIterator 2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext() at System.Collections.Generic.List 1 [[System .__ Canon,mscorlib,Version = 4.0.0.0,Culture = neutral ,PublicKeyToken = b77a5c561934e089]] .. ctor( 1<System.__Canon>) at System.Linq.Enumerable.ToList[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable System.Collections.Generic.IEnumerable 1<System.__Canon>) at System.Linq.Enumerable.ToList[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable位于Repository.MyRepository.GetData(System.String,System.String,System.String,Int32)的1<System.__Canon>) at System.Linq.Enumerable.ToList[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable 1)

I am using SQL Authentication. 我正在使用SQL身份验证。 I added a try catch error and I get this: 我添加了一个try catch错误,我得到了:

Login failed: The login is from an untrusted domain and cannot be used with Windows Authentication. 登录失败:登录来自不受信任的域,不能与Windows身份验证一起使用。

After looking at my connection string, I realized that I had copied the connectionstring from my PC to the server and replaced the data source but not the credentials....So its resolved. 查看连接字符串后,我意识到我已将连接字符串从PC复制到服务器并替换了数据源,但没有替换凭据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Task Scheduler中运行的控制台应用程序不停止 - Console Application running in Task Scheduler without stop 从任务计划程序调试Windows控制台应用程序 - Debugging a Windows Console Application from Task Scheduler 如何使用Windows Task Scheduler隐藏控制台应用程序窗口 - How to hide console application window with windows task scheduler 任务计划程序定期停止运行C#控制台应用程序 - Task scheduler stops running C# console application periodically 现在可以在从 Windows 任务调度程序运行 .net 核心控制台应用程序时读取 appsettings.json 文件中存在的连接字符串 - Now able to read the Connection String present in appsettings.json file when running the .net core Console application from windows task scheduler Task Scheduler无法正确运行控制台.net程序 - Task Scheduler can't run console .net program correctly 调用WCF的C#控制台应用程序的窗口调度程序失败 - window Scheduler of C# Console Application calling WCF fails 任务计划程序中的.NET进程 - .NET processes in Task Scheduler 使用TPL Task杀死.net控制台应用程序 - Kill .net Console application from with TPL Task 如何从Visual Studio 2017中的.NET Framework 4.5控制台应用程序引用.NET标准库? - How Do You Reference a .NET Standard Library from a .NET Framework 4.5 Console Application in Visual Studio 2017?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM