Running .net code from a network drive fails in app.config load - VisualCron - Forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


Irakli Machabeli
12 years ago
Here is the scenario:

Application that has an app.config!!! is located on a network drive.
If I run a job as a background task it fails as soon as it tries to access appname.exe.config file with the following error:
Quote:


System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at System.Security.Policy.PEFileEvidenceFactory.GetLocationEvidence(SafePEFileHandle peFile, SecurityZone& zone, StringHandleOnStack retUrl)
at System.Security.Policy.PEFileEvidenceFactory.GenerateLocationEvidence()
at System.Security.Policy.PEFileEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.AssemblyEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.Evidence.GenerateHostEvidence(Type type, Boolean hostCanGenerate)
at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type)
at System.Security.Policy.Evidence.GetHostEvidence(Type type, Boolean markDelayEvaluatedEvidenceUsed)
at System.Security.Policy.AppDomainEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.Evidence.GenerateHostEvidence(Type type, Boolean hostCanGenerate)
at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type)
at System.Security.Policy.Evidence.RawEvidenceEnumerator.MoveNext()
at System.Security.Policy.Evidence.EvidenceEnumerator.MoveNext()
at System.Configuration.ClientConfigPaths.GetEvidenceInfo(AppDomain appDomain, String exePath, String& typeName)
at System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(AppDomain appDomain, String exePath)
at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
at System.Configuration.Internal.ConfigurationManagerInternal.System.Configuration.Internal.IConfigurationManagerInternal.get_ExeProductName()
at System.Configuration.ApplicationSettingsBase.get_Initializer()
at System.Configuration.ApplicationSettingsBase.CreateSetting(PropertyInfo propInfo)
at System.Configuration.ApplicationSettingsBase.EnsureInitialized()
at System.Configuratio



If I run same app as a foreground process everything works and of course I can run executable from the command prompt. I also tried to add global trust for the network share with caspol but no success.

VisualCron service is running as an user account with admin rights(as a reults foreground and background tasks run with the same account). I also tried to run VisualCron as SYSTEM account and supply credentials to the task but got the same error.
Sponsor
Forum information
Support
12 years ago
Have you tried creating a Credential and set in that Task?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Irakli Machabeli
12 years ago
As I said I tried already to create credential and run task under that account.
Support
12 years ago
Sorry, missed that. I thought you only changed the VisualCronService user.

Which file is the problem in this case? It seems like it loads the app.config but the problem is a path in the config.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Irakli Machabeli
12 years ago
This is the code of application:
static int Main(string[] args)
        {
            try
            {
                Console.WriteLine(Properties.Settings.Default.GreetingText);
                if (args.Length > 0)
                {
...             }
                Console.WriteLine("Huray");
                return 0;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return 7;
            }
        }
    }


It crashes right on the first line as soon as it tries to access Properties.Settings.Default.GreetingText, If I remove exception handling Visual Studio debugger pops up and stack trace is on the first line
Support
12 years ago
Is it possible that you could zip whole folder with all files and attach here or send to support@visualcron.com
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Irakli Machabeli
12 years ago
The whole application is 15 lines of code, everything is attached
File Attachment(s):
TestProcess.zip (28kb) downloaded 55 time(s).
Support
12 years ago
I tried succesfully running your app with the following settings:

1. VisualCron service running as SYSTEM
2. a Credential set in the Execute Task with "Local login" unchecked
3. no other specific settings - just the full (UNC) path to the command line
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Irakli Machabeli
12 years ago
Try to run VisualCron as user account that has access to the network share and instead of UNC path use drive letter (surprisingly application works when one uses UNC).
Support
12 years ago
Originally Posted by: Irakli Machabeli 

Try to run VisualCron as user account that has access to the network share and instead of UNC path use drive letter (surprisingly application works when one uses UNC).



Network shares (logical drives) are not shared across systems (even though same user is used) like this. Also they are unreliable in the sense that you create another dependency. Use UNC paths only and it will work always.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Irakli Machabeli
12 years ago
I got it working finally. The reason was pretty strange, it looked like some kind of permission issue so I tried to delete network share and it would not drop, net use would not show that share is in use but drive was still visible in explorer. After googling a little bit I end up cleaning some registry keys to get rid of mapped drive. Than rebooted reconnected drives and everything worked like a charm.
Reason of using network share is that we have lots of batch files that use drive letters to execute application. Porting all that just to make it work under VisualCron is too much of an effort.
Support
12 years ago
Ok great! Another thing you can do is to Map drives from VisualCron - even though we recommend to not use network drives at all.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top