What exactly is Common Language Runtime [duplicate] - c#

This question already has answers here:
CLR and CLI - What is the difference?
(7 answers)
Closed 5 years ago.
What exactly is Common Language Runtime in Dot Net. Is it an exe or dll. Can I see common language runtime in task manager. Where is it located.

You should first look up in google before posting here.. But here it goes:
What is it?
The .NET Framework provides a run-time environment called the common language runtime, which runs the code and provides services that make the development process easier.
Where is it located?.
C:\Windows\Microsoft.NET\Framework\v2.0.50727
Of course the last part depends on your version.

Related

How to detect C# (not CLR) version programmatically? [duplicate]

This question already has answers here:
Which version of C# am I using
(20 answers)
Closed 3 years ago.
I use C# for .NET. I know how to programmatically detect CLR version of a .NET assembly, but can’t find out how to programmatically detect the C# version in my code. Anyone has idea? TIA.
The C# source code has been translated to IL when the assembly is generated. It's no longer relevant what C# version was used to generate the IL (or indeed, if C# was used), nor is that information stored.
There are some IL features that will not be used by older versions of C# (e.g. support for nullable reference types and async streams). If the IL contains such constructs, you can rule out older C# versions. It's highly non-trivial to make that determination.
Here's a breakdown of the assembly format (click through to the second article in the series). You'll see there's no information describing the language or version that generated the assembly.
https://www.red-gate.com/simple-talk/blogs/anatomy-of-a-net-assembly-pe-headers/

What was the first version of roslyn compiled with [duplicate]

This question already has answers here:
What is the language of compilers? Are they written with different languages?
(5 answers)
In what language is C# compiled [closed]
(3 answers)
What are modern and old compilers written in?
(7 answers)
Closed 5 years ago.
Looking at the github repo, I see that roslyn is written in C# and VB, the same languages that it is meant to compile. It would make sense that each version is compiled using the version that came before it but, if that is the case, how was the first ever version compiled?
Its called bootstrapping
I can tell thats confusing, it's a kind of "the chicken and egg" problem, but it has a rather elegant solution.
In basic terms what you do is make a basic version of the compiler in a pre-existing language compiler.
Using that compiler you compile a compiler code for the language written in itself.
Imagine you write a c# compiler in java, and then you using that compiler written in java to compile and run a compiler written in c# that knows how to compile c#.
But then you say "But what about the first compiler ever, there was no language before that!" its answered here, in short: they wrote a compiler in literal bytes just like a compiler would emit for a cpu to run. after that worked they could theoretically write a compiler in that language.

How do I call a native library from C#? [duplicate]

This question already has answers here:
C# library to native C++ application
(3 answers)
Closed 3 years ago.
What is the best solution to access c# code via native code (C++)?
I have C# code which I want to call from native project, so I'm considering writing a COM wrapper but I wonder whether there is a better option (framework/design pattern/architecture etc.) available in .NET?
COM interop is without a doubt the best bet. It's a known, supported framework for achieving exactly what you want to achieve.
There is another alternative however - it is possible to edit the IL code inside a compiled .NET assembly to flag methods within the assembly as native exports. A detailed breakdown of the changes can be found in this CodeProject article.
Robert Giesecke has created Unmanaged Exports to simplify this process using simple method attributes. A NuGet package can be found here.

Convert Java class to DLL [duplicate]

This question already has answers here:
Is there any way to compile Java code into a DLL?
(3 answers)
Closed 9 years ago.
I need to use Java code in .NET (C#) and am looking for a way to convert a Java class to a DLL file (which I can then reference in my .NET app). Is this a valid scenario? If yes, How can I do it?
You can use IKVM.NET to use Java classes and libraries from .NET.
Basically that is not a good idea. Since java emphasizes on platform independence, but dll is platform dependent. So, think about pack into a jar file, execute and consume it somehow
May be this link will be useful for you:
http://www.codeproject.com/Articles/13549/Using-Java-Classes-in-your-NET-Application
For this you can use IKVM.NET.

Deploying C# application (Obfuscation) [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Best .NET obfuscation tools/strategy
Should you obfuscate a commercial .Net application?
Good day everyone.
I'm ready to release a small c# game, but I've heard that it is extremely easy to disassemble/decompile c# application if it is "deployed" as it is. So my question - what can I do to prevent, or at least make it harder for people to disassemble/decompile my application?
Is there more then one way? If so, what do you think is best?
UPD: As was pointed below using default obfuscator might pose some problem with reflections, because I use lua interpreter for ingame scripts.
Thanks in advance.
Visual studio contains the "Dotfuscator" (Tools->Dotfuscator Software Services in VS 2010) which obfuscates your code for you. It can pose certain problems if you implement reflection in your code, but it does give you options as to what you want it to do to your code, so there is some flexibility there as well.

Categories

Resources