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.
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 created a new .NET Core 2.1 Console project.
I added Config.xml:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="MyLocalSQLServer" connectionString="Initial Catalog=aspnetdb;data source=localhost;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
In Program.cs:
class Program
{
static void Main(string[] args)
{
Console.WriteLine(ConfigurationManager.ConnectionStrings["MyLocalSQLServer"]);
}
}
With aspnet_regiis, I encrypted the configuration file:
RENAME "C:\repos\ConsoleApp7\bin\Debug\netcoreapp2.1\ConsoleApp.dll.config" web.config
aspnet_regiis -pef "connectionStrings" "C:\repos\ConsoleApp\bin\Debug\netcoreapp2.1"
RENAME "C:\repos\ConsoleApp7\bin\Debug\netcoreapp2.1\web.config" ConsoleApp.dll.config
Finally, I ran the app:
dotnet "C:\repos\ConsoleApp7\bin\Debug\netcoreapp2.1\ConsoleApp.dll"
I got the error:
Unhandled Exception: System.Configuration.ConfigurationErrorsException:
Failed to decrypt using provider 'RsaProtectedConfigurationProvider'.
Error message from the provider: Operation is not supported on this platform.
---> System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Configuration.RsaProtectedConfigurationProvider.Decrypt(XmlNode encryptedNode)
at System.Configuration.ProtectedConfigurationSection.DecryptSection(String encryptedXml, ProtectedConfigurationProvider provider)
at System.Configuration.BaseConfigurationRecord.DecryptConfigSection(ConfigXmlReader reader, ProtectedConfigurationProvider protectionProvider)
--- End of inner exception stack trace ---
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.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.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.get_ConnectionStrings()
at ConsoleApp7.Program.Main(String[] args)
This trick works to encrypt app.config with the old .NET Framework, but it isn't supported by .NET Core.
The purpose of this is to test migration from .NET Framework to .NET Core.
How can I encrypt app.config in .NET Core?
my web app stop working after running well couple of days with below exception in the log file.
And it will start to work after I saved the web.config file even without changing anything in it.
Then stop working again with another random days running well.
Any suggestions?
Thanks.
2017-06-15 17:00:19,120 [8] Orchard.Environment.DefaultOrchardHost - (null) - A tenant could not be started: Default
(null)
System.Configuration.ConfigurationErrorsException: The configuration file has been changed by another program. (D:\home\site\wwwroot\Config\Sites.config)
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 Autofac.Configuration.SectionHandler.Deserialize(String configurationFile, String configurationSection)
at Orchard.Environment.ShellBuilders.ShellContainerFactory.<>c__DisplayClass3_0.b__2(ContainerBuilder builder)
at Autofac.Core.Lifetime.LifetimeScope.CreateScopeRestrictedRegistry(Object tag, Action1 configurationAction) at Autofac.Core.Lifetime.LifetimeScope.BeginLifetimeScope(Object tag, Action1 configurationAction)
at Orchard.Environment.ShellBuilders.ShellContextFactory.CreateShellContext(ShellSettings settings)
at Orchard.Environment.DefaultOrchardHost.b__31_1(ShellSettings settings)
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 get the error at the end when I try to start a project I'm working on from Visual Studio. It worked fine until a few hours ago. After some minor unrelated changes it stopped working when starting from Visual Studio. It works fine when run from explorer. Even old version vom revision control (where this part of the code is exactly the same and has worked without any problems) behave the same way so it doesn't seem to be a problem in my code.
The code at Program.cs:line 14 is the following:
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
Any ideas on how to solve this?
System.TypeInitializationException was unhandled
Message=The type initializer for ...' threw an exception.
Source=...
TypeName=...
StackTrace:
at ....Main(String[] args)
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.Runtime.InteropServices.SEHException
Message=External component has thrown an exception.
Source=mscorlib
ErrorCode=-2147467259
StackTrace:
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.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.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at NLog.Config.XmlLoggingConfiguration.get_AppConfig()
at NLog.LogFactory.get_Configuration()
at NLog.LogFactory.GetLogger(LoggerCacheKey cacheKey)
at NLog.LogFactory.GetLogger(String name)
at NLog.LogManager.GetCurrentClassLogger()
at ....Program..cctor() in C:\...\Program.cs:line 14
InnerException:
Check the following post on the Avira support site for details of the problem and a work around. The issue is related to the last product update:
http://www.avira.com/en/support-for-business-knowledgebase-detail/kbid/805