06-10-12, 07:57 PM
الآن سنقوم بعمل ترجمة للكود وتطبيقه
في أول الكود قمنا بانشاء CodeCompileUnit
التى تقوم باعطاء معلومات عن التطبيق من خلال Method
ثم نضيف ذلك إلى فضاء الاسم
)
ُثم أنشأنا عنصر نرسل له خصائص العنصر Compiler
ثم أرسلنا ثلاث خصائص
الخاصية الأول أعطت الصلاحية للكومبيلر بعمل ال Generation فى الذاكرة
والخاصية الثانية اعطت له الصلاحية بعمل ملف تنفيذى
والثالثة أعطت مسار انشاء الملف واسمه
===================
أنشانا Complier
ثم سنمرر للكائن CompilerResults الخواص و Compiler
كود :
Dim Compile_inCreateApp As New CodeCompileUnit
Compile_inCreateApp.Namespaces.Add(NameSpace_inCreateApp)
Dim CompilingParams As New Compiler.CompilerParameters()
CompilingParams.ReferencedAssemblies.Add("system.dll")
CompilingParams.GenerateInMemory = False
CompilingParams.GenerateExecutable = True
CompilingParams.OutputAssembly = "c:\BADRMEDIA.exe"
Dim CodeProvider As New Microsoft.VisualBasic.VBCodeProvider
Dim Compiler As ICodeCompiler = CodeProvider.CreateCompiler
Dim CompilerResult As CompilerResults = Compiler.CompileAssemblyFromDom(CompilingParams, Compile_inCreateApp)في أول الكود قمنا بانشاء CodeCompileUnit
كود :
Dim Compile_inCreateApp As New CodeCompileUnitثم نضيف ذلك إلى فضاء الاسم
كود :
Compile_inCreateApp.Namespaces.Add(NameSpace_inCreateAppُثم أنشأنا عنصر نرسل له خصائص العنصر Compiler
كود :
Dim CompilingParams As New Compiler.CompilerParameters()ثم أرسلنا ثلاث خصائص
كود :
CompilingParams.GenerateInMemory = False
CompilingParams.GenerateExecutable = True
CompilingParams.OutputAssembly = "c:\BADRMEDIA.exe"الخاصية الأول أعطت الصلاحية للكومبيلر بعمل ال Generation فى الذاكرة
والخاصية الثانية اعطت له الصلاحية بعمل ملف تنفيذى
والثالثة أعطت مسار انشاء الملف واسمه
===================
أنشانا Complier
كود :
Dim Compiler As ICodeCompiler = CodeProvider.CreateCompilerثم سنمرر للكائن CompilerResults الخواص و Compiler
كود :
Dim CompilerResult As CompilerResults = Compiler.CompileAssemblyFromDom(CompilingParams, Compile_inCreateApp)