recurring exception when opening saved config files

Topics: General discussion, Logging Application Block
Mar 31, 2011 at 4:15 PM
Edited Mar 31, 2011 at 4:15 PM

Hi,

Just installed 5.0 version of the EntLib.

  1. Opened the editor
  2. Added Logging block.
  3. Saved and closed the editor.
  4. Ran the editor again anf tried to open the file and get an nice exception window: "Error loading section enterpriseLibrary.Configuration Source.... Error Message: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ViewModel.CollectionElementViewModel", name="(none)"  bla bla bla  Exception is: InvalidOperationException - Sequence contains no elements..
  5. Then checked with a new c# project to which an app.config file was added, and when rightclick on it to edit EntLib 5.0 configuration  the same exception is raised.
  6. Uninstalled, closed VS, reinstalled, opened VS and repeated 1-5, same results.

Using VS 2010 premium edition, W7-64

Appreciate any help on this matter.

Apr 1, 2011 at 9:24 AM

Hi,

I'm not sure if you are getting this error because you are using a 64bit machine. Have you tried to use the Entlib Config .NET 4 as your editor? Also, can you try to run it as an Administrator and see if it solves the issue?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 1, 2011 at 3:21 PM

Hi.

Tried all of them (Net 3.5, x86, Net 4, x86) both as regular user  and as Admin and same exception occurs.

Thanks.

Apr 4, 2011 at 3:14 AM

Not sure what's causing the error.  Unfortunately, we don't have a 64-bit machine right now where we could try to repro.  You said that the error occurs upon loading the config, are you able to save the config at all and tried running the project if you'll get an exception?

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 7, 2011 at 6:58 PM

I am able to save a config file.

But while opening it for editing I'd have the exception, and a blanc editor would be shown. This would make me loose my efforts on creating the config file in the first place. I would not go the "manual" edition of the config file way.

 

Regards..

Apr 8, 2011 at 3:21 AM

Did you try repeating the whole process meaning starting with a blank configuration with the stand-alone .NET 4.0 configuration tool?  Just want to confirm that you did this since I recall Chris Tavares' explanation about that version of configuration tool in this thread

In addition, were there any message(s) logged in the event viewer indicating any exception related to it?

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 8, 2011 at 2:19 PM
Edited Apr 8, 2011 at 2:25 PM

I did again steps like this, \again as an admin

1: C:\Program Files (x86)\Microsoft Enterprise Library 5.0\Bin>EntLibConfig.exe "C:\Users\<user>\Documents\mytest.config"

with mytest.config being a blank config file:

<configuration>
    <configSections>
    </configSections>
</configuration>

created with the tool.

Same error is displayed.

2. Repeated 1 but using other executables:

16/04/2010  02:16 PM           158,008 EntLibConfig-32.exe
16/04/2010  02:17 PM           158,008 EntLibConfig.exe
16/04/2010  02:17 PM           158,008 EntLibConfig.NET4-32.exe
16/04/2010  02:17 PM           158,008 EntLibConfig.NET4.exe

Same results:

"Error loading section enterpriseLibrary.Configuration Source.... Error Message: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ViewModel.CollectionElementViewModel", name="(none)"  bla bla bla  Exception is: InvalidOperationException - Sequence contains no elements..

I have both VS2008 and VS2010 (though I dont use VS2008 since our codebase is in VS2010)

Now, repeted steps 1 and 2 with following config file (result of adding a logging block to a new document)

<configuration>
    <configSections>
        <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    </configSections>
    <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
        <listeners>
            <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                source="Enterprise Library Logging" formatter="Text Formatter"
                log="" machineName="." traceOutputOptions="None" />
        </listeners>
        <formatters>
            <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
                name="Text Formatter" />
        </formatters>
        <categorySources>
            <add switchValue="All" name="General">
                <listeners>
                    <add name="Event Log Listener" />
                </listeners>
            </add>
        </categorySources>
        <specialSources>
            <allEvents switchValue="All" name="All Events" />
            <notProcessed switchValue="All" name="Unprocessed Category" />
            <errors switchValue="All" name="Logging Errors &amp; Warnings">
                <listeners>
                    <add name="Event Log Listener" />
                </listeners>
            </errors>
        </specialSources>
    </loggingConfiguration>
