I am developing a C# WPF project with an embedded SQLite Database. I have used SQLite before without problems but for some reason when I call:
SQLiteConnection conn = new SqliteConnection("my connection string");
However, when this code executes it displays the error
XamlParserException was unhandled
Cannot create instance of MainWindow.xaml defined in assembly 'MyProject', Version=1.0.0.0...
Exception has been thrown by the target of an invocation. Error in markup file 'MainWindow.xaml' Line 1 position 9.
At this position is the following code in the XAML file
<Window xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit" x:Class="MySQLBackup.MainWindow"
I have set the project to be .Net Framework 3.5 so I do not understandw why I am getting this error and why it is saying it is an error in the XAML when it calls the SQLiteConnection in the class file.
Thanks for any help you can provide.
UPDATE
As requested below is the stacktrace and inner exception
Inner Exception
System.Configuration.ConfigurationErrorsException: Unrecognized
configuration section userSettings/Gui.Properties.Settings.
(C:\Users\Chris\AppData\Local\Microsoft\MySQLBackup.vshost.exe_Url_5ar2cuyxbdeg3v0bx5aak4mgjx2jmsbn\1.0.0.0\user.config
line 17) at
System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean
ignoreLocal) at
System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors
schemaErrors) at
System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors() at
System.Configuration.ClientConfigurationSystem.OnConfigRemoved(Object
sender, InternalConfigEventArgs e)
Stacktrace
at
System.Configuration.ClientConfigurationSystem.OnConfigRemoved(Object
sender, InternalConfigEventArgs e) at
System.Configuration.Internal.InternalConfigRoot.OnConfigRemoved(InternalConfigEventArgs
e) at
System.Configuration.Internal.InternalConfigRoot.RemoveConfigImpl(String
configPath, BaseConfigurationRecord configRecord) at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean
getRuntimeObject, Boolean requestIsHere, Object& result, Object&
resultRuntimeObject) at
System.Configuration.BaseConfigurationRecord.GetSection(String
configKey, Boolean getLkg, Boolean checkPermission) at
System.Configuration.BaseConfigurationRecord.GetSection(String
configKey) at
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String
sectionName) at
System.Configuration.ConfigurationManager.GetSection(String
sectionName) at
System.Configuration.ClientSettingsStore.ReadSettings(String
sectionName, Boolean isUserScoped) at
System.Configuration.LocalFileSettingsProvider.GetPropertyValues(SettingsContext
context, SettingsPropertyCollection properties) at
System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider
provider) at
System.Configuration.SettingsBase.GetPropertyValueByName(String
propertyName) at System.Configuration.SettingsBase.get_Item(String
propertyName) at
System.Configuration.ApplicationSettingsBase.GetPropertyValue(String
propertyName) at
System.Configuration.ApplicationSettingsBase.get_Item(String
propertyName) at
MySQLBackup.Properties.Settings.get_app_dbPassword() in
c:\users\chris\documents\visual studio
2010\Projects\MySQLBackup\MySQLBackup\Properties\Settings.Designer.cs:line
43 at MySQLBackup.SqlDatabaseWork..ctor() in
c:\users\chris\documents\visual studio
2010\Projects\MySQLBackup\MySQLBackup\Logic\SqlDatabaseWork.cs:line 25
I've managed to resolve it. I think it was something to do with the user.config file that is created by the application. I deleted the user.config and then told visual studio to rebuild and then it seemed to work.
Thanks for your help
Related
We have multiple servers on which we are hosting an ASP.NET website on IIS. In the website we are trying to fetch values from Azure KeyVault.
In one server for some reason it fails to read the values from Azure KeyVault with an error 'The specified user does not have a valid profile'. We have done investigation, double-checked configuration, permission rights on files - everything looks okay. Also tried to adjust profile in IIS, nothing helped.
Here is the stack trace:
Exception information:
Exception type: ConfigurationErrorsException
Exception message: An error occurred loading a configuration file: The specified user does not have a valid profile. Unable to load 'Microsoft.Configuration.ConfigurationBuilders.Azure, Version=2.0.0.0, Culture=neutral'. (D:\<website_path> line 77)
at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)
at System.Web.Util.AppSettings.GetAppSettingsSection()
at System.Web.Util.AppSettings.EnsureSettingsLoaded()
at System.Web.Util.AppSettings.get_PortableCompilationOutput()
at System.Web.Compilation.BuildManager.RestorePortableCompilationOutputSnapshot()
at System.Web.Compilation.BuildManager.ExecutePreAppStart()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
The specified user does not have a valid profile. Unable to load 'Microsoft.Configuration.ConfigurationBuilders.Azure, Version=2.0.0.0, Culture=neutral'.
at System.Configuration.TypeUtil.GetTypeImpl(String typeString, Boolean throwOnError)
at System.Configuration.ConfigurationBuildersSection.InstantiateBuilder(ProviderSettings ps)
at System.Configuration.ConfigurationBuildersSection.GetBuilderFromName(String builderName)
at System.Configuration.BaseConfigurationRecord.GetSectionXmlReader(String[] keys, SectionInput input)
Has anyone experienced a similar issue?
Any help will be appreciated.
I have answered a similar question here: Function app in Azure could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions'
Do check out - it can be because of same reasons. There may be a nuget package which requires different version of Microsoft.Configuration.ConfigurationBuilders.Azure: 2.0.0. But, you have a version installed which is incompatible.
After doing some debugging we have found the issue. It turned out that under Environment variables for the user we had everything correct, but under environment variables for system we mistyped AZURE_TENTANT_ID. Explains why it was working as a console application (run as current user) and not as a Windows Service (run as system)
I am developing a library (VS 2010, assembly targeted for AnyCPU) and I am getting the following error while stepping over the constructor of XmlValidationReader(..). The parameter for this constructor is an instance of XmlReader(), and the specific XML is syntactically correct, and validates with third party tool.
Error: Catastrophic failure (Exception from HRESULT: 0x8000FFFF
(E_UNEXPECTED))
Exception object: System.Runtime.InteropServices.COMException
Stack trace:
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.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.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.ClientConfigurationHost.RequireCompleteInit(IInternalConfigRecord
record) at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean
getRuntimeObject, Boolean requestIsHere, Object& result, Object&
resultRuntimeObject) at
System.Configuration.BaseConfigurationRecord.GetSection(String
configKey) at
System.Configuration.ConfigurationManager.GetSection(String
sectionName) at
System.Xml.Schema.XmlSchemaCollection..ctor(XmlNameTable nametable)
at System.Xml.XmlValidatingReaderImpl..ctor(XmlReader reader) at
System.Xml.XmlValidatingReader..ctor(XmlReader reader)
I have not changed any security configuration in the system. The specific account under which the assembly is loaded has administrative privileges. Any idea of what could cause this issue? I have run through the web extensively, but in vain.
I have something curious that I am hoping a .Net expert can help me with.
I have a custom configuration section and to get hold of it I do this:
var s = (TestConfigurationSection)ConfigurationManager
.GetSection("testSection");
I run that on my development machine (Windows 7, 64 bit, Windows completely up to date) and it works fine.
I take the exe with that code in and I put it in a directory inside c:\users\public on a Windows Server 2008 R2 machine, open up a command prompt as administrator, run it and I get:
System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for testSection: Request failed. (C:\Users\Public\configtest\AppConfigTestConsoleApplication.exe.Config line 10) ---> System.Security.SecurityException: Request failed.
Now I changed that code to do this:
var config = ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
var s = (TestConfigurationSection) config
.GetSection("testSection");
and it works fine on both machines.
So, I am moderately happy (in as much as my application is working) but that little Gremlin in my head is confused so I ask here:
Why is this the case?
Steps to reproduce
Create a new .net 4 Console application project called AppConfigTestConsoleApplication in visual studio 2010 and replace the contents of Program.cs with the following:
using System;
using System.Configuration;
namespace AppConfigTestConsoleApplication
{
public class TestConfigurationSection : ConfigurationSection
{
[ConfigurationProperty("someSetting")]
public int SomeSetting
{
get { return (int) this["someSetting"]; }
set { this["someSetting"] = value; }
}
}
internal class Program
{
private static void Main()
{
try
{
var s = (TestConfigurationSection) ConfigurationManager
.GetSection("testSection");
Console.WriteLine("First Method worked: " + s.SomeSetting);
}
catch (Exception ex)
{
Console.WriteLine("First method failed");
Console.WriteLine(ex.ToString());
if (ex.InnerException != null)
{
var eex = ex.InnerException as SecurityException;
Console.WriteLine("Action: '{0}'", eex.Action.ToString());
Console.WriteLine("Demanded: '{0}'", eex.Demanded.ToString());
Console.WriteLine("RefusedSet: '{0}'", eex.RefusedSet);
Console.WriteLine("GrantedSet: '{0}'", eex.GrantedSet);
}
try
{
var config = ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
var s = (TestConfigurationSection) config
.GetSection("testSection");
Console.WriteLine("Second Method worked: "
+ s.SomeSetting);
}
catch (Exception x)
{
Console.WriteLine("Even the second method failed!");
Console.WriteLine(ex.ToString());
}
}
}
}
}
Then add an application configuration file and replace the contents with the following:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section
name="testSection"
type="AppConfigTestConsoleApplication.TestConfigurationSection, AppConfigTestConsoleApplication"
requirePermission="false"
allowDefinition="Everywhere" />
</configSections>
<testSection someSetting="10"></testSection>
</configuration>
Compile and run and this is the output I got:
C:\Users\Public\configtest>AppConfigTestConsoleApplication.exe
First method failed
System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for testSection: Request failed. (C:\Users\Public\configtest\AppConfigTestConsoleApplication.exe.Config line 10) ---> System.Security.SecurityException: Request failed.
at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, RuntimeMethodHandleInternal method, RuntimeType parent, UInt32 invocationFlags)
at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, IRuntimeMethodInfo method, RuntimeType parent, UInt32 invocationFlags)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
at System.Configuration.TypeUtil.InvokeCtorWithReflectionPermission(ConstructorInfo ctor)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
at System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
at System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader, String filename, Int32 line)
--- End of inner exception stack trace ---
at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecordsectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at AppConfigTestConsoleApplication.Program.Main()
Action: 'Demand'
Demanded: '<PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"/>
'
RefusedSet: ''
GrantedSet: ''
Second Method worked: 10
Process Monitor
I ran Process Monitor and set the filter like so:
And that left 508 events that are all one of:
NAME NOT FOUND
NO MORE ENTRIES
PATH NOT FOUND
FILE LOCKED WITH ONLY READERS
NO SUCH FILE (just once for C:\Windows\assembly\NativeImages_v4.0.30319_32\mscorlib\93e7df09dacd5fef442cc22d28efec83\mscorlib.ni.dll and C:\Users\Public\configtest\AppConfigTestConsoleApplication.exe.config)
BUFFER OVERFLOW (for HKCU\Control Panel\Desktop\MuiCached\MachinePreferredUILanguages, HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Cache,
Does anyone have any advice perhaps on what filter to set to get to the root cause?
I had this same behavior when the assembly was "blocked" (under the file properties tab). The files were emailed via a zip to the admin. When he saved off the attachment, the block bit was added...just like when you download a file from the internet. After we clear the block, it worked fine.
ConfigurationManager.GetSection(String):
retrieves a configuration file obtained by merging the application configuration file, the local user configuration file, and the roaming configuration file.
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel):
The userLevel parameter determines the location of the configuration file being opened by indicating whether it has no user level (the configuration file is in the same directory as the application)
So, they're opening different files. Take a look using ProcessMonitor to find out which files are being accessed and why an exception occurs and on which file.
I know this is an old thread, but I ran into this problem recently when working with a client and thought I'd post another suggestion. In my case the issue was using a non-static ConfigurationManager method, which can cause a SecurityException under certain specific conditions (app targeting .NET Framework 4 and installed on a network drive, and in this case also Windows Update being disabled). Here is more information on the problem and a hotfix from Microsoft:
https://support.microsoft.com/en-us/help/2580188/fix-system.security.securityexception-occurs-when-a-.net-framework-4-based-application-that-calls-a-static-method-in-the-system.configuration.configurationmanager-class-runs-on-a-network-share
I have IIS 7.5 With one web site
I added new virtual directory and getting Runtime Error
http://ngg-l.com/admin
I tried to added this web application as new web site and everything was ok but it does not working in virtual directory
Is there any advices?
Event viewer warning:
Exception information:
Exception type: ConfigurationErrorsException
Exception message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. (C:\inetpub\wwwroot\Admin\web.config line 49)
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Web.Configuration.RuntimeConfig.GetSectionObject(String sectionName)
at System.Web.Configuration.RuntimeConfig.GetSection(String sectionName, Type type, ResultsIndex index)
at System.Web.Configuration.RuntimeConfig.get_Identity()
at System.Web.HttpContext.SetImpersonationEnabled()
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
Request information:
Request URL: http://ngg-l.com/admin
Request path: /admin
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\NGG
Thread information:
Thread ID: 13
Thread account name: IIS APPPOOL\NGG
Is impersonating: False
Stack trace: at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Web.Configuration.RuntimeConfig.GetSectionObject(String sectionName)
at System.Web.Configuration.RuntimeConfig.GetSection(String sectionName, Type type, ResultsIndex index)
at System.Web.Configuration.RuntimeConfig.get_Identity()
at System.Web.HttpContext.SetImpersonationEnabled()
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
As the error message suggests, you need to convert the virtual directory you have added into an application. Right click it in IIS and you should see the option to do this.
I have a strange error on a specific Windows Server 2008 R2 machine (it works on other 2008 R2 machines) when starting a Windows Service. The service uses Common.Logging and log4net. However, on this specific machine the config section handler for Common.Logging can not be created.
It fails with the following stack traces (formatted for better readability). What surprises me most is the SecurityException. What can cause this?
Does anyone have a clue?
System.TypeInitializationException: The type initializer for
'MyWindowsService.Program' threw an exception.
--->
Common.Logging.ConfigurationException: Failed obtaining configuration for
Common.Logging from configuration section 'common/logging'.
--->
System.Configuration.ConfigurationErrorsException: An error occurred creating
the configuration section handler for common/logging: Request failed.
(C:\Path\MyWindowsService.exe.Config line 7)
--->
System.Security.SecurityException: Request failed.
at System.RuntimeTypeHandle.CreateInstance(
RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis,
Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly,
Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Configuration.TypeUtil.CreateInstanceWithReflectionPermission(Type type)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.Init(
RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.InitWithRestrictedPermissions(
RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
at System.Configuration.RuntimeConfigurationRecord.CreateSectionFactory(
FactoryRecord factoryRecord)
at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(
String configKey, Boolean& isRootDeclaredHere)
--- End of inner exception stack trace ---
It continues with:
at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(
String configKey, Boolean& isRootDeclaredHere)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(
String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject,
Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at Common.Logging.LogManager.<>c__DisplayClass6.<BuildLoggerFactoryAdapter>b__3()
at Common.Logging.Configuration.ArgUtils.<>c__DisplayClass13.<Guard>b__12()
at Common.Logging.Configuration.ArgUtils.Guard[T](Function`1 function,
String messageFormat, Object[] args)
--- End of inner exception stack trace ---
at Common.Logging.Configuration.ArgUtils.Guard[T](Function`1 function,
String messageFormat, Object[] args)
at Common.Logging.LogManager.BuildLoggerFactoryAdapter()
at Common.Logging.LogManager.get_Adapter()
at Common.Logging.LogManager.GetLogger(Type type)
at MyWindowsService.Program..cctor()
--- End of inner exception stack trace ---
at MyWindowsService.Program.Main(String[] args)
My configuration looks like this (the Common.Logging part of it anyway).
<configSections>
<sectionGroup name="common">
<section name="logging"
type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<common>
<logging>
<factoryAdapter
type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter,Common.Logging.Log4net">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
I've seen strange things happening when customers downloaded our zip (ASP.NET application) file from our website. Because of the security feature "This file came from another computer and might be blocked to help protect this computer".
Unblocking the files solved all strange problems, this would explain why this is only happening on some computers with exactly the same configuration.
The Unblock option is shown only when the file is actually blocked in the General tab of the file properties dialog:
You might also check in Visual Studio 2013 if the Project > Properties > Application Tab > Startup Object dropdown is configured to point to the Program class of the windows service. If the value isn't set, the service will fail to start with System.TypeInitializationException.
Seems like you need to give permissions to the service account to access the config file.
EDIT: Actually on second glance it doesn't seem like that's the problem, because it's actually reading the config file, but you should double check the permissions anyways.
UPDATE: This is a known issue with .NET 4.0, but there is a workaround - see http://social.msdn.microsoft.com/Forums/en-US/clr/thread/1e14f665-10a3-426b-a75d-4e66354c5522.
Turned out for me to be because I was running the executable from a network mapped drive which .NET considers unsecure