[英]Showing an image in crystal report
我想在VB.net中使用Crystal Report来显示包含条形码的图像。但是,当我运行该应用程序时,尽管在我的项目中添加了crdb_adoplus.dll的引用,但在加载该报告之前遇到了以下异常。
例外:无法加载文件或程序集'crdb_adoplus,版本= 9.1.3300.0,区域性=中性,公共密钥令牌= 692fbea5521e1304'或其依赖项之一。 强名验证失败。 (来自HRESULT的异常:0x8013141A)
这是我的代码:
Private Sub Frm_Reporting_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CrystalReportViewer1.ReportSource = Nothing
Dim rptbarcode As RptPacking
rptbarcode = New RptPacking
Dim xrep As DataSet1
xrep = New DataSet1
Dim row As DataRow
Dim MyImg As Image = Nothing
Try
btnEncode(MyImg, BarcodeText)
row = xrep.Tables("DataTable1").NewRow
Dim ms As New MemoryStream()
MyImg.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim ii As Byte()
ii = ms.ToArray()
xrep.Tables("DataTable1").Rows.Add(ii)
rptbarcode.Load("GSMProduction.RptPacking.rpt")
rptbarcode.SetDataSource(xrep.Tables("DataTable1"))
CrystalReportViewer1.ReportSource = rptbarcode
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub btnEncode(ByRef pic As Image, ByVal txtData As String)
Dim W As Integer = 160
Dim H As Integer = 110
Dim b As BarcodeLib.Barcode
Dim type As BarcodeLib.TYPE = BarcodeLib.TYPE.UNSPECIFIED
type = BarcodeLib.TYPE.CODE128
b = New BarcodeLib.Barcode()
Try
If type <> BarcodeLib.TYPE.UNSPECIFIED Then
b.IncludeLabel = True
'===== Encoding performed here =====
pic = b.Encode(type, txtData, W, H)
'CType(Frm, frm_submitentery).pic_img.Image = pic.Image
'===================================
End If
Catch ex As Exception
'try
MessageBox.Show(ex.Message)
'catch
End Try
End Sub
非常感谢您提前提出建议。
如果在VS2010中运行.Net 4,则可能需要将以下内容添加到.config文件(配置部分):
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.