</configuration>

Same result (exception)

Regards.

 

 

Apr 11, 2011 at 1:37 AM

I'm currently trying to repro this on a 64-bit machine.  I'll keep you posted for any updates.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 11, 2011 at 3:00 AM

Unfortunately, in none of the version of the stand-alone tool were I able to repro the error you're getting.  I tried that using Windows 7 - 64bit machine.  Please try closing first Visual Studio, uninstall entlib, check if the folder in the Program Files directory still exists, delete it if it does. Re-install it and then open Visual Studio.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 12, 2011 at 4:23 PM
Edited Apr 12, 2011 at 9:21 PM

Thanks for your efforts. Unfortunately your suggestions lead me to same point.

I even completely uninstalled VS2008 (leaving only 2010 in my ws). Uninstalled and reintalled EntLib 5.0 and same result.

I modified EntLibConfig.exe.config  to provide verbose logging..

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.diagnostics>
    <switches>
      <add name="configurationToolLogging" value="Verbose"/>
    </switches>
  </system.diagnostics>
</configuration>

Ran the EntLibConfig.exe, tried to load a previouslly saved config an assertion failed, caugth by VS2010:

c:\Users\xx\Documents\EntLib50Src\Blocks\Configuration\Src\Design\ViewModel\ElementCollectionViewModel.cs, line 67

Debug.Assert(configurationCollectionAttribute != null);

I let it continue and obviously this causes the error subject of this thread:

c:\Users\xx\Documents\EntLib50Src\Blocks\Configuration\Src\Design\ViewModel\CollectionElementViewModel.cs, line 57

