Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting up ELMAH on console apps for XML files
    primarykey
    data
    text
    <p>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 &amp; use ELMAH for logging in XML files. I have downloaded &amp; installed <a href="http://nuget.org/packages/elmah.xml" rel="nofollow">"Elmah on XML Log"</a> from NuGet. So, it is active in my references folder, I think. I've followed the instructions in <a href="http://naspinski.net/post/Installing-ELMAH-for-simple-error-logging.aspx" rel="nofollow">this link</a>:</p> <p>Of course I've modified it slightly to use XML. </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;sectionGroup name="elmah"&gt; &lt;section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah"/&gt; &lt;section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" /&gt; &lt;section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" /&gt; &lt;section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah"/&gt; &lt;section name="errorTweet" requirePermission="false" type="Elmah.ErrorTweetSectionHandler, Elmah"/&gt; &lt;/sectionGroup&gt; &lt;/configSections&gt; &lt;elmah&gt; &lt;security allowRemoteAccess="yes" /&gt; &lt;errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="C:\temp\elmah_logs\" /&gt; &lt;/elmah&gt; &lt;system.web&gt; &lt;httpModules&gt; &lt;add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/&gt; &lt;/httpModules&gt; &lt;httpHandlers&gt; &lt;add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" /&gt; &lt;/httpHandlers&gt; &lt;/system.web&gt; &lt;location path="elmah.axd"&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;deny users="?"/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; </code></pre> <p></p> <p>But in my main program, I can't access the reference and start using ELMAH. Here's my very simple code:</p> <pre><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 } } } </code></pre> <p>What am I missing here? Thanks in advance from .Net n00bie.</p> <p>Maybe, it the following errors might shed some light:</p> <blockquote> <p>Error 1 The type or namespace name 'Elmah' could not be found (are you missing a using directive or an assembly reference?)</p> <p>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</p> <p>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</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload