Closed GoogleCodeExporter closed 8 years ago
If you had the PDB deployed too, we could have the exact offending line. In
absence of that, I'm guessing it's [line #489 of ErrorMailModule.cs]([1]). Are
you using a custom subject setting in configuration? The subject can have {0}
and {1} tokens that get replaced with error message and type. However, you have
to escape { and } otherwise if they appear in the subject format. Could you
check if that's not causing this issue?
[1]
https://code.google.com/p/elmah/source/browse/src/Elmah/ErrorMailModule.cs?repo=
1x&name=v1.2-sp2#489
Original comment by azizatif
on 23 Aug 2013 at 3:31
How do I get the PDB for Elmah? I've added the reference via NuGet, and it
doesn't seem to download the PDB.
These are the settings for ELMAH (some details XXX-ed out)
<elmah>
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/errors/" />
<security allowRemoteAccess="1" />
<errorMail from="xxxxx@xxxxxxx.com" to="xxxxx@xxxxxxx.com" subject="{Error_Encountered} [XXXXX XXXXX]"
async="true" smtpPort="25" smtpServer="mail.xxxxxxxxxx.com.mt" userName="xxxxxxxxxxx" password="xxxxxxxxxxxxx" />
</elmah>
Does the `subject` attribute mean I am using a custom subject? Could it be
that it is because I am using the curly brackets? If so, I would suggest adding
a more descriptive error message to it, by catching it and saying what the
problem might be. Future users checking the logs could immediately get a
better idea what is wrong.
Original comment by k...@casasoft.com.mt
on 23 Aug 2013 at 3:43
The PDB can be obtained from the Downloads[1] section in the following zip:
https://code.google.com/p/elmah/downloads/detail?name=ELMAH-1.2-sp2-bin-core.zip
You can copy it out and place it next to Elmah.dll in your web site bin
directory. However, looking at your settings, the problem seems to be clear.
The braces around {Error Encountered} are throwing String.Format off. The
following:
string.Format("{Error_Encountered} [XXXXX XXXXX]")
will throw FormatException. You need to escape the braces like this:
string.Format("{{Error_Encountered}} [XXXXX XXXXX]")
Try changing the subject attribute to read like this:
subject="{{Error_Encountered}} [XXXXX XXXXX]"
Does it help?
[1] https://code.google.com/p/elmah/wiki/Downloads?tm=2
Original comment by azizatif
on 23 Aug 2013 at 3:56
I am testing it out, and it seems that it did work. It wasn't evident to me
that this was using the .Net string.Format, hence the {} mean something. I
don't have the need to use {}, so I've now replaced them with
(Error_Encountered) and problem solved.
Maybe you could add a try-catch to it, and a more appropriate message would be
shown?
Thanks a lot for your help, much appreciated!
Original comment by k...@casasoft.com.mt
on 23 Aug 2013 at 4:23
Closing this as Invalid as it's not problem is external (String.Format rules)
though point taken about it not being clear that subject is a format as opposed
to plain text.
Original comment by azizatif
on 23 Aug 2013 at 4:33
Agreed, and thanks once again for your help.
Original comment by k...@casasoft.com.mt
on 23 Aug 2013 at 4:48
Original issue reported on code.google.com by
k...@casasoft.com.mt
on 23 Aug 2013 at 2:57