Giter Club home page Giter Club logo

Comments (7)

Codechenyin avatar Codechenyin commented on July 20, 2024 1

ah,i can‘t understan,can you?

from zxing.net.

micjahn avatar micjahn commented on July 20, 2024

Can you explain what you have tried?

I did some tests 4 years ago. I got it running with SSRS 2012. Not sure if it works the same way with SSRS 2016.
First I made a little additional project "SSRSBarcodeDemo" which implements ICustomReportItem.
The custom report item adds a custom designer for the barcode control. The report item itself calls the BarcodeWriter class.
To get it running I had to copy the SSRSBarcodeDemo assembly and the zxing.dll to the following directory:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies
I think for SSRS2016 the "11.0" has to be changed to "14.0" or something similar.

I added the following lines

    <ReportItems>
      <ReportItem Name="ZXingBarcodeControl" Type="SSRSBarcodeDemo.BarcodeCustomReportItem, SSRSBarcodeDemo" />
    </ReportItems>

to the file
C:\Program Files\Microsoft SQL Server\MSRS11.WORKSHOP\Reporting Services\ReportServer\rsreportserver.config
before the closing tag </Extensions>

I added the lines

              <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust" Name="ZXingBarcodeControl" Description="This code group grants FullTrust to ZXing Barcode Demo assembly.">
                <IMembershipCondition class="StrongNameMembershipCondition" version="1" PublicKeyBlob="0024000004800000140100000602000000240000525341310008000001000100014c9a01956f13a339130616473f69f975e086d9a3a56278936b12c48ca45a4ddfee05c21cdc22aedd84e9468283127a20bba4761c4e0d9836623fc991d562a508845fe314a435bd6c6ff4b0b1d7a141ef93dc1c62252438723f0f93668288673ea6042e583b0eed040e3673aca584f96d4dca19937fbed30e6cd3c0409db82d5c5d2067710d8d86e008447201d99238b94d91171bb0edf3e854985693051ba5167ca6ae650aca5dd65471d68835db00ce1728c58c7bbf9a5d152f491123caf9c0f686dc4e48e1ef63eaf738a12b3771c24d595cc5a5b5daf2cc7611756e9ba3cc89f08fb9adf39685bd5356858c010eb9aa8a767e5ef020408e0c9746cbb5a8" />
              </CodeGroup>

to the file
C:\Program Files\Microsoft SQL Server\MSRS11.WORKSHOP\Reporting Services\ReportServer\rssrvpolicy.config
and to the file
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\RSPreviewPolicy.config

Without the custom report item and using only custom code in the report you should get a different exception now: "That assembly does not allow partially trusted callers".
I could only fix it with a special build of zxing which adds the attribute AllowPartiallyTrustedCallers.
https://docs.microsoft.com/en-us/sql/reporting-services/custom-assemblies/using-strong-named-custom-assemblies

from zxing.net.

Timber11 avatar Timber11 commented on July 20, 2024

I positioned the zxing.dll (.NET 2.0 version) in the C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies folder.

I created a new report. I added a reference to zxing.dll and system.drawing. I added the following custom code:

Public Function getBarCode(ByVal s As String) As Byte()
Dim b As System.Drawing.Bitmap
Dim writer As New ZXing.BarcodeWriter()
writer.Format = ZXing.BarcodeFormat.DATA_MATRIX
writer.Options = New ZXing.Common.EncodingOptions
writer.Options.Width = 100
writer.Options.Height = 100
writer.Options.Margin = 30
b = writer.write("1234")
Dim bitmapData as byte() = Nothing
Using ms As New System.IO.MemoryStream()
b.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp)
bitmapData = ms.ToArray()
End Using
Return bitmapData
End Function

Then on the report you add an Image. Set the Image Source to Database. Set the Field to an expression with value =Code.getBarCode("1234"). Set the MIME type to image/bmp.

Run the report and get the runtime error.

Thanks for you attention

Tim

from zxing.net.

micjahn avatar micjahn commented on July 20, 2024

Then it is as I said before.
You have to add the mentioned lines to the file rssrvpolicy.config and RSPreviewPolicy.config. And you need a zxing.dll with the attribute AllowPartiallyTrustedCallers which isn't available yet.
I can't say when I will provide such a version of the assembly because it has some side effects.
Meanwhile you can try to write a wrapper assembly which contains your custom report code. With such a wrapper it should be possible to work around the strong name problem.

from zxing.net.

VIJAYASHANKAR avatar VIJAYASHANKAR commented on July 20, 2024

I have followed all the steps and end up with the error

anonymous access.
[rsRuntimeErrorInExpression] The Value expression for the image 'Image1' contains an error: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

from zxing.net.

asushil avatar asushil commented on July 20, 2024

[rsRuntimeErrorInExpression] The Value expression for the image 'Image1' contains an error: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
[rsInvalidDatabaseImageProperty] The value of the ImageData property for the image 'Image1' is "=Code.getBarCode(Fields!csv.Value)", which is not a valid ImageData.
Preview complete -- 0 errors, 2 warnings

from zxing.net.

bergerb-com avatar bergerb-com commented on July 20, 2024

I would like to leave a link here, if someone has the same issue.

This happens because of Bitmap.LockBits

var bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);

https://www.codeproject.com/Articles/625868/LockBits-Alternative-SecurityException-Workaround

More details:
https://stackoverflow.com/a/71710028/11829240

from zxing.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.