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 8636353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:12:50+00:00 2026-06-12T10:12:50+00:00

Code block four (below) is giving me an error that I am at a

  • 0

Code block four (below) is giving me an error that I am at a loss with regard to fixing…

Here’s the XML Schema that I’m using:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

<!DOCTYPE ctqcfg SYSTEM "cache.dtd">

<cache version="1.0">
    <configuration name="Test">
        <cacheControl>
            <cache name="Customer" mode="off"/>
            <cache name="Vendor" mode="off"/>
            <cache name="Agency" mode="off"/>
            <cache name="Partner" mode="off"/>
        </cacheControl>
    </configuration>

    <configuration name="Production">
        <cacheControl>
            <cache name="Customer" mode="preload"/>
            <cache name="Vendor" mode="dynamic"/>
            <cache name="Agency" mode="dynamic"/>
            <cache name="Partner" mode="dynamic"/>
        </cacheControl>
    </configuration>
</cache>

The XML file is loaded

Private XElement As XElement = Nothing

Public Sub Load()
    XElement = XElement.Load(ConfigurationResource)
End Sub

When the user selects a configuration to edit, a reference to the root of the selected configuration element is held

Private ConfigurationRoot As System.Collections.Generic.IEnumerable(Of System.Xml.Linq.XElement)

Private ConfigurationName_ As String

Public Property ConfigurationName() As String
    Get
        Return ConfigurationName_
    End Get
    Set(ByVal Value As String)
        ConfigurationName_ = Value
        ConfigurationRoot = From Configuration In XElement.<configuration> Where Configuration.@name = Value
    End Set
End Property

Trying to retrieve the cache mode that corresponds to the cache name (in this case Customer)

Public Property CustomerCache() As String
    Get
        Try
            Return From Cache In ConfigurationRoot.<cacheControl>.<cache> Where Cache.@name = "Customer" Select Cache.@mode
        Catch Exception As Exception
            Return Nothing
        End Try
    End Get
    Set(ByVal Value As String)
        'ToDo
    End Set
End Property

I’m getting the following error

System.InvalidCastException was caught
Message=Unable to cast object of type 'WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String]' to type 'System.String'.

This is my first day working with LINQ and I seem to have a basic misunderstanding regarding how to access the attribute – it seems that the query is returning a collection and I know that there is only ever one possible value that can be found…

  • 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-06-12T10:12:51+00:00Added an answer on June 12, 2026 at 10:12 am

    You need .First() or .Single():

    Return (From Cache In ConfigurationRoot.<cacheControl>.<cache> Where Cache.@name = "Customer" Select Cache.@mode).First()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code below contains certain tags in all four. Image-1 here is the code :
I have a code block that leads to a Internet Explorer cannot display the
I have the code block below, I deleted all unnecessary parts, just left the
I have a small code block that should append text to the beg of
The simple code block below can be served up in a static HTML page
I have a code block that checks certain elements before allowing a form to
I am new in iphone...i have created toolbar with Four buttons...code is show below...I
I just created script that shows/hides (toggles) block of HTML. There are four buttons
For example, if I make a block of four images that are absolutely positioned
I have a code something below: function showHideOptions() { $(#template1, #template2, #template3, #template4).css(display,none); $(this).css(display,block);

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.