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

The Archive Base Latest Questions

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

The Question Aside from all the obvious answers, what would cause extension methods to

  • 0

The Question

Aside from all the obvious answers, what would cause extension methods to generate compiler errors like this one:

‘DataType’ does not contain a definition for ‘YourExtensionMethodName’

I’ve got a real stumper here, and it’s spelled out for you in detail below. I’ve exhausted all the possible causes I can think of.

Scenario

  • I have a couple of extension methods defined in various static classes in a DLL that is consumed by a WinForms application.
  • The extension method signatures do not conflict with the signatures of methods on the class I’m extending (String, in this case).
  • Both the DLL and the WinForms application are written in C#.
  • Both the DLL and the WinForms application are configured to target .NET 3.5.
  • The consuming classes include a reference to the namespace that defines the extension method. Its spelling has been verified.
  • If I reference the extension class directly, the extension methods appear. For example, if I type StringExtensions., Intellisense appears as normal, with all of my extension methods listed.
  • EDIT: The errors are occurring in the WinForms application, but only for some of the extension methods, not all of them.

The Code (Or an Excerpt Thereof)

(Yep, this is the offending code)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Roswell.Framework
{
    public static class StringBuilderExtensions
    {
        public static string ToSentenceCase(this string value)
        {
            return value.Substring(0, 1).ToUpper() + value.Substring(1).ToLower();
        }

        public static string ToTitleCase(this string value)
        {
            string[] parts = value.Split(new string[] {" "}, StringSplitOptions.None);
            System.Text.StringBuilder builder = new System.Text.StringBuilder();
            foreach (string part in parts)
            {

                builder.Append(part.ToSentenceCase());
                builder.Append(" ");
            }
            return builder.ToString();
        }

    }
}

And this is the code that consumes it:

using Roswell.Framework;

namespace Roswell.Windows.Command
{
    /// <summary>
    /// Views the SQL for an object in the database window.
    /// </summary>
    internal class ViewObjectDdlCommand
        : MainWindowCommand
    {

        public override void Execute()
        {
           // ...

           OpenCodeWindow(
               string.Format("{0} - {1} - {2}", 
                             dsn.Name, 
                             objectName, 
                             info.ToTitleCase()),
                schemaItemType,
                objectName);
         }
    }
}
  • 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-12T16:09:04+00:00Added an answer on May 12, 2026 at 4:09 pm

    From your code snippet, I can see you’re calling ToTitleCase on something called info. But I can’t see the type of that variable, which is the thing that will determine what is happening here.

    Obviously it needs to be a string (if string was not a sealed class it could be something derived from string, but that’s impossible for a sealed class).

    So the only thing that makes sense (aside from a very unlikely compiler error) is that info is not a string.

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

Sidebar

Related Questions

Are there any simple, effective answers to this?... aside from, Decide which is more
I know this is going to sound like a dumb question, but as I'm
This question is just to clear some things up. Some things like this have
Possible Duplicate: What Advantages of Extension Methods have you found? All right, first of
Clarification Upon working through your answers and reading your interpretations of this question, I
This is such a dumb question that I feel like I must be missing
I'm still relatively new to Python, so if this is an obvious question, I
I'd like to apologize in advance, because this is not a very good question.
Question from Object-Oriented JavaScript book: Imagine Array() doesn't exist and the array literal notation
Question I'd like the CSS background texture for my content area to begin immediately

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.