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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:32:11+00:00 2026-06-14T07:32:11+00:00

class Device{ private object device; public Device(string ProgID) { if (ProgID == ) ProgID

  • 0
class Device{
    private object device;
    public Device(string ProgID)
    {
        if (ProgID == "") ProgID = "ScopeSim.Telescope";
        device = Activator.CreateInstance(Type.GetTypeFromProgID(ProgID));
        Console.WriteLine("Connected");
    }
    public object Invoke(string Name, object[] args)
    {
        var v1 = device.GetType(); //this is a com object in debug
        var v2 = v1.GetMethod(Name);
        var v3 = v2.Invoke(device,args); //throws exception, v2 is null
        return v3;
    }
}
//somwhere else in another method in another class that has this in a field...
Console.WriteLine(new Device("").Invoke("A Method Name that is a string but is not known and could be anything, for testing, the name is 'Unpark'", object[] args));

This throws a NullReferenceException. The Unpark method does exist but it does not have a return type, but it does exist. Also, when it stopped to debug (on the exception) the ProgID field in the constructor was null. I would assume that this is normal though, right? It would have already run. Does anyone know why it throws it? If I declare device as dynamic, says it can’t bind at runtime to a null object (basically the same thing).

Response to First Answer: I think reflection requires the variables as an array of objects. Yes, Unpark is written with a capital U. The ProgID thing apparently seems to be irrelevant.

  • 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-14T07:32:14+00:00Added an answer on June 14, 2026 at 7:32 am

    Well, I think I finally figured it out, thanks to this answer: https://stackoverflow.com/a/3199919/258482. The problem is that you have to use InvokeMember to do anything to a COM object.

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

Sidebar

Related Questions

Models: class Device extends Backbone.Model url: '/device' initialize: -> console.log Device model created... @set
The java.io.Console class requires there to be a Console device (window). How can I
I'm currently developing a custom control that derives from CStatic MFC class (Smart Device
I've written following class to start my application activity Home.class but on device start
I have a class the communicates with a device over TCP. I send commands,
There is an class android.os.Build that got static variables cointaining device info, but when
I have a little problem. I have class private static class EfficientAdapter extends BaseAdapter
Here is the test code that I am using : public class IOConnectDirect extends
i have written a class which implements ListFieldCallBack like, import java.util.Vector; import net.rim.device.api.ui.Graphics; import
Hi everybody I'm implementing serialization and saving object in the android device memory. I

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.