Note that there are some explanatory texts on larger screens.

plurals
  1. POcodedom add reference
    primarykey
    data
    text
    <p>I want make a mail sender generator . but I have problem with codedom reference . my result is : "The type or namespace name 'Mail' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)"</p> <p>I cant add system.net.mail because system.net.mail is`nt a dll file. my code :</p> <pre><code>using System; using System.Collections.Generic; using Microsoft.CSharp; using System.CodeDom.Compiler; using System.Runtime.InteropServices; namespace compilerTest { class Program { static void compileIt1() { //mail sender code string source = @" using System; using System.Collections.Generic; using System.Text; using System.Net.Mail; using System.Net; namespace mail_sender { class Program { static void Main(string[] args) { SmtpClient smtp = new SmtpClient(""smtp.gmail.com"", 587); NetworkCredential myCredentials = new NetworkCredential(""sendermail@gmail.com"", ""password""); smtp.Credentials = myCredentials; smtp.EnableSsl = true; ServicePointManager.ServerCertificateValidationCallback = (s, cert, chain, ssl) =&gt; true; smtp.Send(""sendermail@gmail.com"", ""tomaill@gmail.com"", ""titel"", ""mail body""); Console.ReadKey(); } } } "; //version Dictionary&lt;string, string&gt; providerOptions = new Dictionary&lt;string, string&gt; { {"CompilerVersion", "v3.5"} }; //code type CSharpCodeProvider provider = new CSharpCodeProvider(providerOptions); //output file CompilerParameters compilerParams = new CompilerParameters { OutputAssembly = "D:\\mailsender.EXE", GenerateExecutable = true }; compilerParams.ReferencedAssemblies.Add("System.Net.Dll"); //compile CompilerResults results = provider.CompileAssemblyFromSource(compilerParams, source); //errors Console.WriteLine("Number of Errors: {0}", results.Errors.Count); foreach (CompilerError err in results.Errors) { Console.WriteLine("ERROR {0}", err.ErrorText); } } static void Main(string[] args) { compileIt1(); Console.WriteLine("Press a key..."); Console.ReadKey(); } } } </code></pre> <p>I have : .net 3.5 VS 2010</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload