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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:15:25+00:00 2026-06-05T16:15:25+00:00

I need to assign values to properties through reflection, and it has been OK

  • 0

I need to assign values to properties through reflection, and it has been OK to every cases tested so far, except one with the type of System.Reflection.Missing. For example this is the class:

public class SomeClass
{
    public System.Reflection.Missing MissingProp { get; set; }
}

And this is the code that assigns to the property through reflection:

var inst = new SomeClass();
var prop = typeof (SomeClass).GetProperty("MissingProp");
prop.SetValue(inst, Missing.Value, null);

And this is the exception I’m receiving:

System.ArgumentException: Missing parameter does not have a default value.
Parameter name: parameters
   at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
   at ClassesWithNoProperties.Program.Main(String[] args) in D:\Documents\Documents\Visual Studio 2010\Projects\C#\ClassesWithNoProperties\ClassesWithNoProperties\Program.cs:line 24

I have tested my library with too many cases that uses the same code for assigning values to properties, and this is the only case (System.Reflection.Missing) that I’m observing such a behaviour.

How do I achieve this kind of assignment in C#?

  • 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-05T16:15:26+00:00Added an answer on June 5, 2026 at 4:15 pm

    The error message is quite self-explanatory – the Missing.Value can only be used as a placeholder in methods that have optional parameters. What you’re trying to do, using it in a method to set the value of an instance using a PropertyInfo, simply doesn’t make sense, and Missing.Value knows this so it throws an exception.

    Strangely, you could probably get this to work using VB.Net, as VB.Net supports default parameters. C# does not.

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

Sidebar

Related Questions

A TreeNode class has Text Name Tag I need to assign more values to
I need to get UserCarId(int) from this query and assign to int type variable.
I need to assign values from a small dictionary collection (10 items) to a
I am working with a reflection based object translator. it basically loops through properties
I need to know how many times a button in my program has been
I want to assign values to server control properties in my code behind to
I need to assign a specific color to a bar in ggplot bar plots.
I need to assign an active class to my main-level navigation rendered by wordpress.
I need to assign a variable which will be used to create the id
I am exporting datatable in MSEXCEL.I need to Assign MultipleLines in a cell in

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.