"System.InvalidOperationException was unhandled by user code
  Message=Sequence contains no elements
  Source=System.Core
  StackTrace:
       at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
       at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ViewModel.CollectionElementViewModel..ctor(ElementCollectionViewModel containingCollection, ConfigurationElement thisElement, IEnumerable`1 additionalAttributes)
       at Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ViewModel.CollectionElementViewModel..ctor(ElementCollectionViewModel containingCollection, ConfigurationElement thisElement)
       at BuildUp_Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ViewModel.CollectionElementViewModel(IBuilderContext )
       at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
       at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
  InnerException:
"

Now,

Using EntLib-Net4 as admin, the behavior was the same. Created a new config file with just the Logging block:

<configuration>
    <configSections>
        <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null" requirePermission="true" />
    </configSections>
    <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
        <listeners>
            <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null"
                listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null"
                source="Enterprise Library Logging" formatter="Text Formatter"
                log="" machineName="." traceOutputOptions="None" />
        </listeners>
        <formatters>
            <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null"
                template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
                name="Text Formatter" />
        </formatters>
        <categorySources>
            <add switchValue="All" name="General">
                <listeners>
                    <add name="Event Log Listener" />
                </listeners>
            </add>
        </categorySources>
        <specialSources>
            <allEvents switchValue="All" name="All Events" />
            <notProcessed switchValue="All" name="Unprocessed Category" />
            <errors switchValue="All" name="Logging Errors &amp; Warnings">
                <listeners>
                    <add name="Event Log Listener" />
                </listeners>
            </errors>
        </specialSources>
    </loggingConfiguration>
</configuration>

But this file is saying the logging assembly's public token is null, which may be wrong.

Regards.

 

Apr 13, 2011 at 2:07 AM
Edited Apr 13, 2011 at 2:11 AM

Did you directly open the EntLibConfig.exe from EntLib50Src\Blocks\bin\Debug or did you run the EntLib source code?  Either way, it will indeed create a config file where entlib assemblies have their PublicKeyToken as null since it's using the unsigned versions of the Entlib assemblies.

(If you haven't) Please run the Configuration.Console project of the Enterprise Library source code.  Place a breakpoint on the line mentioned in the stack trace where the exception originated.  Debugging is the only choice we have right now since I can't repro your error.  Check what exactly is that collection which doesn't contain any element.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 13, 2011 at 4:00 PM

Hi Sarah,

I was using the shortcut provided by the installer, but because of the errors I switched to trying the code.

Uninstalled everything again but found some EntLib 4.1.0.0 in the gac, and removed manually them (after cleaning up references in the registry). Installed EntLib 5.0 again, un-checking the source code option.

Tried again: open the console, and save a blank config. Tried to reopen and got:

The application could not save the configuration information to the configuration file. Please try to save the configuration to a different file.
Error message: An error occurred creating the configuration section handler for enterpriseLibrary.ConfigurationSource: Could not load file or assembly ‘Microsoft.Practices.EnterpriseLibrary.Common,
Version=4i.O.O, Culture= neutral, PublicKeyToken=31bf3856ad364e35 or one of its dependencies. The located assemblys manifest definition does not match the assembly reference. (Exception from HRESULT:
0x80131040)
(C:\WindowAMicrosoft.NET\Framework64\v4.O.30319\Config\machine .config line 141)
"

At line 141:
"    <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></configSections>
"

I then removed all references to the 4.1.0.0 dlls from all the machine.config files in .NET folder. Rebooted. tried again and it finally worked.

 

Thanks.

 

th

Apr 14, 2011 at 12:09 AM

So the error has got something to do with other version of EntLib being installed in GAC. I'm just not sure why did your config had your entlib assemblies marked as version 4.1 if you used the config tool version 5.  Anyway, thanks for sharing how you got this to worked :)

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 14, 2011 at 3:06 AM

You can try reproducing the error:

  • Install 4.1 assemblies to GAC
  • modify .NET machine.config files accordingly.
  • Install EntLib 5.0

I am not sure why there were 4.1 dlls on the gac, since there was no entlib 4.1 installed on the system, the only version installed was 5. May be a glitch on the 4 installer.

Apr 14, 2011 at 4:09 AM

Sounds like the real issue was the presence of Entlib configuration in machine.config. The tool tries to use System.Configuration to open the file, and my guess was it was hitting the Entlib section in machine.config, which was pointing to the old version of Entlib which of course doesn't work with the 5.0 tool, and that's why it was blowing up.

 Entlib installers don't touch the GAC or machine.config, so it must have been something done after the fact on that machine.

Apr 14, 2011 at 6:39 AM

Thanks Chris for the insight.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 14, 2011 at 2:26 PM
Edited Apr 14, 2011 at 2:37 PM

thanks for input. I looked further into the issue, and remember having seen in the machine.config a section like this (from a backup file I made before making modifications):

    <enterpriseLibrary.ConfigurationSource selectedSource="ESB File Configuration Source">
      <sources>
        <add name="ESB File Configuration Source"
        type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        filePath="C:\Program Files (x86)\Microsoft BizTalk ESB Toolkit 2.1\esb.config" />
        <add name="ESB SSO Configuration Source"
        type="Microsoft.Practices.ESB.SSOConfigurationProvider.SSOConfigurationSource, Microsoft.Practices.ESB.SSOConfigurationProvider, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        applicationName="ESB" description="ESB SSO Configuration"
        contactInfo="someone@microsoft.com"
        userGroupName="BizTalk Application Users"
        adminGroupName="BizTalk Server Administrators" />
      </sources>
    </enterpriseLibrary.ConfigurationSource>

I had installed before the latest version of the ESB (Enterprise Service Bus) Toolkit (BizTalk ESB Toolkit 2.1-x64.msi). I now tried to uninstall it and it shows a message saying: "Warning: all Enterprise Library 4.1 assemblies will be uninstalled from the Global Assembly Cache". This explains why I had EntLib 4.1 assemblies in the GAC, and this could explain the links to the v4.1 assemblies in the machine.config files. In fact, I just proceeded to uninstall and reinstall this toolkit and found that all the references to v4.1 assemblies are back again on all of the machine.config files.

This shows that I cannot use both products' versions at the same.

So, in order to reproduce the error, you just need to:

  • Uninstall Entlib v5.0 (or any other)
  • install ESB 2.1
  • Install EntLib 5.0
  • Try use it the console as described in this thread.

If I had the ESB source code I could recompile it referencing 5.0 assemblies. But the source code is not available.

Regards

Nov 7, 2011 at 6:54 PM
Edited Nov 7, 2011 at 6:55 PM

Hi

I faced the same problem and the solution for me was removing: publicKey=null

From:

<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral" requirePermission="true" />

Regards

Jose