ZXing在C#.NET 2013中无法编码 [英] ZXing failing on encode in C#.NET 2013

查看:80
本文介绍了ZXing在C#.NET 2013中无法编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS 2013并尝试使用zxingnet.codeplex.com中的ZXing.NET.0.14.0.0实现来创建QRCodes。我在执行下面的代码时收到错误QRCodeWriter.cs。以下是错误的具体内容;



未找到来源

未找到QRCodeWriter.cs

您需要找到QRCodeWriter.cs来查看当前调用堆栈帧的来源

尝试以下选项之一:

-Browse并找到QRCodeWriter.cs ...

您可以在反汇编窗口中查看反汇编。始终查看缺失源文件的反汇编。更改选项对话框中的设置。

源搜索信息

**这里看起来正在搜索目录以查找文件

QRCodeWriter是第一个在示例中使用的方法,这是我正在使用的。不知道为什么它正在寻找.cs文件。



这是示例代码。它在编码行(第一个例子中的第3行)上失败并出现上述错误。



I am using VS 2013 and trying to use ZXing.NET.0.14.0.0 implementation from zxingnet.codeplex.com to create QRCodes. I am getting the error QRCodeWriter.cs not found when executing the code below. Here are the specifics of the error;

Source Not Found
QRCodeWriter.cs not found
You need to find QRCodeWriter.cs to view the source for the current call stack frame
Try one of the following options:
-Browse and find QRCodeWriter.cs...
You can view disassembly in the Disassembly window. To always view disassembly for missing source files. change the setting in the Options dialog.
Source search information
** Here it looks like it is searching through directories to find the file
QRCodeWriter is the method first being used in the example, which is all I am using. Not sure why it's looking for the .cs file though.

Here is the sample code. It is failing on the encode line (3rd line in the 1st example) with the error above.

using ZXing.QrCode;
using ZXing.QrCode.Internal;

namespace QRCodeTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
		QRCodeWriter qr = new ZXing.QrCode.QRCodeWriter();
		string url = "http://www.bing.com/";
		var matrix = qr.encode(url, BarcodeFormat.QR_CODE, 200, 200); //Failing here
		ZXing.BarcodeWriter w = new ZXing.BarcodeWriter();
		w.Format = ZXing.BarcodeFormat.QR_CODE;
		Bitmap img = w.Write(matrix);
		img.Save(@"C:\Users\Frank\Documents\myQR.png", System.Drawing.Imaging.ImageFormat.Png);
        }
    }
}





希望比我聪明的人能告诉我我的意思我在这做错了。在此先感谢!



Hopefully someone a lot smarter than me can tell me what I am doing wrong here. Thanks in advance!

推荐答案

看起来它正在寻找.cs代码向您显示'错误'的来源

我我要看



it looks like its looking for the .cs code to show you the source of 'an error'
I'd be looking at

QRCodeWriter qr = new ZXing.QrCode.QRCodeWriter();





并用try / catch和/或null测试包装它以查看'qr'是否是一个有效的对象 - 顺便说一下,你真的需要做吗?





and wrapping it with a try/catch and/or null test to see if 'qr' is a valid object - btw, do you really need to do

ZXing.QrCode.QRCodeWriter()





?我在他们的例子中注意到 http://zxingnet.codeplex.com/SourceControl /latest#trunk/Source/test/src/qrcode/QRCodeWriterTestCase.cs [ ^ ]如果你有正确的'使用'语句,你应该可以这样做





? I note in their example http://zxingnet.codeplex.com/SourceControl/latest#trunk/Source/test/src/qrcode/QRCodeWriterTestCase.cs[^] if you have the correct 'using' statements, you should be able to do this

QRCodeWriter writer = new QRCodeWriter();







这可能没有用 - 抱歉




this may not be helpful - sorry


感谢您的关注!对不起那是我尝试不同的东西,我只是忘了改回来。实例化对象的代码应该是

Thanks for looking! Yeah sorry. That was me trying something different and I just forgot to change it back. The code to instantiate the object should be
QRCodeWriter qr = new QRCodeWriter();





仍然无效。



如果我删除



which still doesn't work.

If I remove

using ZXing.QRCode;



它告诉我在错误列表无法找到类型或命名空间名称QRCodeWriter(您是否缺少或使用指令或程序集引用?)

并且在该示例中您指向它不包括好奇。我把它放回去没有设计时错误,但我仍然得到相同的运行时错误。


It tells me in the Error List that "the type or namespace name QRCodeWriter could not be found (are you missing or using directive or an assembly reference?)"
and in that example you pointed to it does not include that which is curious. I put it back and no design time errors but I still get the same runtime error.


这篇关于ZXing在C#.NET 2013中无法编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