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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:01:38+00:00 2026-06-09T13:01:38+00:00

For the sake of learning, I’m trying to call an Assembly function from C#.

  • 0

For the sake of learning, I’m trying to call an Assembly function from C#. I’m working in a very sterile project doing everything as simply as I can. Here’s my assembly (mostly cut and paste from codeproject):

.386
.model flat, stdcall
option casemap :none

include \masm32\include\masm32rt.inc

.code
LibMain proc instance:dword,reason:dword,unused:dword 
     mov     eax,1
     ret
LibMain     endp
PrintMess proc
     print "Test"
     exit
PrintMess endp
End LibMain

Note: The assembly builds just fine. No errors and the only warning is that masm32rt.inc has another .model line that the assembler is ignoring, this warning is fine. I’ve set up my environment using these instructions.

For C#, a language I’m much more familiar with, I’ve tried 2 main approaches: Reflection and adding the DLL as a reference. Both give me an error saying that an assembly manifest is expected. Here I’m at a lose.

My C# is simply:

Assembly mylib = Assembly.LoadFile(@"C:\mypath\MyLib.dll");

And I get The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018) as an error on that line. I don’t know anything about assembly manifests. Any direction towards how to create and embed one 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-09T13:01:40+00:00Added an answer on June 9, 2026 at 1:01 pm

    The word “assembly” can mean two things. When you use MASM, assembly means “machine code”. When you use .NET, assembly means “container of managed code”.

    Assembly.LoadXxx() can only load .NET assemblies that were created with .NET tools. it cannot load DLLs that contain pure machine code. You’ll need to use pinvoke with the [DllImport] attribute to call the functions in the DLL.

    You’d also better check that your DLL actually exports the functions. At the Visual Studio Command Prompt, run dumpbin.exe /exports on your DLL to see the exported names. Some odds that you won’t see “PrintMess”, you need to pass a .def file to the linker to tell it which functions need to be exported.

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

Sidebar

Related Questions

For the sake of learning, I'm trying to chain decorators that are defined by
Im trying to make a simple app (just for learning sake) that will be
Just for learning's sake, I tried in java doc but I did not find
For the sake of convenience I am trying to assign multiple values to a
I am learning multi-threading and for the sake of understanding I have wriiten a
Learning django & python. Just set up a new site after doing the tutorial.
I'm new to ASP.NET MVC and I'm trying to create a very simple blog
For the sake of learning i'm making a timer. Used an NSTimer but it
For the sake of learning combinatorics of boost::thread I'm implementing a simple barrier (BR)
Doing some initial research on a new project and one of my requirements is

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.