My WindowsForms application is not compiling. The error is as follows:
InvalidOperatinException was unhandled: SetCompatibleTextRenderingDefault must be called before the first IWin32Window object is created in the application.
using System.Linq;
using System.Windows.Forms;
using NLog;
namespace SQLSMODemo
{
static class Program
{
private static Logger logger = LogManager.GetCurrentClassLogger();
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
logger.Trace("Sample trace message");
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}Nlog.config:
<?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">
<!-- make sure to set 'Copy To Output Directory' option for this file -->
<!-- go to http://nlog-project.org/wiki/Configuration_file for more information -->
<targets>
<target name="logfile" xsi:type="File" fileName="c:\temp\file.txt" />
<target xsi:type="RichTextBox" name="outputbox" layout="${longdate}|${level:uppercase=true}|${logger}|${message}" controlName="richTextBox1" formName="Form1" />
</targets>
<rules>
<logger name="UI" minlevel="Trace" writeTo="outputbox" />
<logger name="*" minlevel="Trace" writeTo="logfile" />
</rules>
</nlog>Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
logger.Trace("Sample trace message");
Application.Run(new Form1());
--
You received this message because you are subscribed to the Google Groups "NLog-Users" group.
To post to this group, send email to nlog-...@googlegroups.com.
To unsubscribe from this group, send email to nlog-users+...@googlegroups.com.
Visit this group at http://groups.google.com/group/nlog-users?hl=en.