Error when trying to run LINQ query, Unable to open configSource file

Discussion of issues, suggestions and bugs of LINQ Insight, Visual Studio add-in for design-time executing LINQ statements, that simplifies debugging LINQ
Post Reply
vbdotnetboy
Posts: 3
Joined: Sun 04 Jun 2006 14:51

Error when trying to run LINQ query, Unable to open configSource file

Post by vbdotnetboy » Wed 01 Apr 2015 14:13

When I try and run the LINQ query I get the following error. Is there something I can do to get this to work?


Message: The type initializer for 'Financial.Data.FinancialEntities' threw an exception.
Type: System.TypeInitializationException
Source: Financial.Data
Site: .ctor
Stack Trace:
at Financial.Data.FinancialEntities..ctor() in file://c:\Projects\VS 2013\Financial\Financial.DataLayer\FinancialModel.Context.cs:line 24
at Financial.Data.EFUnitOfWork..ctor() in file://c:\Projects\VS 2013\Financial\Financial.DataLayer\EFUnitOfWork.cs:line 18
at Financial.Data.EFRepository`1..ctor() in file://c:\Projects\VS 2013\Financial\Financial.DataLayer\EFRepository.cs:line 22
at Financial.Data.fiBankRepository..ctor()
at Financial.BLL.fiBankService..ctor() in file://c:\Projects\VS 2013\Financial\Financial.BLL\fiBankService.cs:line 22
at Query.GetQuery(Object[] args)
at #=q4$P6mZboF9qvEjXbeAeRg1ugEGhzHAyfFRiytR_osVYn9Ss$nZ$JZ_00QB_VT$a3NRg3usB3ft9BtmkhDgOpBw==.#=qiqhxVa2Iy_ZqVlxwQtMgswxfTdG5SJqQ2jgi7SXgA9E=.#=qk3j9Iayhk1lG0BWXOltlew==()
at #=q4$P6mZboF9qvEjXbeAeRg1ugEGhzHAyfFRiytR_osVYn9Ss$nZ$JZ_00QB_VT$a3NRg3usB3ft9BtmkhDgOpBw==.#=qLTYkZdOLoTcpfUbRVe8_CWGqOCTgbZoRx9FZeFaOZLE=.#=qB69RWZgS3yZYacwWLjMZgL4ONYiIoPPBhxmqZ0cwhEtJw05Odr9B2Gu29m9SfcCv()
Inner Exception:
Message
: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.
Type: System.TypeInitializationException
Source: EntityFramework
Site: EnsureLoadedForAssembly
Stack Trace:
at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.EnsureLoadedForAssembly(Assembly assemblyHint, Type contextTypeHint)
at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.EnsureLoadedForContext(Type contextType)
at System.Data.Entity.Database.SetInitializer[TContext](IDatabaseInitializer`1 strategy)
at Financial.Data.FinancialEntities..cctor() in file://c:\Projects\VS 2013\Financial\Financial.DataLayer\FinancialModel.Context.cs:line 21
Inner Exception:
Message: Unable to open configSource file 'appSettings.config'. (C:\Projects\VS 2013\Financial\Financial\bin\Financial.dll.config line 19)
Type: System.Configuration.ConfigurationErrorsException
Source: System.Configuration
Site: EvaluateOne
Stack Trace:
at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.get_AppSettings()
at System.Data.Entity.Internal.AppConfig..ctor()
at System.Data.Entity.Internal.AppConfig..cctor()

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Error when trying to run LINQ query, Unable to open configSource file

Post by MariiaI » Thu 02 Apr 2015 08:00

Please check your project in runtime, without using LINQ Insight. Does it work correctly, without any errors?
If yes, please specify the following details:
- the version of LINQ Insight;
- the LINQ query you are trying to execute;
- the version of EF;
- the content of the *.config file;
- the type of the project, etc.

