Hack Forums
[C#] C# .exe to .dll / execute or run .dll as if it were a .exe - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] C# .exe to .dll / execute or run .dll as if it were a .exe (/showthread.php?tid=5306279)



C# .exe to .dll / execute or run .dll as if it were a .exe - UnisBot - Jun 15, 2016

Okay so for example I have 2 projects, Form1.exe & console1.exe, what I want is to execute console1.exe within form1.exe, so I used,

Code
if (isLogin(true))
        {
            MessageBox.Show($"Welcome!");
            Process.Start("console1.exe");

Now the problem with this is, in order to execute console1.exe the user must store that file locally, now the issue with that is, he/she can execute console1.exe without executing form1.exe

So what I did was used ILMerge to merge the .exe's as you would a .dll but it's unable to now find console1.exe, so merging didn't work.

So now my conclusion was to reopen visual studio & create a reference .dll out of console1.exe.

Problem with this is executing the .dll as if it were still a .exe without calling methods separately, so to execute the file as if it were one method.

So basically executing the parent class, which will then follow up with the sub classes.

Now is there anyway I can reference console1.exe and merge it to form1.exe preventing users from running it as a solo application, or is it possible to set rules on console1.exe that it may not execute unless called from form1.exe, or the second conclusion to run it as a .dll reference library in one command not multiple sub classes.


* - Zilog80 - Jun 16, 2016

1) Add console1.exe as resource in form1 project settings
2) when you need execute console1.exe from form1.exe simply extract the console1.exe resource to temp folder (Windows Temp folder would be nice)
3) execute console1.exe with wait for exit
4) after wait for exit delete console1.exe, so user can't use it.

Profit.


* - BahNahNah - Jun 16, 2016

One method would be encrypting console1 using the login details as the encryption key then but that in resources.
When someone logs in, decrypt the resource and use reflection to run the program.


* - Johansinan - Sep 15, 2016

i go t a file in my flash disk :
filename : extract_sound.exe
icon : zip/rar icon
size : 81mb
when i double click on it
then just show up a new windows at directory "libraries"
no activity happen

How can i get open the file inside?


* - Corios - Sep 15, 2016

Why not just move the code from console1 to form1...


* - Johansinan - Sep 15, 2016

how to move it,,i don't understand


* - Sakuto - Sep 16, 2016

(Sep 15, 2016 11:15 PM)Johansinan Wrote:  i go t a file in my flash disk :
filename : extract_sound.exe
icon : zip/rar icon
size : 81mb
when i double click on it
then just show up a new windows at directory "libraries"
no activity happen

How can i get open the file inside?
Please create a thread with your question and not use another one unrelated.
(Sep 15, 2016 11:39 PM)Corios Wrote:  Why not just move the code from console1 to form1...
Not the same question