Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 335539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:09:29+00:00 2026-05-12T10:09:29+00:00

I have made some progress on the problem I posted about yesterday, so I

  • 0

I have made some progress on the problem I posted about yesterday, so I am rewriting the post.

My problem appears to be related to my use of generics. Here’s the relevant part of App.config (formatted with whitespace for readability):

<configSections>
    <section
        name="NA5300ResolverSynchroDevices"
        type="InfrastructureModule.DeviceConfiguration.DeviceConfigurationSection
             &lt;NA5300ResolverSynchroModule.NA5300ResolverSynchroConfigurationElement&gt;,
             NA5300ResolverSynchroModule">
    </section>
</configSections>

<NA5300ResolverSynchroDevices>
    <Device deviceName="AzResolverSynchro" busAddress="7"/>
    <Device deviceName="ElResolverSynchro" busAddress="8"/>
</NA5300ResolverSynchroDevices>

Here’s the class I’m trying to map to the configuration section:

namespace InfrastructureModule.DeviceConfiguration
{
    public class DeviceConfigurationSection<T> : ConfigurationSection
           where T : DeviceConfigurationElement, new()
    {
        [ConfigurationProperty("", IsDefaultCollection = true, IsKey = false)]
        public DeviceConfigurationElementCollection<T> Devices
        {
            get { return (DeviceConfigurationElementCollection<T>) base[""]; }
            set { base[""] = value; }
        }
    }
}

Here’s the C# code that tries to access the config file:

DeviceConfigurationSection<NA5300ResolverSynchroConfigurationElement> devices =
    ConfigurationManager.GetSection("NA5300ResolverSynchroDevices") as
    DeviceConfigurationSection<NA5300ResolverSynchroConfigurationElement>;

Here’s the exception text I’m getting:

An error occurred creating the configuration section handler for NA5300ResolverSynchroDevices: Could not load type ‘InfrastructureModule.DeviceConfiguration.DeviceConfigurationSection<NA5300ResolverSynchroModule.NA5300ResolverSynchroConfigurationElement>’ from assembly ‘NA5300ResolverSynchroModule’.

I know that in C# generics are instantiated at runtime rather than at compile time (unlike C++). I do not yet know enough about generics to understand what assembly a runtime-generated type is considered to live in when the generic type and the instantiating type live in different assemblies. Above, I told the runtime to look for it in assembly NA5300ResolverSynchroModule. I’ve also tried telling it to look for it in assembly InfrastructureModule. Neither works.

I am attempting to use a genric type because I will have many config sections for which the corresponding ConfigurationSection-derived types will all be of the form shown above. I want to avoid code duplication.

Can anybody see why my approach is failing and how I can fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:09:30+00:00Added an answer on May 12, 2026 at 10:09 am

    Your problem is actually how you’ve referenced the generic type.

    Instead of (shortened):

    <section name="..."
    type="InfrastructureModule.DeviceConfiguration.DeviceConfigurationSection
                 &lt;NA5300ResolverSynchroModule.NA5300ResolverSynchroConfigurationElement&gt;,
                 NA5300ResolverSynchroModule" />
    

    Try

    <section name="..."
    type="InfrastructureModule.DeviceConfiguration.DeviceConfigurationSection`1[[NA5300ResolverSynchroModule.NA5300ResolverSynchroConfigurationElement, NA5300ResolverSynchroModule]],
                 NA5300ResolverSynchroModule" />
    

    Note the `1[[…]] rather than <…> or &lt;…&gt; part for the generic type. The part inside the [[…]] can be a full type definition as well – like namespace.class,assembly,token.

    The 1 is "generic type with one type parameter". If the type takes 2 "aka SomeType<T,V>", use2. Note that you should put “type, assembly” in the double square brackets, not just “type”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I posted a thread about this earlier and have made some progress but now
Ok after my previous post, i have made some progress, yet still i need
I have made some progress with the DataList and UserControl this morning but I
I've tried several things... using Variables and Templates, and have made some slow progress.
I'm trying to disassemble a C/C++ DLL, and have made some progress, but I
I am just learning the Entity Framework and have made some good progress on
I have made some changes in one perforce client, but haven't submitted them. I
I have made some screenshots of my website, and in internet explorer 6 my
I have made some screenshots of my website, and in internet explorer 6 my
I have a datagrid in C#.net I have made some columns in grid editable.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.