locked
Custom Assembly in a 2017 RDLC Report RRS feed

  • Question

  • Hey all:

    First, please let me emphasize that I need a solution for RDLC reports in VS 2017.  I am printing or creating a PDF for the RDLC in a Windows app, if that matters.  I've seen solutions for earlier VS and RDLC versions, but they don't seem 100% applicable to 2017.

    Also, I have another RDLC, without the custom assembly, working correctly.

    Error:

    That assembly does not allow partially trusted callers.

    I suspect this error is from the GenCode128.DLL custom assembly noted below

    First, per one article, I tried to simply load the custom assembly into my GAC, but no-go.

    Here's the more involved approach I tried via pieces of multiple articles:

    ALL on my local development PC at this point

    • Strongly name the custom assembly assembly.
    • Copy the custom assembly DLL into the following folders:
      • C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\SSRS
      • C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PrivateAssemblies
    • In C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\SSRS\RSPreviewPolicy.config:
      • Set ALL PermissionSetName attributes to FullTrust
        • This may have been overkill, but followed the article
      • I also saw something in yet another article about adding a custom CodeGroup for my assembly, but wasn’t clear where to do that.
    • Added the following report references:
      • GenCode128, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ad394d3897d5fe98
        • From the above PrivetAssemblies folder
      • System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    • I get the error at runtime, not compiling.


    Wednesday, October 23, 2019 11:33 AM

Answers

  • Hi Lanis,

    Sorry for not meeting your issue correctly for the first time.

    When you strongly name the custom assembly assembly, it means that you should add the following assembly-level attribute to your assembly attribute file. 

    > >add [assembly: AllowPartiallyTrustedCallers] into your dll assembly

    Besides, you also add the dll into GAC and then reference it from there which l probably think it does not work. Using Strong name does work and its corresponding error is usually "That assembly does not allow partially trusted callers".

    In general,  adding the dll into GAC usually corresponds to this error:

    Could not load file or assembly 'xxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxx' or one of its dependencies. The system cannot find the file specified.

    This usually means that vs cannot find the DLL in the environment for some reason.

    ###When you add the strong name,do not forget to rebuild the assembly and then requote this dLL.

    So you should reanalyze it based on this.

    ##Will I run into other issues, say when I deploy?

    > >For the deploying this assembly, I think you should take a good look at Microsoft's official documentation and follow its steps to avoid unnecessary errors. If you have any problems, please let us know in time.

    Best Regards,

    Perry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Friday, October 25, 2019 2:39 AM

All replies

  • UPDATE:

    I was able to get it running, although still messing with the bar code to get the same size as our existing Active Report.

    Here's how I got it to work:

    • Putting the GenCode128.DLL in those folders and updating that config did not work, so I reverted.
    • Only way I could get the GenCode128.DLL to run in my report is:
      • Add the following to the GenCode128 AssemblyInfo.cs (found this in yet another article 😊)

    [assembly: AllowPartiallyTrustedCallers]

      • Put it in the GAC and reference it from there

    Still, based on articles I've read

    • Surprised the initial approach did not work
    • Will I run into other issues, say when I deploy?
    Wednesday, October 23, 2019 6:27 PM
  • Hi Lanis,

    Welcome to the MSDN forum.

    We are so glad to hear that you got your answer by yourself. Since you have solved your issue, please remember to mark it as answer so that it will help other community members to search and handle similar issues. 

    If you have any other similar issues about this aspect in the future, please feel free to let us know. We are willing to help you further.

    Thanks for your understanding.

    Best Regards,

    Perry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Thursday, October 24, 2019 4:47 AM
  • Note I still have questions, as noted at the end of my update:

    Still, based on articles I've read

    • Surprised the initial approach did not work
    • Will I run into other issues, say when I deploy?

    Thursday, October 24, 2019 10:03 AM
  • Hi Lanis,

    Sorry for not meeting your issue correctly for the first time.

    When you strongly name the custom assembly assembly, it means that you should add the following assembly-level attribute to your assembly attribute file. 

    > >add [assembly: AllowPartiallyTrustedCallers] into your dll assembly

    Besides, you also add the dll into GAC and then reference it from there which l probably think it does not work. Using Strong name does work and its corresponding error is usually "That assembly does not allow partially trusted callers".

    In general,  adding the dll into GAC usually corresponds to this error:

    Could not load file or assembly 'xxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxx' or one of its dependencies. The system cannot find the file specified.

    This usually means that vs cannot find the DLL in the environment for some reason.

    ###When you add the strong name,do not forget to rebuild the assembly and then requote this dLL.

    So you should reanalyze it based on this.

    ##Will I run into other issues, say when I deploy?

    > >For the deploying this assembly, I think you should take a good look at Microsoft's official documentation and follow its steps to avoid unnecessary errors. If you have any problems, please let us know in time.

    Best Regards,

    Perry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Friday, October 25, 2019 2:39 AM