1

am developing a flash copy protect software with c#. The software is to remain on the flash drive(can not be transfered out or installed in the computer), it is a click and run software, no installation. I know that for it to work on other computers, the computer must have .net framework installed in it. I was thinking if it can be possible to add .net framework dll to the startup path of the application. If it will work, pls let me know and how to do it.

If there are other methods besides switching my project to C or C++, pls let me know. Thanks.

  • 1
    Is .NET Native the droid you are looking for? https://learn.microsoft.com/en-us/dotnet/framework/net-native/ | However teh requirment itself is wierd. This will only run on Windows. And all Windows this side of XP have some Framework installed. – Christopher Jun 01 '20 at 19:28
  • @Christopher. i dont know, can i do windows form application with .net native? – Adorable Laughter Jun 01 '20 at 19:32

1 Answers1

2

In normal .NET compilation (regardless of source language), the product is a (MS)IL - (Microsoft) Intermediate Language - dll. In case of executeables, it is given some native bootstrap code, a entry point, but it is still stricly tied to the Framework installation and works for nearly everything like a .NET dll. The Framework has to do the final IL -> Native Code translation. IL is a concept very similar to Java Bytecode, but with about 5 years of what works and does not work in Java.

.NET Native does not compile IL. It compiles hard, native code. Similar to the one any Native C++ (not to be mistaken with C++ .NET) compiler would make. The same a Delphi compiler would make. The same the Framework itself is written in. The final programm will have local copies of all the .NET .dll's it accesses. It is fully independant of any .NET Framework installation.

Christopher
  • 9,634
  • 2
  • 17
  • 31
  • Ok but I don't see c# .net native on my visual Studio 2010. Do I have to download it? – Adorable Laughter Jun 02 '20 at 03:14
  • @AdorableLaughter 2010 might be a few years to old. It seems to exist for 2015 at least: https://stackoverflow.com/a/32009939/3346583 | Edit: Yeah, it was added with 2015 earliest. – Christopher Jun 02 '20 at 03:42
  • @AdorableLaughter The original announcements said it would not work for Windows Forms, as Native is related to Core and Core did not have WindowsForms support back then. However, in the meantime Core got Windows Form support introduced. | I can only advise to ge the last Visual Studio community edition and hope for the best. – Christopher Jun 02 '20 at 03:49
  • @AdorableLaughter On the question of ".NET Native + WindowsForms", I got a answer from a MSFT guy: https://stackoverflow.com/a/33768621/3346583 | It should be more likely to work under .NET 5 and 6 "Brands". | WinForms is a tricky technology, as it has been technically Deprecated for 2 decades now. Programmers just will not let it die. – Christopher Jun 03 '20 at 07:37
  • I learnt that all computers have a .net framework installed in them, it might be a low version. So I redevelop the software in .net framework version 2 and it worked. I can run it on different computers with low .net framework now. – Adorable Laughter Jun 05 '20 at 03:56
  • @AdorableLaughter I did mention that in my original comment, but not the answer attempt. It may fail for some extreme cases, like Windows PE: the https://en.wikipedia.org/wiki/Windows_Preinstallation_Environment But overall that should be a valid option. – Christopher Jun 05 '20 at 19:35