c#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace ReflectionCS
{
class Program
{
static void Main(string[] args)
{
String path = @"C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll";
Assembly assembly = Assembly.LoadFile(path);
ShowAssemblyInfo(assembly);
Assembly currentAssembly = Assembly.GetExecutingAssembly();
ShowAssemblyInfo(currentAssembly);
Console.ReadLine();
}
static void ShowAssemblyInfo(Assembly assembly)
{
Console.WriteLine(assembly.FullName);
Console.WriteLine("From GlobalAssemblyCache? {0}", assembly.GlobalAssemblyCache);
Console.WriteLine("Path: {0}", assembly.Location);
Console.WriteLine("Version: {0}", assembly.ImageRuntimeVersion);
foreach (Module module in assembly.GetModules())
{
Console.WriteLine("Module: {0}", module.Name);
}
Console.WriteLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace ReflectionCS
{
class Program
{
static void Main(string[] args)
{
String path = @"C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll";
Assembly assembly = Assembly.LoadFile(path);
ShowAssemblyInfo(assembly);
Assembly currentAssembly = Assembly.GetExecutingAssembly();
ShowAssemblyInfo(currentAssembly);
Console.ReadLine();
}
static void ShowAssemblyInfo(Assembly assembly)
{
Console.WriteLine(assembly.FullName);
Console.WriteLine("From GlobalAssemblyCache? {0}", assembly.GlobalAssemblyCache);
Console.WriteLine("Path: {0}", assembly.Location);
Console.WriteLine("Version: {0}", assembly.ImageRuntimeVersion);
foreach (Module module in assembly.GetModules())
{
Console.WriteLine("Module: {0}", module.Name);
}
Console.WriteLine();
}
}
}
vb.net:
Imports System.Reflection
Module Module1
Sub Main()
Dim path As String = "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll"
Dim assembly As Assembly = assembly.LoadFile(path)
ShowAssemblyInfo(assembly)
Dim currentAssembly As Assembly = assembly.GetExecutingAssembly()
ShowAssemblyInfo(currentAssembly)
Console.ReadLine()
End Sub
Sub ShowAssemblyInfo(ByVal assembly As Assembly)
Console.WriteLine(assembly.FullName)
Console.WriteLine("From GlobalAssemblyCache? {0}", assembly.GlobalAssemblyCache)
Console.WriteLine("Path: {0}", assembly.Location)
Console.WriteLine("Version: {0}", assembly.ImageRuntimeVersion)
For Each [Module] As [Module] In assembly.GetModules
Console.WriteLine("Module: {0}", [Module].Name)
Next
Console.WriteLine()
End Sub
End Module
Module Module1
Sub Main()
Dim path As String = "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll"
Dim assembly As Assembly = assembly.LoadFile(path)
ShowAssemblyInfo(assembly)
Dim currentAssembly As Assembly = assembly.GetExecutingAssembly()
ShowAssemblyInfo(currentAssembly)
Console.ReadLine()
End Sub
Sub ShowAssemblyInfo(ByVal assembly As Assembly)
Console.WriteLine(assembly.FullName)
Console.WriteLine("From GlobalAssemblyCache? {0}", assembly.GlobalAssemblyCache)
Console.WriteLine("Path: {0}", assembly.Location)
Console.WriteLine("Version: {0}", assembly.ImageRuntimeVersion)
For Each [Module] As [Module] In assembly.GetModules
Console.WriteLine("Module: {0}", [Module].Name)
Next
Console.WriteLine()
End Sub
End Module
posted @ 2009-05-04 09:57 N/A2011 阅读(79) 评论(0) 编辑
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;
using System.ComponentModel;
using System.Net.Mime;
namespace Email
{
class Program
{
static void Main(string[] args)
{
MailMessage mm = new MailMessage();
mm.From = new MailAddress("email@email.com", "Joey");
mm.To.Add(new MailAddress("email@email.com", "Joey"));
mm.Subject = "Email sending test";
string htmlBody = "<html><body><h1>Picture</h1><br><img src=\"cid:Pic\"></body></html>";
AlternateView avHtml = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);
LinkedResource pic = new LinkedResource("pic.jpg", MediaTypeNames.Image.Jpeg);
pic.ContentId = "Pic";
avHtml.LinkedResources.Add(pic);
mm.AlternateViews.Add(avHtml);
string textBody = "You must use an e-mail client that supports HTML messages";
AlternateView avText = AlternateView.CreateAlternateViewFromString(textBody, null, MediaTypeNames.Text.Plain);
mm.AlternateViews.Add(avText);
SmtpClient sc = new SmtpClient("host");
sc.Credentials = new NetworkCredential("username", "password");
sc.SendCompleted += new SendCompletedEventHandler(sc_SendCompleted);
sc.SendAsync(mm, null);
sc.SendAsyncCancel();
}
static void sc_SendCompleted(object sender, AsyncCompletedEventArgs e)
{
if (e.Cancelled)
Console.WriteLine("Message cancelled");
else if (e.Error != null)
Console.WriteLine("Error: " + e.Error.ToString());
else
Console.WriteLine("Message sent");
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;
using System.ComponentModel;
using System.Net.Mime;
namespace Email
{
class Program
{
static void Main(string[] args)
{
MailMessage mm = new MailMessage();
mm.From = new MailAddress("email@email.com", "Joey");
mm.To.Add(new MailAddress("email@email.com", "Joey"));
mm.Subject = "Email sending test";
string htmlBody = "<html><body><h1>Picture</h1><br><img src=\"cid:Pic\"></body></html>";
AlternateView avHtml = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);
LinkedResource pic = new LinkedResource("pic.jpg", MediaTypeNames.Image.Jpeg);
pic.ContentId = "Pic";
avHtml.LinkedResources.Add(pic);
mm.AlternateViews.Add(avHtml);
string textBody = "You must use an e-mail client that supports HTML messages";
AlternateView avText = AlternateView.CreateAlternateViewFromString(textBody, null, MediaTypeNames.Text.Plain);
mm.AlternateViews.Add(avText);
SmtpClient sc = new SmtpClient("host");
sc.Credentials = new NetworkCredential("username", "password");
sc.SendCompleted += new SendCompletedEventHandler(sc_SendCompleted);
sc.SendAsync(mm, null);
sc.SendAsyncCancel();
}
static void sc_SendCompleted(object sender, AsyncCompletedEventArgs e)
{
if (e.Cancelled)
Console.WriteLine("Message cancelled");
else if (e.Error != null)
Console.WriteLine("Error: " + e.Error.ToString());
else
Console.WriteLine("Message sent");
}
}
}
posted @ 2009-05-04 06:37 N/A2011 阅读(47) 评论(0) 编辑
