getting ELMAH working with sql server

1,138 views
Skip to first unread message

Diane Schips

unread,
Mar 8, 2011, 9:52:23 AM3/8/11
to el...@googlegroups.com
I'm trying to add ELMAH to a new site.  I want errors saved in our Sql Server 2008 R2 Web database.  The site is being written in asp.net 4.0, and will run on a 64 bit 2008 R2 server. 

My development machine is windows 7 home.edition.

I added the ELMAH table and stored procedures to the database on the server.  I'm using remotely on my development machine.

On my development machine, I downloaded the v86 version of ELMAH and added the files I needed to to the bin directory.  In the production server, I have the files from the 64 bit version. 

I have a problem and a wired situation.  Here's the weird thing:  On the production server, I can't load any page, even pages I know have no problem, without getting this error: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format.  Yet I have not yet changed the web.config file at all.  There is nothing in there about ELMAH!

My problem is that I have made the necessary changes to the web.config on my development machine.  I try to load a page that I know will get an error, and nothing is added to the database.  Here's my web,config:

<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"/>
        </sectionGroup>
    </configSections>
    <connectionStrings>
    <remove name="LocalSqlServer" />
    <add name="LocalSqlServer" connectionString="Data Source=xx.xx.xx.xx,xxxx;Initial Catalog='xxxx';Integrated Security=False;User ID=xxxx;Password=xxxx;"providerName="System.Data.SqlClient" />
    <add name="wapConnectionString" connectionString="
Data Source=xx.xx.xx.xx,xxxx;Initial Catalog='xxxx';Integrated Security=False;User ID=xxxx;Password=xxxx;"providerName="System.Data.SqlClient" />
    <add name="elmahConnectionString" connectionString="
Data Source=xx.xx.xx.xx,xxxx;Initial Catalog='xxxx';Integrated Security=False;User ID=xxxx;Password=xxxx;"providerName="System.Data.SqlClient" />
</connectionStrings>
    </connectionStrings>
    <system.webServer>
          <validation validateIntegratedModeConfiguration="false"/>
        <modules>
              <add name="Elmah.ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
        </modules>
        <handlers>
              <add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
        </handlers>
     </system.webServer>
     <elmah>
         <security allowRemoteAccess="0" />
         <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="elmahConnectionSyring" />
    </elmah>
    <system.web>
        <customErrors mode="Off" defaultRedirect="GenericErrorPage.aspx">
              <error statusCode="404" redirect="homepage.aspx"/>
        </customErrors>
        <trace configSource="WebTrace.config"/>
        <httpHandlers>
            <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
        </httpHandlers>
        <httpModules>
            <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
        </httpModules>
        <compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
            <assemblies>
                <add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
                <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            </assemblies>
            <buildProviders>
                <add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
            </buildProviders>
        </compilation>
        <authentication mode="Forms">
            <forms loginUrl="~/Account/Login.aspx" timeout="30" slidingExpiration="true" />
        </authentication>
        <caching>
            <outputCacheSettings configSource="Cache.config"></outputCacheSettings>
        </caching>
        <pages theme="Standard"></pages>
        <membership>
            <providers>
              <clear />
              <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="WAP" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="30" passwordStrengthRegularExpression="" />
            </providers>
        </membership>
        <profile>
            <providers>
              <clear />
              <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/" />
            </providers>
        </profile>
        <roleManager enabled="true">
            <providers>
              <clear />
              <add connectionStringName="LocalSqlServer" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
              <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" />
            </providers>
        </roleManager>
        <healthMonitoring enabled="true">
            <eventMappings>
                <clear />
                <add name="All Errors" type="System.Web.Management.WebBaseErrorEvent"  startEventCode="0" endEventCode="2147483647" />
                <add name="Application Events" type="System.Web.Management.WebApplicationLifetimeEvent" startEventCode="0" endEventCode="2147483647"/>
            </eventMappings>
            <providers>
                <clear />
                <add connectionStringName="LocalSqlServer" maxEventDetailsLength="1073741823" buffer="false" name="SqlWebEventProvider" type="System.Web.Management.SqlWebEventProvider" />
            </providers>
            <rules>
                <clear />
                <add name="All Errors Default" eventName="All Errors" provider="SqlWebEventProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:00:00" />
                <add name="Application Events Default" eventName="Application Events"
                   provider="SqlWebEventProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:00:00" />
            </rules>
        </healthMonitoring>
    </system.web>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
    </system.webServer>
    <system.net>
        <mailSettings>
          
        </mailSettings>
    </system.net>
</configuration>


James_2JS

unread,
Mar 8, 2011, 10:36:03 AM3/8/11
to ELMAH
Hi Diane,

Simply delete System.Data.SQLite.DLL from your bin directory... you
don't need it!

Cheers,

James

