1,
---------------------------
Microsoft Visual Studio
---------------------------
无法打开项目文件“C:/documents and Settings/administrator/Local Settings/Temp/5plaia1i.o42/Temp/WpfApplication1.csproj”。
此安装不支持该项目类型。
---------------------------
确定 帮助
---------------------------
2,
c#设计视图不能用
3,
在创建一个silverlight application时,总是报错:
无法打开项目文件“c:/documents and settings /administrator/localsettings/Temp/silverlightApplication.csproj”
此安装不支持该项目类型
上面三个问题的解决办法:
开始菜单–>Microsoft Visual Studio 2008–>Visual Studio Tools->Visual Studio 2008 Command Prompt(命令提示符)
运行: devenv /resetSkipPkgs
--------------------------------
引用命名空间 using System.Drawing;
产生随机字符串
public string MakeValIDateCode()
{
char[] s = new char[] { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };//枚举数组
string num = "";
Random r = new Random();
for (int i = 0; i < 5; i++)
{
num += s[r.Next(0,s.Length)].ToString();
}
return num;
}
产生图片
private voID CreateCheckCodeImage(string checkCode)
{ //将验证码生成图片显示
if (checkCode == null || checkCode.Trim() == String.Empty)
return;
System.Drawing.Bitmap image = new System.Drawing.Bitmap((int)Math.Ceiling((checkCode.Length * 12.5)),22);
Graphics g = Graphics.FromImage(image);
//生成随机生成器
Random random = new Random();
//清空图片背景色
g.Clear(color.White);
//画图片的背景噪音线
for (int i = 0; i < 25; i++)
{
int x1 = random.Next(image.WIDth);
int x2 = random.Next(image.WIDth);
int y1 = random.Next(image.Height);
int y2 = random.Next(image.Height);
g.Drawline(new Pen(color.Silver),x1,y1,x2,y2);
}
Font Font = new System.Drawing.Font("Arial",12,(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic));
System.Drawing.drawing2d.linearGradIEntBrush brush = new System.Drawing.drawing2d.linearGradIEntBrush(new Rectangle(0,image.WIDth,image.Height),color.Blue,color.DarkRed,1.2f,true);
g.DrawString(checkCode,Font,brush,2,2);
//画图片的前景噪音点
for (int i = 0; i < 100; i++)
{
int x = random.Next(image.WIDth);
int y = random.Next(image.Height);
image.SetPixel(x,y,color.FromArgb(random.Next()));
}
//画图片的边框线
g.DrawRectangle(new Pen(color.Silver),image.WIDth - 1,image.Height - 1);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
image.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);
Response.ClearContent();
Response.ContentType = "image/Gif";
Response.BinaryWrite(ms.ToArray());
}
用这两个函数放在一个GetValCode.aspx里面,用一个session["curValCode"]保存随机字符串:
protected voID Page_Load(object sender,EventArgs e)
{
string valCode = MakeValIDateCode();
Session["curValCode"] = valCode;
CreateCheckCodeImage(valCode);
}
Register.aspx调用<img src="GetValCode.aspx" />
在Register.aspx里用session["curValCode"]来检查
总结以上是内存溢出为你收集整理的VS2005/2008出错判断-生成验证码全部内容,希望文章能够帮你解决VS2005/2008出错判断-生成验证码所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)