I am unable to use the NLog MessageBox target in a WinForm application. The config file indicates the xsi:type is invalid. When I run the program I get this error:
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'Catalog.Form2' threw an exception.
Source=Catalog
StackTrace:
at Catalog.Form2..ctor() in L:\SourceCode\Catalog\Catalog\Form2.cs:line 29
at Catalog.Program.Main() in L:\SourceCode\Catalog\Catalog\Program.cs:line 16
Inner Exception 1:
NLogConfigurationException: Exception when parsing L:\SourceCode\Catalog\Catalog\bin\Debug\NLog.config.
Inner Exception 2:
ArgumentException: Target cannot be found: 'MessageBox'
My config file contains this:
<targets>
<target name="errors" xsi:type="MessageBox" layout="${message}" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="errors" />
</rules>
If I change the target to "Console" everything works. Why does MessageBox not work?
NLog 4.5.11,
NLog.Schema 4.5.11,
.NET Framwork 4.7.2,
VS 2017 Pro (15.9.7)
For the MessageBox target you need to install the NLog.Windows.Forms NuGet package.
See also: https://nlog-project.org/config/?tab=targets&search=messagebox
Related
This error happened to me recently when I try to build any project,
Android resource compilation failed
E:\Android Projects\BarcodReader\app\src\main\res\drawable\ic_launcher_background.xml:12: error: not well-formed (invalid token).
E:\Android Projects\BarcodReader\app\src\main\res\drawable\ic_launcher_background.xml: error: file failed to compile.
and here's the file ic_launcher_background.xml
<component name="libraryTable">
<library name="Gradle: junit:junit:4.12#jar">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/a6c32b40bf3d76eca54e3c601e5d1470c86fcdfa/junit-4.12-sources.jar!/" />
</SOURCES>
</library>
</component>
when I hover over the file it shows this error
Attribute is missing the Android namespace prefix,
Inspection info:Most Android views have attributes in the Android namespace. When referencing these attributes you must include the namespace prefix, or your attribute will be interpreted by aapt as just a custom attribute. Similarly, in manifest files, nearly all attributes should be in the android: namespace. Issue id: MissingPrefix
what might be causing this error?.
That ic_launcher_background.xml is a IDEA file and not an Android resource file.
Just replace it with whatever valid Android resource XML file and it should build.
We are having trouble creating our app pools using wix. This problem happens only on server 2016 or iis version >10.
This is the error with verbose log turned on.
Its complaining about path not found or trying to access a path that has not been created or does not have permissions. The installer fails with rollback.
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe" -norestart -s W3SVC/1/ROOT/INFO-SUITE
CAQuietExec: Microsoft (R) ASP.NET RegIIS version 4.0.30319.0
CAQuietExec: Administration utility to install and uninstall ASP.NET on the local machine.
CAQuietExec: Copyright (C) Microsoft Corporation. All rights reserved.
CAQuietExec: Start registering ASP.NET (4.0.30319.0) recursively at W3SVC/1/ROOT/MyApplication.
CAQuietExec: Installation stopped because the specified path (W3SVC/1/ROOT/MyApplication) is invalid.
CAQuietExec: Error 0x80070001: Command line returned an error.
CAQuietExec: Error 0x80070001: CAQuietExec Failed
This is the wix xml which creates the app pool.The same installer msi works on windows 8. The IISMajorVersion is 10 according to the log. I also ran dsim enable feature IIS-ASPNET45 to make sure Asp.net is registered. I also checked the registry. THis is only when the wix creates the app pools. We don't have a problem when its an upgrade or we manaully create the app pools.
<Fragment>
<PropertyRef Id="IISMAJORVERSION" />
<Component Id="Component.WebServer.WebServices.IISSite.v10" Guid="F73DACBB-EF8B-4C8E-8B6A-6610670D991F" Directory="WEBSERVICES_INSTALLLOCATION">
<Condition><![CDATA[IISMAJORVERSION >= 10]]> </Condition>
<CreateFolder />
<iis:WebAppPool Id="WebAppPool.WebServices.IISSite.v10"
Name="[WEBSERVICESSERVERINFO_IISAPPNAME]"
ManagedRuntimeVersion="v4.0"
ManagedPipelineMode="integrated"
Identity="networkService"
IdleTimeout="0" />
<iis:WebVirtualDir Id="WebVirtualDir.WebServices.IISSite.v10"
Directory="WEBSERVICES_INSTALLLOCATION"
Alias="[WEBSERVICESSERVERINFO_IISAPPNAME]"
WebSite="WebSite">
<iis:WebDirProperties Id="WebDirProperties.WebServices.IISSite.v10"
Execute="yes"
Script="yes"
Read="yes"
WindowsAuthentication="yes"
AnonymousAccess="yes"
IIsControlledPassword="yes" />
<iis:WebApplication Id="WebApplication.WebServices.IISSite.v10"
Name="[WEBSERVICESSERVERINFO_IISAPPNAME]"
WebAppPool="WebAppPool.WebServices.IISSite.v10" />
</iis:WebVirtualDir>
</Component>
</Fragment>
<ComponentGroupRef Id="ComponentGroup.WebServer.WebServices.Files" />
<ComponentRef Id="Component.WebServer.WebServices.SetWebConfig" />
<ComponentRef Id="Component.WebServer.WebServices.Certificates" />
<ComponentRef Id="Component.WebServer.WebServices.IISSite.v10" />
I took care of my own problem. The condition had to be = "10"]]> instead of = 10]]>
I'm developing API where I use NLog for logging incoming requests and their responses.
Occasionally I'm getting following error on my server
Application: w3wp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileLoadException
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32, IntPtr)
at NLog.Internal.FileAppenders.BaseFileAppender.WindowsCreateFile(System.String, Boolean)
at NLog.Internal.FileAppenders.BaseFileAppender.TryCreateFileStream(Boolean)
at NLog.Internal.FileAppenders.BaseFileAppender.CreateFileStream(Boolean)
at NLog.Internal.FileAppenders.RetryingMultiProcessFileAppender.Write(Byte[])
at NLog.Targets.FileTarget.WriteToFile(System.String, NLog.LogEventInfo, Byte[], Boolean)
at NLog.Targets.FileTarget.ProcessLogEvent(NLog.LogEventInfo, System.String, Byte[])
at NLog.Targets.FileTarget.FlushCurrentFileWrites(System.String, NLog.LogEventInfo, System.IO.MemoryStream, System.Collections.Generic.List`1<NLog.Common.AsyncContinuation>)
at NLog.Targets.FileTarget.Write(NLog.Common.AsyncLogEventInfo[])
at NLog.Targets.Target.WriteAsyncLogEvents(NLog.Common.AsyncLogEventInfo[])
at NLog.Targets.Wrappers.AsyncTargetWrapper.ProcessPendingEvents(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.TimerQueueTimer.CallCallback()
at System.Threading.TimerQueueTimer.Fire()
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
My nlog.config looks like this
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true" throwExceptions="true">
<variable name="logPath" value="${basedir}/App_Data/Logs"/>
<variable name="rowFormatInfo" value="${longdate} | ${level:uppercase=true} | ${message} | Thread: ${threadid}" />
<targets async="true">
<target name="traceFile" xsi:type="AsyncWrapper" overflowAction="Grow">
<target xsi:type="File" fileName="${logPath}/${shortdate}.trace.log" layout="${rowFormatInfo}" />
</target>
</targets>
<rules>
<logger name="*" minlevel="Trace" maxlevel="Debug" writeTo="traceFile" />
</rules>
</nlog>
In my opinion the problem lies with the fact that I'm using async wrapper which can result into mix of several threads trying to access the log file.
Is there any workaround to prevent such errors occurring in the peak times where my API has to deal with tens of requests per second? I don't think that switching to sync logging helps as the API runs in several concurrent threads itself.
Thanks for suggestions
Multiple threads within the same application should not give any issues, as they will just write to the async-queue (and not the file). But if you have multiple applications writing to the same file, then you can get issues.
You can also get this issue if you have an external application can monitors the log-file and tries to copy the contents somewhere else (Ex. SPLUNK).
If you don't have multiple applications writing to the same file, then just add these options to the file-target:
<target xsi:type="File"
fileName="${logPath}/${shortdate}.trace.log"
layout="${rowFormatInfo}"
keepFileOpen="true"
concurrentWrites="false" />
If you do have multiple Applications/AppDomains writing to the same file, then upgrade to latest NLog (currently 4.4.10) and use these options on the file-target:
<target xsi:type="File"
fileName="${logPath}/${shortdate}.trace.log"
layout="${rowFormatInfo}"
keepFileOpen="true"
concurrentWrites="true" />
While creating local cluster with latest service fabric SDK, I got following errors with Visual Studio 2013 Update 5 while it works fine with Visual Studio 2015 Update 3:
Cluster manifest validation failed with exception System.ArgumentException: Error occurs in section Federation, parameter System.
Fabric.Management.ServiceModel.SettingsOverridesTypeSectionParameter...
OR
Cluster manifest validation failed with exception System.ArgumentException: Section FaultAnalysisService found in cluster manifest but not Configurations.csv in system.fabric.management.dll
What I did to fix it?
If you closely look into error, you will find that following two files settings are not compatible.
C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code\Configurations.csv
and
C:\Program Files\Microsoft SDKs\Service Fabric\ClusterSetup\NonSecure\ClusterManifestTemplate.xml
Just disable following in ClusterManifestTemplate.xml:
<Section Name="Federation">
<Parameter Name="NodeIdGeneratorVersion" Value="V3" />
<!-- <Parameter Name="UnresponsiveDuration" Value="0" /> -->
</Section>
and
<!-- <Section Name="FaultAnalysisService">
<Parameter Name="TargetReplicaSetSize" Value="5" />
<Parameter Name="MinReplicaSetSize" Value="3" />
</Section> -->
I got below log error when I publish my ASP.NET 5 RC1 project to the IIS server.
Failed to initialize runtime 0x
IIS 7.5, installed 64 bit HTTP Platform Handler and followed below instructions
docs.asp.net/en/latest/publishing/iis.html
I have the project working well locally with VS2015 and IIS Express.
Any idea about this error?
Updated approot folder structure:
Runtimes folder:
Web.config in wwwroot(auto-generated):
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*"
modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="..\approot\web.cmd"
arguments=""
stdoutLogEnabled="false"
stdoutLogFile="..\logs\stdout.log"
startupTimeLimit="3600"
forwardWindowsAuthToken="true"></httpPlatform>
</system.webServer>
</configuration>
web.cmd in approot(auto-generated):
#echo off
SET DNX_FOLDER=dnx-clr-win-x64.1.0.0-rc1-update1
SET "LOCAL_DNX=%~dp0runtimes\%DNX_FOLDER%\bin\dnx.exe"
IF EXIST %LOCAL_DNX% (
SET "DNX_PATH=%LOCAL_DNX%"
)
for %%a in (%DNX_HOME%) do (
IF EXIST %%a\runtimes\%DNX_FOLDER%\bin\dnx.exe (
SET "HOME_DNX=%%a\runtimes\%DNX_FOLDER%\bin\dnx.exe"
goto :continue
)
)
:continue
IF "%HOME_DNX%" NEQ "" (
SET "DNX_PATH=%HOME_DNX%"
)
IF "%DNX_PATH%" == "" (
SET "DNX_PATH=dnx.exe"
)
#"%DNX_PATH%" --project "%~dp0src\Pms.Client.Web" --configuration Debug web %*
Tried to use WinDbg the dnx.exe on server and got below error code. Hope someone is able to interpret for me. Thanks!
ModLoad: 000007fe`f96d0000 000007fe`fa035000 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
ModLoad: 000007fe`fa530000 000007fe`fa601000 C:\Windows\system32\MSVCR100_CLR0400.dll
(668.126c): Unknown exception - code 04242420 (first chance)
ModLoad: 000007fe`ee610000 000007fe`ef889000 C:\Windows\assembly\NativeImages_v4.0.30319_64\mscorlib\7f2c596fb4811af2d6fc7a5132c75d10\mscorlib.ni.dll
ModLoad: 000007fe`f5510000 000007fe`f5524000 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\nlssorting.dll
ModLoad: 000007fe`fc850000 000007fe`fc868000 C:\Windows\system32\CRYPTSP.dll
ModLoad: 000007fe`fc3b0000 000007fe`fc3f7000 C:\Windows\system32\rsaenh.dll
ModLoad: 000007fe`fcd20000 000007fe`fcd2f000 C:\Windows\system32\CRYPTBASE.dll
ModLoad: 000007fe`f4d90000 000007fe`f4f03000 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clrjit.dll
(668.126c): C++ EH exception - code e06d7363 (first chance)
(668.126c): CLR exception - code e0434352 (first chance)
(668.126c): C++ EH exception - code e06d7363 (first chance)
(668.126c): CLR exception - code e0434352 (first chance)
(668.126c): C++ EH exception - code e06d7363 (first chance)
(668.126c): CLR exception - code e0434352 (first chance)
(668.126c): C++ EH exception - code e06d7363 (first chance)
(668.126c): CLR exception - code e0434352 (first chance)
ntdll!ZwTerminateProcess+0xa:
Figured out this issue. The answer is simple enough, but the story is long.
I just installed .NET Framework 4.5.1 on server and the error has gone.
Then I got another well-known issue about
"
you must add reference assembly to System.Runtime
"
Tried every way I found in this site and gave up eventually. The magic came out when I checked option to build binaries when publishing:
image here.
Just post this workaround for peoples that may encounter similar situation. Still I am not very clear about underlying things.