On Mar 8, 2:52 pm, Diane Schips <wapfo...@gmail.com> wrote:
> I'm trying to add ELMAH to a new site.  I want errors saved in our Sql
> Server 2008 R2 Web database.  The site is being written in asp.net 4.0, and
> will run on a 64 bit 2008 R2 server.
>
> My development machine is windows 7 home.edition.
>
> I added the ELMAH table and stored procedures to the database on the
> server.  I'm using remotely on my development machine.
>
> On my development machine, I downloaded the v86 version of ELMAH and added
> the files I needed to to the bin directory.  In the production server, I
> have the files from the 64 bit version.
>
> I have a problem and a wired situation.  Here's the weird thing:  On the
> production server, I can't load any page, even pages I know have no problem,
> without getting this error: *Could not load file or assembly
> 'System.Data.SQLite' or one of its dependencies. An attempt was made to load
> a program with an incorrect format.*  Yet I have not yet changed the

Diane Schips

unread,
Mar 8, 2011, 12:57:44 PM3/8/11
to el...@googlegroups.com
Thank you.  That did it.

Now, on my development machine, why isn't the table being populated when an error occurs?

Diane

--
You received this message because you are subscribed to the Google Groups "ELMAH" group.
To post to this group, send email to el...@googlegroups.com.
To unsubscribe from this group, send email to elmah+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/elmah?hl=en.


James_2JS

unread,
Mar 8, 2011, 4:30:42 PM3/8/11
to ELMAH
Sorry Diane... I missed the bit about your dev machine not logging.

OK... a couple of questions....

1) is your prod server logging OK... or have we just fixed the could
not load assembly error??
2) How are you running on your dev machine??? IIS (if so which
version), Cassini??

Thanks,

James

On Mar 8, 5:57 pm, Diane Schips <wapfo...@gmail.com> wrote:
> Thank you.  That did it.
>
> Now, on my development machine, why isn't the table being populated when an
> error occurs?
>
> Diane
>

James_2JS

unread,
Mar 8, 2011, 4:43:23 PM3/8/11
to ELMAH
Hi Diane,

I also meant to ask if you can do the following:

1) Navigate to elmah.axd... look at the text at the bottom... what
does it say about the provider?? Is it SqlErrorLog??
2) Navigate to elmah.axd/test - this should generate a test exception
3) Navigate back to elmah.axd... can you see your test exception now??

Thanks,

James
> ...
>
> read more »

Diane Schips

unread,
Mar 8, 2011, 8:52:16 PM3/8/11
to el...@googlegroups.com
If I run elmah.axd on the development system, I get the following error:
Elmah.ApplicationException: Connection string is missing for the SQL error log.

I sent you my web.config file.  I do have the connection string in there.  But something is clearly wrong. 

On the server, I'm getting an error from the modules line in the web.config file:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

I'm not getting that error on the development system.  I'm getting very confused!

Diane



--

Diane Schips

unread,
Mar 8, 2011, 9:00:33 PM3/8/11
to el...@googlegroups.com
Never mind my last email on the sever error.  It's resolved.  Both the server and development system are giving me the same connection string missing error.

Diane

James_2JS

unread,
Mar 9, 2011, 4:32:53 AM3/9/11
to ELMAH
Hi Diane,

Looks like a typo to me:

<connectionStrings>
<add name="elmahConnectionString" ... />
</connectionStrings>
<elmah>
<errorLog type="Elmah.SqlErrorLog, Elmah"
connectionStringName="elmahConnectionSyring" />
</elmah>

See how you've got Syring instead of String??!

Also, there are two </connectionStrings> closing tags in your sample
above... maybe that's a copy and paste error.

Cheers,

James


On Mar 9, 2:00 am, Diane Schips <wapfo...@gmail.com> wrote:
> Never mind my last email on the sever error.  It's resolved.  Both the
> server and development system are giving me the same connection string
> missing error....
>
> read more »
>
> Diane
>
>
>
> On Tue, Mar 8, 2011 at 8:52 PM, Diane Schips <wapfo...@gmail.com> wrote:
> > If I run elmah.axd on the development system, I get the following error:
> > * *Elmah.ApplicationException: Connection string is missing for the SQL
> > error log.
>
> > I sent you my web.config file.  I do have the connection string in there.
> > But something is clearly wrong.
>
> > On the server, I'm getting an error from the modules line in the web.config
> > file:
>
> > <system.webServer>
> >     <modules runAllManagedModulesForAllRequests="true" />
> > </system.webServer>
>
> > I'm not getting that error on the development system.  I'm getting very confused!
>
> > Diane
>
> >> > > > >         </roleManager>- Hide quoted text -
>
> - Show quoted text -

Diane Schips

unread,
Mar 9, 2011, 9:15:24 AM3/9/11
to el...@googlegroups.com
It was the typo.  It works on both machines.  Thank you!

Diane


--
Reply all
Reply to author
Forward
0 new messages