locked
InvalidCastException - Microsoft.Practices.EnterpriseLibrary.Common RRS feed

  • Question

  • User-1934285710 posted

    Hi Everyone

    When trying to debug an ASP.NET application I keep getting an exception thrown when this line of code is executed - 

    Database db = DatabaseFactory.CreateDatabase();

    The exception detail is as follows -

    [A]Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection cannot be cast to [B]Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection.

    Type A originates from 'Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\assembly\GAC_MSIL\Microsoft.Practices.EnterpriseLibrary.Common\5.0.414.0__31bf3856ad364e35\Microsoft.Practices.EnterpriseLibrary.Common.dll'. Type B originates from 'Microsoft.Practices.EnterpriseLibrary.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\assembly\GAC_MSIL\Microsoft.Practices.EnterpriseLibrary.Common\4.0.0.0__31bf3856ad364e35\Microsoft.Practices.EnterpriseLibrary.Common.dll'.

    Any ideas as to how resolve this issue?

    Thanks

    Riaz

    Friday, November 28, 2014 7:42 AM

Answers

  • User281315223 posted

    It sounds like you have two separate references to the Microsoft.Practices.EnterpriseLibrary. Common assembly within your project. You might want to check under the references in your application to verify this and remove one of them if there are multiple.

    You might also check if two of these references are present within your web.config file as well and remove one of them.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 28, 2014 8:49 AM