Please also send us a small test project, so that we are able to reproduce this issue in our environment and find the solution for you in a shortest time.

vbdotnetboy
Posts: 3
Joined: Sun 04 Jun 2006 14:51

Re: Error when trying to run LINQ query, Unable to open configSource file

Post by vbdotnetboy » Thu 02 Apr 2015 12:09

The project works correctly as this is a query that runs each time a page is loaded. I was evaluating this product to see if it would benefit our development department. I cannot send you a small project with the underlying dlls as this would be a breach of contract. The most I can do is provide you with the code I tried to use the LINQ Insight on version information and parts of the config files.

If I had to guess as to why it's failing it most likely has to do with the fact that we are not storing out appSettings in the web.config file, based on the exception that is being thrown.

Version: 3.2.610.0
EF Version: 6.1.2
Project Type: web
What I'm trying to execute:

Code: Select all

IQueryable<seMenu> FullMenu = seMenuRepository.Where(v => v.fkApplication == app &&
											((menu == -1) || v.fkMenu == menu) &&
											((v.seApplication.Area == "MyPage") ||
											(v.seApplication.Area == "System" && sysAdmin == true) ||
											(v.seMenuItem.MenuType == "S" && v.fkMenu != 1) ||
											(v.seMenuItem.seUserMenus.Where(m => m.fkUser == userid).Count() != 0) ||
											(v.seMenuItem.seRoleMenus.Where(m => m.seRole.seUserInRoles.Where(n => n.fkUser == userid).Count() != 0).Count() != 0))).OrderBy(v => v.Sequence)
[/size]



Web.config file:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application; please visit
  http://go.microsoft.com/fwlink/?LinkId=152368
  -->
