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

  • Home
  • SEARCH
  • 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 8413987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:03:04+00:00 2026-06-10T01:03:04+00:00

While there are similar questions in Stackoverflow about this it does not help me

  • 0

While there are similar questions in Stackoverflow about this it does not help me with my problem.
Here is the big picture of what I am doing. I am generating IL for my iDB2DataReader to dynamically get my types from a database and map to my poco.
I am having problems getting a nullable to pull in the data.

So I have a method that needs to return the methodinfo via reflection. To get the this I am using “getmethod” of the type that I need.
Here is the code:

private static MethodInfo GetDataMethod(Type destinationDataType, Type underlyingDestinationDataType, iDB2DataReader reader)
{
    MethodInfo methInfo = null;

    if (_readerDataMethods.ContainsKey(destinationDataType))
    {
        methInfo = _readerDataMethods[destinationDataType];
    }
    else
    {

        if (underlyingDestinationDataType != null)
        {
            //trying to get underlying type which would be DateTime thus resulting in GetDatetime.
            methInfo = reader.GetType().GetMethod("Get" + underlyingDestinationDataType.Name);
        }
        else
            methInfo = reader.GetType().GetMethod("Get" + destinationDataType.Name);
        //methInfo = reader.GetType().GetMethod("Get" + destinationDataType.ToGenericTypeString());

        if (methInfo != null)
        {
            _readerDataMethods[destinationDataType] = methInfo;
        }
    }

    return methInfo;
}

As you can see from my code comment I get the underlying type of datetime but this does not work, it gets a runtime error of “Operation could destabilize the runtime.”.

The real problem is I don’t know what the name I should be using for the getmethod for a Nullable<DateTime>. Or at least I was hoping it was that simple. Any help would be appreciated.

  • 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-10T01:03:06+00:00Added an answer on June 10, 2026 at 1:03 am

    You’re probably going to have to create a special case fur Nullables as the actual type name wouldn’t be valid in a method name. I’d check to see if it’s a Nullable type and the use reflection to get the generic parameter.

    Example:

    Type t = typeof (Nullable<DateTime>);
    
    Console.WriteLine(t.Name);   // Nullable`1
    if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>))
    {
        Type t2 = Nullable.GetUnderlyingType(t);
        Console.WriteLine("Nullable"+t2.Name); // NullableDateTime
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While there are similar questions here, none gave a complete answer, so I am
i know that there are similar questions on Stackoverflow, but they did not solve
I know this is the repeat question.There are many similar questions are there in
I see that there have been similar questions asked here regarding wrapping unmanaged C++
I found similar questions asked here but there weren't answers to my satisfaction. So
While there have been some similar questions I couldn't find a solution for exactly
I've searched for this info and see similar questions, but not one that matches
I don't think this question has asked yet (most similar questions are about extracting
Similar to what I asked in this question a while back about getting the
I there are similar questions out there, but none of that did really help

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.