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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:50:17+00:00 2026-05-24T12:50:17+00:00

.NET supports the FlagsAttribute for enum’s, which indicates that an enumeration can be treated

  • 0

.NET supports the FlagsAttribute for enum’s, which indicates “that an enumeration can be treated as a bit field”.

An example of an enum that makes use of this [Flags] attribute is System.Windows.Forms.Keys

Here is my Spring.NET object definition:

<object id="command.paste" type="MyNamespace.PasteClipboardCommand, MyProject">
  <property name="Title" value="Paste into Folder" />
  <property name="ShortcutKeys" value="P" />
</object>

This sets the property ShortcutKeys of type Keys to the key P. No problem there. However, since this is a shortcut, I’d like to assign something like Control+P as shortcut key.

If I would wire this up in code, it would be:

command.ShortcutKeys = Keys.Control | Keys.P;

So, maybe I was a little naive trying this:

<property name="ShortcutKeys" value="Control|P" />

This fails, because the EnumConverter can only parse/convert string representations of single enum’s. A full stacktrace is available below.

  • Is this possible by default Spring.NET ?
  • Can I work around this by specifying/using another EnumConverter ?
  • Should I create/use another Keys class to do the Spring.NET initialization ?

UPDATE:

Apparently the KeysConverter knows how to handle this like this:

(new KeysConverter()).ConvertFrom(null, null, "Control+P");

Unfortunately, the EnumConverter does not support this ?

Attached Stacktrace:

System.Configuration.ConfigurationErrorsException: Error creating context 'spring.root': PropertyAccessExceptionsException (1 errors); nested PropertyAccessExceptions are: 
[Spring.Core.TypeMismatchException: Cannot convert property value of type [System.String] to required type [System.Windows.Forms.Keys] for property 'ShortcutKeys'., Inner Exception: System.FormatException: Control|P is not a valid value for Keys. ---> System.ArgumentException: Requested value 'Control|P' was not found.
    at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
    at System.ComponentModel.EnumConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
    --- End of inner exception stack trace ---
    at System.ComponentModel.EnumConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
    at System.ComponentModel.TypeConverter.ConvertFromInvariantString(String text)
    at Spring.Core.TypeConversion.TypeConversionUtils.ConvertValueIfNecessary(Type requiredType, Object newValue, String propertyName)] ---> Spring.Objects.Factory.ObjectCreationException: Error creating object with name 'command.builder.paste' defined in 'file [....\commands.xml] line 39' : Error setting property values: PropertyAccessExceptionsException (1 errors); nested PropertyAccessExceptions are: 
[Spring.Core.TypeMismatchException: Cannot convert property value of type [System.String] to required type [System.Windows.Forms.Keys] for property 'ShortcutKeys'., Inner Exception: System.FormatException: Control|P is not a valid value for Keys. ---> System.ArgumentException: Requested value 'Control|P' was not found.
    at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
    at System.ComponentModel.EnumConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
    --- End of inner exception stack trace ---
    at System.ComponentModel.EnumConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
    at System.ComponentModel.TypeConverter.ConvertFromInvariantString(String text)
    at Spring.Core.TypeConversion.TypeConversionUtils.ConvertValueIfNecessary(Type requiredType, Object newValue, String propertyName)] ---> PropertyAccessExceptionsException (1 errors); nested PropertyAccessExceptions are: 
[Spring.Core.TypeMismatchException: Cannot convert property value of type [System.String] to required type [System.Windows.Forms.Keys] for property 'ShortcutKeys'., Inner Exception: System.FormatException: Control|P is not a valid value for Keys. ---> System.ArgumentException: Requested value 'Control|P' was not found.
    at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
    at System.ComponentModel.EnumConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
    --- End of inner exception stack trace ---
    at System.ComponentModel.EnumConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
    at System.ComponentModel.TypeConverter.ConvertFromInvariantString(String text)
    at Spring.Core.TypeConversion.TypeConversionUtils.ConvertValueIfNecessary(Type requiredType, Object newValue, String propertyName)]
  • 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-24T12:50:17+00:00Added an answer on May 24, 2026 at 12:50 pm

    If you look at the Spring.NET documentation 5.11 Configuration of IApplicationContext, you can see an example of how to add a specific type converter for a given type.

    Adding the KeysConverter for type Keys in app.config is sufficient:

    <converter for="System.Windows.Forms.Keys, System.Windows.Forms" type="System.Windows.Forms.KeysConverter, System.Windows.Forms"/>
    

    Now the enumvalue/shortcut can be specified like this:

    <property name="ShortcutKeys" value="Control+P" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody recommend a treeview component for ASP.NET that supports drag & drop (between
I am looking for a tool which can edit asp.net pages and supports intellisense.
I know .net supports base64 encoding of byte arrays. But i thought that i
I'm looking for a decent lexical scanner generator for C#/.NET -- something that supports
I have a C# (2008/.NET 3.5) class library assembly that supports WPF (based on
I would like create a web service in ASP.Net 2.0 that will supports JSON.
You can use App.config; but it only supports key/value pairs. You can use .Net
I need a .NET that supports last in first out (LIFO). Is there one?
Is there any twitter library for .NET which supports twitter entities ( http://dev.twitter.com/pages/tweet_entities )?
Given a .net application that supports different logic providers, how to instantiate one instance

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.