<configuration>
  <configSections>
    
    <!--<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>-->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
  <connectionStrings>
    <add name="FinancialEntities" connectionString="metadata=res://*/FinancialModel.csdl|res://*/FinancialModel.ssdl|res://*/FinancialModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=cssql3;Initial Catalog=Financial;Integrated Security=True;Application Name=FIS;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
    <add name="ReportConnection" connectionString="Data Source=cssql3;Initial Catalog=Financial;Integrated Security=True;Application Name=FIS;" />
  </connectionStrings>
  <appSettings configSource="appSettings.config" />
  <system.web>
    <httpHandlers>
      <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" validate="false" />
    </httpHandlers>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
        <add assembly="Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
        <add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
      </assemblies>
      <buildProviders>
        <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
      </buildProviders>
    </compilation>
    <authentication mode="Forms">
      <forms loginUrl="~/Account/LogOn" timeout="2880" />
    </authentication>
    <membership>
      <providers>
        <clear />
      </providers>
    </membership>
    <profile>
      <providers>
        <clear />
      </providers>
    </profile>
    <roleManager>
      <providers>
        <clear />
      </providers>
    </roleManager>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
        <add namespace="CSIU.Helpers" />
        <add namespace="Financial.Areas.FlexReports.Helpers" />
        <add namespace="Microsoft.Web.Helpers" />
        <add namespace="System.Web.Optimization" />
      </namespaces>
    </pages>
    <customErrors mode="Off" />
    <!--request length is in kilobytes -->
    <!--why this was changed can be found here http://weblogs.asp.net/pscott/404-errors-with-fileupload-with-iis7-->
    <httpRuntime maxQueryStringLength="5000" maxRequestLength="5120" executionTimeout="120" />
    <!--<httpModules>
      <add name="PerfMon" type="Financial.Helpers.PerformanceMonitorModule"/>
    </httpModules>-->
  </system.web>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <clear />
        <!--<add name="X-UA-Compatible" value="IE=EmulateIE8" />-->
      </customHeaders>
    </httpProtocol>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404" subStatusCode="13" />
    </httpErrors>
    <handlers>
      <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
    </handlers>
    <security>
      <requestFiltering>
        <!--maxAllowedContentLength is in bytes. Defaults to 30,000,000 -->
        <!--why this was changed can be found here http://weblogs.asp.net/pscott/404-errors-with-fileupload-with-iis7-->
        <requestLimits maxAllowedContentLength="5242880" />
      </requestFiltering>
    </security>
    <!--<staticContent>
      <clientCache cacheControlCustom="public"
      cacheControlMaxAge="12:00:00" cacheControlMode="UseMaxAge"/>
    </staticContent>-->
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="4.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="ReportingService2010Soap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" 
				 bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
				 messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://cssql3:80/ReportServer/ReportService2010.asmx" binding="basicHttpBinding" bindingConfiguration="ReportingService2010Soap" contract="ReportingService2010.ReportingService2010Soap" name="ReportingService2010Soap" />
    </client>
  </system.serviceModel>
  <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true" internalLogFile="c:\\Logging\\NLog.log" internalLogLevel="Error">
    <extensions>
      <add assembly="NLog.Extended" />
    </extensions>
    <!--Targets are types of logging containers: database, file, email, webservice, etc.-->
    <variable name="fmtStandard" value="${longdate} | ${level} | ${logger} | ${message}" />
    <targets>
      <!--Generic log file configuration-->
      <target name="logfile" xsi:type="File" fileName="C:\\Logging\\FundAccounting.log" archiveAboveSize="5000000" archiveFileName="C:\\Logging\\Archive\\${shortdate}.{###}.log" maxArchiveFiles="30" layout="${fmtStandard}" />
      <!--Log database from WebErrorManager configuration-->
      <target xsi:type="Database" name="databaseWebErrorManager" connectionString="Data Source=cssql3;Initial Catalog=Financial;Integrated Security=True;Application Name=FIS;" commandText="exec [dbo].[usp_log_message] @user, @message, @server, @application, @procedure, @exception, @log_level">
        <parameter name="@user" layout="${aspnet-user-identity}" />
        <parameter name="@message" layout="${message}" />
        <parameter name="@server" layout="${machinename}" />
        <parameter name="@application" layout="${event-context:item=application}" />
        <parameter name="@procedure" layout="${event-context:item=procedure}" />
        <parameter name="@exception" layout="${event-context:item=stackTrace}" />
        <parameter name="@log_level" layout="${level}" />
      </target>
      <!--Email log configuration-->
      <!-- <target name="mail" html="true" type="Mail" smtpServer="csiu.mail.com" smtpPort="25" from="donotreply@csiu.org" to="nicolestaretz@gdcit.com" subject="${level:uppercase=true} Message from Warehouse Mgmt" body="<table>     <tr>         <td>Level: </td><td>${level:uppercase=true}</td>     </tr>     <tr>         <td>LogDate: </td><td>${date:format=MM/dd/yyyy HH\:mm\:ss tt}</td>     </tr>     <tr>         <td>User: </td><td>${machinename}</td>     </tr>     <tr>         <td>Server: </td><td>${machinename}</td>     </tr>     <tr>         <td>Application: </td><td>${callsite:className=true:filename=false:includeSourcePath=false:methodName=false}</td>     </tr>     <tr>         <td>Method: </td><td>${callsite:className=false:filename=false:includeSourcePath=false:methodName=true}</td>     </tr> </table> <hr /> <table>     <tr>         <td><b>Message:</b></td>     </tr>     <tr>         <td>${message}</td>     </tr>     <br />     <tr>         <td><b>${onexception:Exception\:}</b></td>     </tr>     <tr>         <td>${onexception:${exception:format=tostring}}</td>     </tr> </table>"/> -->
    </targets>
    <!--Rules for specific implementations of a target configuration-->
    <rules>
      <!--The following are the allowed log levels (in descending order): Off, Fatal, Error, Warn, Info, Debug, Trace -->
      <!--The attribute name is the namespace of the logging assembly.  If *, every message is written to the -->
      <logger name="*" minlevel="Error" writeTo="logfile" />
      <logger name="*" minlevel="Trace" writeTo="databaseWebErrorManager" />
      <!--logger name="*" minlevel="Warn" writeTo="mail" /-->
    </rules>
  </nlog>
