I'm trying to use ELMAH in my console app. I'm just trying to learn the ropes so pardon my .net inexperience. I just want to create a very simple console app & use ELMAH for logging in XML files. I have downloaded & installed "Elmah on XML Log" from NuGet. So, it is active in my references folder, I think. I've followed the instructions in this link:
Of course I've modified it slightly to use XML.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah"/>
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah"/>
<section name="errorTweet" requirePermission="false" type="Elmah.ErrorTweetSectionHandler, Elmah"/>
</sectionGroup>
</configSections>
<elmah>
<security allowRemoteAccess="yes" />
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="C:\temp\elmah_logs\" />
</elmah>
<system.web>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
</httpModules>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
</system.web>
<location path="elmah.axd">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
But in my main program, I can't access the reference and start using ELMAH. Here's my very simple code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using Elmah; // Complains that missing a directive or assembly
namespace Test_004
{
class Program
{
static void Main(string[] args)
{
int y = 4;
int z = 0;
try
{
var x = y / z;
}
catch (Exception ex) ErrorSignal.FromCurrentContext().Raise(ex); // because of above, this fails
}
}
}
What am I missing here? Thanks in advance from .Net n00bie.
Maybe, it the following errors might shed some light:
Error 1 The type or namespace name 'Elmah' could not be found (are you missing a using directive or an assembly reference?)
Warning 2 The referenced assembly "Elmah" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. Test_004
Warning 3 The referenced assembly "Elmah" could not be resolved because it has a dependency on "System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. Test_004