问题
I have a c# console app that uploads data to a Sitecore/UCommerce implementation. It is based on the UCommerce UConnector. When I run this from the command line it executes without a problem all data is uploaded and downloaded correctly without error. When I try to schedule this task it exits with a 0xffffff
error. The task specifies a command line parameter that sets the app to read all configurable options from the App.Config
I have search this error and found many suggestions which I have tried but none are solving this problem. Things I have tried include:
- Entering a Start In parameter
- Checking Run with highest privilege's
- Converting Console App to Windows Forms app with no forms
- Using Administrator account to run task
- Setting security permissions on the folder the app is in to full control
- Running under the System account
- Tried running the same task on a Server (Windows Server 2012) and Workstation (Windows 7)
None of these have made any difference. Nothing in logged in the event viewer. The error logging (SQL) in the app logs nothing.
I don't know if this has any relevance but the app is using NHibernate, Castle Windsor and of course UCommerce.
Can anyone suggest anything I have not yet tried? Or suggest how I can find out what the error might be.
Edit
Here is the command line command as requested
Update
(I have removed all the spaces in the path just in case that was causing an issue so command below is a different path than the image above)
I have managed to get the config changed on the server and create a batch file. I have also changed the folder the app is in so there are no spaces in the path. in the batch file I have
cmd /c F:\SCProcessor\Orders\SiteConnector.exe /cfg
I have the same error being repored in Task Scheduler
If I double click the batch file it runs perfectly. If I change the /c
to /k
(hoping to see an error reported in the command window) no window shows and the task does not stop running until I end it.
回答1:
Ok I have fixed my own problem. It took a while to find out what the problem actually was but eventually I found it by running this in SSMS and xp_cmdshell
. This reported back that it could not find a config file
C:\windows\system32\app_config\prefetch\Common.config
app_config is a folder in the console apps folder. In the SiteConnector.exe.config is a number of includes that pull in various configs:
<sc.include file="App_Config/Prefetch/Common.config"/>
For whatever reason (and I still have to work out why) this resolves to:
C:\windows\system32\app_config\prefetch\Common.config
When calling it from task scheduler or a SQL job but:
F:\SCProcessor\Orders\app_config\prefetch\Common.config
When run from the command prompt.
I changed the paths for the includes to absolute paths and the problem is fixed. Just need to update the SiteConnector.exe.config
to something like
<sc.include file="{$CurrentFolder}/App_Config/Prefetch/Common.config"/>
If that is possible.
来源:https://stackoverflow.com/questions/33125750/scheduled-task-fails-unspecified-error