首页上一页 1 下一页尾页 1 条记录 1/1页
引用dll文件,调用不到方法,请问这是什么原因呀?
发表在C#图书答疑
2010-07-03
是否精华
是
否
版块置顶:
是
否
[font color=#FF0000][strong]//尊敬的老师,你好,我新建了一个类项目,生成dll文件,再新建一个widows窗体项目,引用该dll文件,资源管理器中双击该dll文件在对象浏览器中却看不到有方法,代码中也调用不到,请问这是什么原因呀?[/strong][/font]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography; //加密解密用
using System.IO; //MemoryStream文件流用
namespace cls_encrypt
{
class cls_encryptString
{
public string Encryp(string what)
{
string encryptKey = "secr";//加密key
try
{
DESCryptoServiceProvider descsp = new DESCryptoServiceProvider();
byte[] key = Encoding.Unicode.GetBytes(encryptKey);
byte[] data = Encoding.Unicode.GetBytes(what.Trim());
MemoryStream MStream = new MemoryStream();
CryptoStream CStream = new CryptoStream(MStream, descsp.CreateEncryptor(key, key), CryptoStreamMode.Write);
CStream.Write(data, 0, data.Length);
CStream.FlushFinalBlock();
return Convert.ToBase64String(MStream.ToArray());
}
catch
{
return string.Empty;
}
}
public string Descryp(string what) //有返回值的方法
{
string encryptKey = "secr";//解密key
try
{
DESCryptoServiceProvider descsp = new DESCryptoServiceProvider();
byte[] key = Encoding.Unicode.GetBytes(encryptKey);
byte[] data = Convert.FromBase64String(what.Trim());
MemoryStream MStream = new MemoryStream();
CryptoStream CStream = new CryptoStream(MStream, descsp.CreateDecryptor(key, key), CryptoStreamMode.Write);
CStream.Write(data, 0, data.Length);
CStream.FlushFinalBlock();
return Encoding.Unicode.GetString(MStream.ToArray());
}
catch
{
return string.Empty;
}
}
}
}
[strong]//以下是新窗体项目代码[/strong]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using cls_encrypt;//引用加密命名空间
namespace 调用加密类dll
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Encryp Encryp = new Encryp("fdfds");
textBox1.Text = Encryp;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography; //加密解密用
using System.IO; //MemoryStream文件流用
namespace cls_encrypt
{
class cls_encryptString
{
public string Encryp(string what)
{
string encryptKey = "secr";//加密key
try
{
DESCryptoServiceProvider descsp = new DESCryptoServiceProvider();
byte[] key = Encoding.Unicode.GetBytes(encryptKey);
byte[] data = Encoding.Unicode.GetBytes(what.Trim());
MemoryStream MStream = new MemoryStream();
CryptoStream CStream = new CryptoStream(MStream, descsp.CreateEncryptor(key, key), CryptoStreamMode.Write);
CStream.Write(data, 0, data.Length);
CStream.FlushFinalBlock();
return Convert.ToBase64String(MStream.ToArray());
}
catch
{
return string.Empty;
}
}
public string Descryp(string what) //有返回值的方法
{
string encryptKey = "secr";//解密key
try
{
DESCryptoServiceProvider descsp = new DESCryptoServiceProvider();
byte[] key = Encoding.Unicode.GetBytes(encryptKey);
byte[] data = Convert.FromBase64String(what.Trim());
MemoryStream MStream = new MemoryStream();
CryptoStream CStream = new CryptoStream(MStream, descsp.CreateDecryptor(key, key), CryptoStreamMode.Write);
CStream.Write(data, 0, data.Length);
CStream.FlushFinalBlock();
return Encoding.Unicode.GetString(MStream.ToArray());
}
catch
{
return string.Empty;
}
}
}
}
[strong]//以下是新窗体项目代码[/strong]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using cls_encrypt;//引用加密命名空间
namespace 调用加密类dll
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Encryp Encryp = new Encryp("fdfds");
textBox1.Text = Encryp;
}
}
}