Showing an image in crystal report

2

I want to use crystal report in VB.net in order to show an image containing a barcode.But when I run the application I get the following exception before loading the report although I have added the reference of crdb_adoplus.dll to my project.

exception:Could not load file or assembly 'crdb_adoplus, Version=9.1.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)

And here is my code:

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

I really appreciate your suggestions in advance.

vb.net
crystal-reports
datatable
dataset
barcode
asked on Stack Overflow Feb 12, 2013 by (unknown user)

1 Answer

0

If you are running .Net 4 in VS2010, then you may need to add the following to your .config file (configuration section):

<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
answered on Stack Overflow Feb 13, 2013 by Sahar Kiyan

User contributions licensed under CC BY-SA 3.0