Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to write assembly code in vb.net or C#?

Tags:

.net

assembly

i know how to write MSIL code but out of curiosity i would like to know if there is a workaround to write assembly code. I can think of a way like writing the code in a string and passing it to a native windows api that executes and returns the result but not sure if this is real or even possible.

i would like to hear your opinions/suggestions.Thanks

like image 796
Ali Tarhini Avatar asked Nov 24 '10 22:11

Ali Tarhini


People also ask

Can I write assembly in C?

We can write assembly program code inside c language program. In such case, all the assembly code must be placed inside asm{} block. Let's see a simple assembly program code to add two numbers in c program.

Can you use assembly in C#?

In C#, you can use two versions of the same assembly in a single application.

What is assembly in VB net?

Assembly is a single deployable unit and consists of the MSIL, metadata, etc. Assemblies can be DLL or . EXE. Assembly is providing security and type boundary also.


1 Answers

No it is not possible to write assembly code directly in C# or VB.Net.

The closest you can get to doing this is to separate the assembly code into a native DLL which exported C style function entry points. Then PInvoke into those entry points from the C# / VB.Net application.

Another option is to use C++/CLI as it's possible to inline assembly into a C++/CLI project.

like image 71
JaredPar Avatar answered Sep 28 '22 02:09

JaredPar