This question already has answers here:
What are .NET Assemblies?
(13 answers)
Closed 6 years ago.
Are assemblies basically executable files? Thanks. I'm writing more because I can't bypass quality standards and it needs more words in my current problem written in.
No they are not executable files. As it is stated here:
In general, a static assembly can consist of four elements:
The assembly manifest, which contains assembly metadata.
Type metadata.
Microsoft intermediate language (MSIL) code that implements the types.
A set of resources.
Actually an assembly is loaded in the runtime environemt (CLR) and the MSIL code is compiled to native code on demand (this is called just in time compliation).
Related
This question already has answers here:
Is it possible to embed C code in a C# project?
(4 answers)
Closed 6 years ago.
I have C++ legacy code with functions in the form:
double func(double)
I have this as a source file - it isnt in the form of a DLL although it could be turned into one if necessary
How can I call func in my C# code (maybe over managed C++)? I heard of Marshalling and DllImport but I did not find MSDN very helpful.
You have to compile C++ code as DLL library and then DllImport is way to go.
I don't know what problem you have with it. On MSDN I found this https://msdn.microsoft.com/en-us/library/e59b22c5.aspx
And also this article: http://www.mono-project.com/docs/advanced/pinvoke/ seems to be quite useful.
This question already has answers here:
How can I specify a [DllImport] path at runtime?
(10 answers)
Closed 6 years ago.
I am hoping this is a simple question but I have not been able to find the solution in my searching. I have a C# application that needs to load data from several DLLs. Each DLL is guaranteed to have the same function foo(). But I want these DLLs to be plug and play at run time. The way I usually handle DLLs (where I know the name) is using:
[DllImport("my_dll.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int foo();
How do I do this with a dynamic string for a file name instead (e.g., "my_dll_3934.dll")? Also, there may be more than 1 dll that must be loaded that matches the same signature (e.g., "my_dll_3934.dll" and "my_dll_3935.dll").
The DLLs that will be used are generated by me but I want the end-user to just drop the DLL in as updates/new dlls become available without updating the application. I will be doing appropriate error checking and exception handling.
Thank you in advance.
Answer to my question can be found here:
How can I specify a [DllImport] path at runtime?
in the comment by user Ran. Thanks to Hackerman for pointing me to the correct solution.
This question already has answers here:
How do I merge multiple .net assemblies into a single assembly?
(3 answers)
Closed 6 years ago.
My project is of type "Class library" and has a reference to "Newtonsoft.Json". I would like to have one single DLL as output so that other consumers only have to exchange one DLL. Right now, the project builds to two single DLLs.
I have set "Embed Interop Types" to "True" for "Newtonsoft.Json" which resulted in an error ("Cannot embed interop types because it is missing either the 'ImportedFromTypeLibAttribute' attribute or the 'PrimaryInteropAssemblyAttribute' attribute..").
I have also found many other posts regarding this problem, but most of these posts were about including DLLs in a .exe which I do not have.
How can I merge both DLLs?
Have you tried using an external tool like ILMerge (https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=17630) ?
This question already has answers here:
How do I decompile a .NET EXE into readable C# source code?
(9 answers)
Closed 7 years ago.
I have a dll file that I want to decompile. I know there are ILSpy, dotPeek and similar programs, but I have yet to find one that will actually create the cs file.
The dll I'm dealing with has several hundred classes in it and it would take days to manually copy everything.
Is there a tool that will take a dll file and return a set of cs files?
ILSpy
If you have loaded a dll in ILSpy, select File -> Save Code... or type Ctrl + S.
If you select the dll in the tree, then it will create a cs
project in a selected folder, along with C# files for each
class.
If you select just a class in the tree, it will create just
the C# file for the class.
See ILSpy.
This question already has an answer here:
How can we add embedded resources to a file which is compiled from a source file at run-time
(1 answer)
Closed 9 years ago.
I am generating C# code at runtime and compiling it with the CSharpCodeProvider The two problems I'm having are
How to add resources to the generated exe?
How to set the executable description (i.e company name and others) to it?
Thanks.
Have a look here my friend. I think this will sort you out as the guy was having the very same issue:
How can we add embedded resources to a file which is compiled from a source file at run-time