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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:46:13+00:00 2026-05-25T19:46:13+00:00

I have a model class called VideoGame . I need the class to get

  • 0

I have a model class called VideoGame. I need the class to get passed in a t4 template using reflection in this method.

MethodInfo[] methodInfos =
    typeof(type).GetMethods(BindingFlags.Public | BindingFlags.Static);

I have the following variables.

//passed via powershell file - is a string "VideoGame"
var modelName = Model.modelName
Type type = modelName.GetType();

I get an error that says: The type or namespace name ‘type’ could not be found (are you missing a using directive or an assembly reference?). What I need to know is how to pass the VideoGame class inside that typeof() method. I have tried the following:

MethodInfo[] methodInfos =
    typeof(modelName.GetType()).GetMethods(BindingFlags.Public | BindingFlags.Static);
MethodInfo[] methodInfos =
    modelName.GetType.GetMethods(BindingFlags.Public | BindingFlags.Static);
MethodInfo[] methodInfos =
    typeof(modelName).GetMethods(BindingFlags.Public | BindingFlags.Static);
  • 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-25T19:46:14+00:00Added an answer on May 25, 2026 at 7:46 pm

    typeof(modelName.GetType()) would never work, because modelName.GetType() returns a System.String’s runtime type.

    modelName.GetType has the same problem.

    typeof(modelName) won’t work because modelName is a string and typeof expects a Type.

    So….if you have a string “VideoGame” and you want to get the methods on the Type VideoGame….

    I would do:

    Type.GetType(modelName).GetMethods()
    

    Type.GetType will return a Type by the specified name. NOTE that this requires an Assembly Qualified Name….so just supplying VideoGame isn’t enough. You need modelName to be in the form:

    MyNamespace.VideoGame, MyAssemblyThatContainsVideoGame
    

    Further, that means that whatever is running your T4 code needs to have a reference to MyAssemblyThatContainsVideoGame.

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

Sidebar

Related Questions

I have a class in my domain model called JobPlan this class is stored
Let's say I have a model class called Project, but instead of this: class
Using an MVVM approach to WPF, I have a view model class called SubButton
I have this Task model: class Task < ActiveRecord::Base acts_as_tree :order => 'sort_order' end
Let's say I have a model like this class Foo(db.Model): id = db.StringProperty() bar
I have a rails model that looks something like this: class Recipe < ActiveRecord::Base
Assume I have a Model class called Bird and a instance of Bird called
I have a model class Action that get's extended by several other classes. I
I have this class model where, Bank is a class which is now going
I have a model like this: class Person(models.Model,Subject): name = .. The class Subject

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.