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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:30:20+00:00 2026-05-22T21:30:20+00:00

I wrote following program in order to understand object construction and method call in

  • 0

I wrote following program in order to understand object construction and method call in IL Unfortunately it doesn’t print

How are you doing

on the console.

Do you have any idea?

Output of peverify is also given below.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection.Emit;
using System.Reflection;
using System.IO;

namespace Research
{
    public class Program
    {
        public static void Main(string[] args)
        {
            AssemblyName name = 
                new AssemblyName(Path.GetFileNameWithoutExtension("Hello"));
            AssemblyBuilder asmb = 
                System.AppDomain.CurrentDomain.DefineDynamicAssembly(name, 
                                                    AssemblyBuilderAccess.Save);
            ModuleBuilder modb = asmb.DefineDynamicModule("Hello");
            TypeBuilder typeBuilder = modb.DefineType("Bar");
            MethodBuilder methb = 
                typeBuilder.DefineMethod("Me", MethodAttributes.Static, 
                                            typeof(void), System.Type.EmptyTypes);
            ILGenerator gen = methb.GetILGenerator();

            ConstructorInfo cil = typeof(Research.Dog).GetConstructor(new Type[] { });
            gen.Emit(OpCodes.Newobj, cil);
            gen.Emit(OpCodes.Call, typeof(Research.Dog).GetMethod("Bark"));
            gen.Emit(OpCodes.Ret);
        }
    }
    public class Dog
    {
        public void Bark()
        {
            Console.WriteLine("How are you doing");
        }
    }
}

C:\temp\Research\Research\bin\Release>peverify
Research.exe

Microsoft (R) .NET Framework PE
Verifier. Version 4.0.30319.1
Copyright (c) Microsoft Corporation.
All rights reserved.

All Classes and Methods in
Research.exe Verified.

C:\temp\Research\Research\bin\Release>

  • 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-22T21:30:21+00:00Added an answer on May 22, 2026 at 9:30 pm

    You create a dynamic assembly and then do nothing with it. Why should that print anything? Also, peverify won’t help you in any way here, because you’re not verifying the assembly you generated, you’re verifying just the assembly that’s generating it.

    You also don’t call typeBuilder.CreateType(), which is necessary and your assembly isn’t set to be able to run.

    If you use AssemblyBuilderAccess.RunAndSave and add the following code at the end of the method, it will work (at least it works for me):

    var barType = typeBuilder.CreateType();
    var meMethod = barType.GetMethod("Me", BindingFlags.Static | BindingFlags.NonPublic);
    meMethod.Invoke(null, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wrote the following in PowersHell as a quick iTunes demonstration: $iTunes = New-Object -ComObject
Using an idea from Bob King idea I wrote the following method. It works
I was having trouble with a nullable type so I wrote the following program
I am trying to write a C++ program that takes the following inputs from
I wrote the following javascript to put in my startup folder to work around
I wrote the following Nant script on my Vista dev machine and was pleased
I just wrote the following C++ function to programmatically determine how much RAM a
In C++Builder, I wrote the following code (in Button1Click handler), When I run in
I needed some simple string encryption, so I wrote the following code (with a
I wrote a managed C++ class that has the following function: void EndPointsMappingWrapper::GetLastError(char* strErrorMessage)

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.