I created an app in C# using the sample project connector to create an entity record. It works great, except when I try to trigger it with Task Scheduler. It is running on Server 12. The app does run, and leaves an entry in it's log file, however I errors:


Application: MYClient.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.NullReferenceException Stack: at MyNamespace.ServerConnection.GetServerAddress(Boolean ByRef) at MyNamespace.ServerConnection.GetServerConfiguration() at MyNamespace.CRM.Connect() at MyClient.Program.Main(System.String[])

I'm using CRM 2011 on prem which is on a different server than my program is running. This has to be some sort of permission issue. I have Task Scheduler set to run as me. I have tried unsuccessfully using an intermediary bat file. I have also tried starting the program from a different C# exe using: System.Diagnostics.Process.Start("MyClient.exe");
with no luck. The last entry in Report.wer is LoadedModule[79]=C:\Windows\Microsoft.NET\Framework\v4.0.30319\diasymreader.dll  
before the line:
FriendlyEventName=Stopped working

If anyone has ever used the sample SDK code with Task Scheduler successfully, I would love to hear from you. Thanks