Hack Forums
[.NET] Need CodeDom builder tutorial. - 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: [.NET] Need CodeDom builder tutorial. (/showthread.php?tid=4400389)



Need CodeDom builder tutorial. - Voidlight - Aug 17, 2014

I have searched a lot on google, and using the hackforums search function, like i know you will all tell me to do, but i have just come up with a lot of errors or just dont understand it.

Could someone walk me through a codedom compiling example with string replacement within the stub located in the resources? Or, link me to a working and usable example that i could learn from? thanks.


* - TheBarret - Aug 17, 2014

(Aug 17, 2014 08:45 AM)Sυιcιɗє SιƖєηcє Wrote:  I have searched a lot on google, and using the hackforums search function, like i know you will all tell me to do, but i have just come up with a lot of errors or just dont understand it.

Could someone walk me through a codedom compiling example with string replacement within the stub located in the resources? Or, link me to a working and usable example that i could learn from? thanks.

Qeustion is, at what level are ya, plain said, what do you know.


* - He B TeMy - Aug 17, 2014

I'll give you mine, editing this shortly.

Code
Private Sub CompileApp(ByVal filename As String)
      Dim provider As CodeDomProvider = CodeDomProvider.CreateProvider("VisualBasic")

      Dim parameters As New System.CodeDom.Compiler.CompilerParameters()
      ' Add reference
      parameters.ReferencedAssemblies.Add("System.dll")
      parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll")
      parameters.ReferencedAssemblies.Add("Microsoft.VisualBasic.dll")
      parameters.ReferencedAssemblies.Add("System.Drawing.dll")

      'Compile in memory
      parameters.GenerateExecutable = True
      parameters.OutputAssembly = filename
      parameters.CompilerOptions = "/target:winexe"

      Dim strCode As String = "Your Code here"
      Dim CompileResults As New System.CodeDom.Compiler.CompilerResults(Nothing)

      CompileResults = provider.CompileAssemblyFromSource(parameters, strCode)

      If CompileResults.Errors.HasErrors Then
      ' If an error occurs
      MessageBox.Show("Error: Line>" & CompileResults.Errors(0).Line.ToString & ", " & _
      CompileResults.Errors(0).ErrorText)
      End If

    End Sub

Found this, hope it helps. It's from a working example i got here laying...


* - Only3 - Aug 17, 2014

i think its well explained
https://hackforums.net/showthread.php?tid=3757923
https://hackforums.net/showthread.php?tid=3579582


* - Voidlight - Aug 25, 2014

Any more? those where not very successful..


* - RKYDA - Aug 25, 2014

http://msdn.microsoft.com/en-us//library/y2k85ax6(v=vs.110).aspx

Regards,


* - Voidlight - Aug 25, 2014

(Aug 25, 2014 06:51 AM)RKYDA Wrote:  http://msdn.microsoft.com/en-us//library/y2k85ax6(v=vs.110).aspx

Regards,

Could you give a quick example using that?


* - Tostig - Aug 25, 2014

(Aug 25, 2014 08:22 AM)Sυιcιɗє SιƖєηcє Wrote:  Could you give a quick example using that?

I wish I could, but I dropped my spoon and it's dirty now.


* - Voidlight - Aug 25, 2014

(Aug 25, 2014 03:00 PM)Blixten Wrote:  I wish I could, but I dropped my spoon and it's dirty now.

A little dirt never hurt anyone, spoon feed away.


* - Earn - Aug 26, 2014

(Aug 25, 2014 08:38 PM)Sυιcιɗє SιƖєηcє Wrote:  A little dirt never hurt anyone, spoon feed away.

How about stop being a skid & trying to copy-paste other people's code. Many people have linked you to great resources. Use them.