</configuration>
[/size]

appSettings.config:

Code: Select all

  <appSettings>
	  <add key="webpages:Version" value="2.0.0.0" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="MaxImageHeight" value="120"/>
    <add key="MaxImageWidth" value="240"/>
	  <add key="ClientValidationEnabled" value="true" />
	  <add key="UnobtrusiveJavaScriptEnabled" value="true" />
	  <add key="PasswordStrengthRegularExpression" value="REMOVED FOR SECURITY"/>
    <add key="maxInvalidPasswordAttempts" value="REMOVED FOR SECURITY" />
    <add key="PositivePayDirectory" value="REMOVED FOR SECURITY" />
    <add key="ReportServerUrl" value="REMOVED FOR SECURITY"/>
    <add key="ReportPath" value="/DEV/Reports/"/>
    <add key="ReportServerUsername" value="REMOVED FOR SECURITY"/>
    <add key="ReportServerPassword" value="REMOVED FOR SECURITY"/>
    <add key="ReportServerDomain" value="REMOVED FOR SECURITY"/>
    <add key="ReportCSEncryptionKeyPath" value="REMOVED FOR SECURITY"/>
    <!--SSRS Subscription Scheduling Settings-->
    <add key="SSRSSubscriptionScheduleType" value="0"/> <!--0=Delayed, 1=Constant-->
    <add key="SSRSSubscriptionDelayType" value="0" /> <!--0=Minutes, 1=Hours, 2=Days-->
    <add key="SSRSSubscriptionDelayTimeAmount" value="5" /> <!--Integer type-->
    <add key="SSRSSubscriptionConstantTimeAmount" value="D:1-H:2-M:0" /> <!--D:#-T:#, D=how many days from now, H=actual hour to send subscription; must be military time 0-23, M=actual minute to send subscription; 0-59 -->
    <!--jQuery/javascript file source paths-->
    <add key="jQueryLibPath" value="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.0.min.js"/>
    <add key="jQueryUILibPath" value="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.3/jquery-ui.min.js"/>
    <add key="jQueryUICSSPath" value="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.3/themes/base/jquery-ui.css"/>
    <add key="jQueryValidateLibPath" value="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"/>
    <add key="jQueryValidateAdditionalMethodsLibPath" value="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.min.js"/>
    <add key="jQueryValidateUnobtrusiveLibPath" value="http://ajax.aspnetcdn.com/ajax/mvc/5.0/jquery.validate.unobtrusive.min.js"/>
    <add key="jQueryCookieLibPath" value="~/Scripts/jquery.cookie.js"/>
    <add key="jQueryIdleTimerLibPath" value="~/Scripts/jquery.idletimer.min.js"/>
    <add key="jQueryIdleTimeoutLibPath" value="~/Scripts/jquery.idletimeout.min.js"/>
    <add key="jQueryLinqLibPath" value="~/Scripts/jquery.linq.min.js"/>
    <add key="jQueryBrowserFixLibPath" value="~/Scripts/jquery.browser.fix.js"/>
    <add key="MVCjQueryUnobtrusiveAjax" value="~/Scripts/jquery.unobtrusive-ajax.min.js"/> <!--Could not use the CDN copy as we needed to modify it to work with the newer version of jQuery-->
  </appSettings>
[/size]

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Error when trying to run LINQ query, Unable to open configSource file

Post by MariiaI » Fri 03 Apr 2015 11:23

Thank you for the additional information. We will investigate this issue in more details and inform you about the results as soon as any are available.
As a temporary workaround, please try copying the content of the appSettings.config file to the web.config file and tell us if this helps.

Post Reply