Tag Archives: ASP.Net

DbProviderFactories section can only appear once per config file

Recently I came across this error while doing some housekeeping and updating some old websites to .Net 4.0:

HttpException: Failed to generate code. The ‘DbProviderFactories’ section can only appear once per config file.

The problem is with the machine.config file in the .Net 4.0 folder on the hosting server. For some reason, an additional <DbProviderFactories /> element is present and needs to be removed.

  • On the affected server, open C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config in your favorite editor (Also might want to check C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config)
  • Scroll down about halfway to the <system.data> section
  • Look for the <DbProviderFactories> element, which should already contain various connection providers. Right after the closing </DbProviderFactories> element there is most likely another empty element that looks like this:
    <system.data>
            <DbProviderFactories>
                <add name="Provider Name" invariant="Something" description=".NET Framework Data Provider for Something" type="Type, Desc, Version, Culture=neutral, PublicKeyToken=token" />
            </DbProviderFactories>
            <DbProviderFactories />
        </system.data>

    Delete the <DbProviderFactories /> line right before the closing <system.data>. It should look like this now:

    
            <DbProviderFactories>
                <add name="Provider Name" invariant="Something" description=".NET Framework Data Provider for Something" type="Type, Desc, Version, Culture=neutral, PublicKeyToken=token" />
            </DbProviderFactories>
        </system.data>
  • Save the file and restart IIS on the affected server

That should solve that issue. In rare cases I’ve had to restart the entire server, but usually bouncing IIS afterwards is good enough. Hope this helps!

Eric Oszakiewski

Eric Oszakiewski is a professional software developer based in Scottsdale, AZ with over 36 years of IT experience, and 19 years Native American Gaming experience. He is currently working as a Sr .Net/SharePoint Development Lead for General Motors, and also as a consultant.

More Posts

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

Access Denied due to invalid credentials in IIS7

I’ve been having issues with a few ASP.Net websites that we’re moving to IIS7 at work.  It didn’t happen to app of them, but to some it would prompt for network credentials, then throw an HTTP 401.1 “Access Denied Due To Invalid Credentials” error.  We’d hunt around for solutions and never find anything that worked.  Finally I tripped over the answer this morning:

Open the website in IIS, and under the IIS header double-click on Authentication to open.  Click and select Windows Authentication, then click “Providers” on the right under Actions.  Make sure NTLM is above Negotiate and click OK.

Problem solved!  Hope this helps someone!

Eric Oszakiewski

Eric Oszakiewski is a professional software developer based in Scottsdale, AZ with over 36 years of IT experience, and 19 years Native American Gaming experience. He is currently working as a Sr .Net/SharePoint Development Lead for General Motors, and also as a consultant.

More Posts

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

Scott Guthrie returns to Arizona!

Just got the message, @ScottGu is returning to Arizona Friday, April 22nd. Details to follow, but save the date!

UPDATE: Registration form is to the right! Sign up today!

Eric Oszakiewski

Eric Oszakiewski is a professional software developer based in Scottsdale, AZ with over 36 years of IT experience, and 19 years Native American Gaming experience. He is currently working as a Sr .Net/SharePoint Development Lead for General Motors, and also as a consultant.

More Posts

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

7 Free .Net Development and Architecture e-Books!

Thank you to MSDN for re-distributing Anoop’s blog post on these seven FREE .Net development e-Books! The last group are Scribd from DZone, and you have to have a DZone account and be logged in to download, but the rest are freely downloadable from the websites. Here’s the title and link to each:

Foundations of Programming
Microsoft Application Architecture Guide, 2nd Ed.
Rob Miles C# YellowBook 2010
Threading in C#
Improving .Net Application Performance and Stability
Applying Design Patterns

DZone Reference Cards
Getting Started With WCF 4.0
Getting Started with Silverlight + Expression Blend
Essential F#

Enjoy the freebies!

Eric Oszakiewski

Eric Oszakiewski is a professional software developer based in Scottsdale, AZ with over 36 years of IT experience, and 19 years Native American Gaming experience. He is currently working as a Sr .Net/SharePoint Development Lead for General Motors, and also as a consultant.

More Posts

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

Scott Guthrie is returning to Phoenix!

Mark the calendar, Microsoft’s own Scott Guthrie is returning to Phoenix on May 10th at the Scottsdale Resort and Conference Center. From 8am-6pm, we’ll get to enjoy the wisdom and insight of one of the industry’s top professionals, along with great speakers such as Scott Hanselman and Jeffrey Palermo! There’s a link on the side along with a countdown, courtesy of @ScottCate. Seats are filling up quickly!

Eric Oszakiewski

Eric Oszakiewski is a professional software developer based in Scottsdale, AZ with over 36 years of IT experience, and 19 years Native American Gaming experience. He is currently working as a Sr .Net/SharePoint Development Lead for General Motors, and also as a consultant.

More Posts

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube