程序集生成失败 -- 引用的程序集“ThoughtWorks.QRCode”没有强名称,为没有源码的程序集强签名

如果你写的程序程序集是带签名的,应用了没有签名的程序集,编译就会报下面的错误

 引用的程序集“**”没有强名称

进入sdk提示符界面,依次输入如下指令

sn -k ThoughtWorks.QRCode.snk

ildasm ThoughtWorks.QRCode.dll /out=ThoughtWorks.QRCode.il

ilasm ThoughtWorks.QRCode.il /dll /resource=ThoughtWorks.QRCode.res /key=ThoughtWorks.QRCode.snk /optimize

sn -v ThoughtWorks.QRCode.dll

安装程序集

Install-Package ThoughtWorks.QRCode -Version 1.1. 
 /// <summary>
/// 二维码生成与解析帮助类
/// </summary>
public class QRCodeHelper
{
/// <summary>
/// 根据字符串生成二维码
/// </summary>
/// <param name="val"></param>
public static void GenQRCode(string val,Stream stream)
{
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
qrCodeEncoder.QRCodeScale = ;
qrCodeEncoder.QRCodeVersion = ;
qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
using (System.Drawing.Image image = qrCodeEncoder.Encode(val))
{
image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
stream.Close();
image.Dispose();
}
} /// <summary>
/// 根据图片文件路径解析二维码
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static string CodeDecoder(string filePath)
{
string decodedString = string.Empty;
if (System.IO.File.Exists(filePath))
{
using (Bitmap myBitmap = new Bitmap(Image.FromFile(filePath)))
{
QRCodeDecoder decoder = new QRCodeDecoder();
decodedString = decoder.decode(new QRCodeBitmapImage(myBitmap));
}
}
return decodedString;
}
}
上一篇:Eclipse用法和技巧十六:自动添加未实现方法2


下一篇:002_tmux详解