English 中文(简体)
正在访问新签名的第三方 DLLL 给出错误
原标题:Accessing newly signed third party DLL gives error

我有一个使用第三方 DLLS 的签名申请。这些 DLLS 还没有签名 。 - 到目前为止,第一步没有问题:我刚刚签名了它们(使用 laldasm.exe, 使用 ildasm.exe ), 因为他们有相互依存关系, 并且用 lasm.exe 做了 *.dll s 。

该项目现在汇编精细,并且也开始。

但当我的代码里,一个三党DLL的班级建设者被称作(或其他东西?)时, 我得到的错误是“它们”“Scrong-name 签名的集会必须在其内部可视宣言中指定一个公用钥匙”

如果你有DLL的源头,并且可以通过设置 AssemblyInfo.cs 来公正使用AssemblyInfo.cs, 似乎不会有问题。

[assembly: InternalsVisibleTo("MyProject.Domain.Tests, PublicKey=..."]

" 强 " 但是: " 强 " 如上所述,我有第三方DLL I " 强 " (强) (强) (强) (强) (强) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有) (有。因此无法解决此类问题。

有建议要启动吗?

问题回答

我也有同样的问题

" 强 " 为何发生

  • The 3rd-party assembly is declared with InternalsVisibleTo to make it "friend" to other assemblies, e.g. InternalsVisibleTo("OtherAssembly")
  • .NET requires that strong-name assembly can only be "friend" to other strong-name assemblies, in which case the InternalsVisibleTo attribute must specify the public keys of those other assemblies, e.g. InternalsVisibleTo("OtherAssembly, PublicKey=[key]")
  • At runtime, the CLR sees that InternalsVisibleTo is not properly declared for the assembly in question, so it throws the exception.

< 加固> 修补 的方法

如果执行程序不需要“朋友”集会(例如,它是一个测试集会,没有投入生产),则遵循这些步骤:

  • Disassemble the assembly in question: ildasm.exe ThirdParty.dll /OUTPUT=ThirdParty.il
  • Use a text editor to edit the IL file, remove any declaration of InternalsVisibleTo
  • Assemble and sign the IL: ilasm.exe ThirdParty.il /DLL /OUTPUT=ThirdParty.modified.dll /KEY=key.snk
  • Note: generate a key by: sn.exe -k key.snk

如果执行程序需要“朋友”集会,您必须签署所有这些朋友集会。然后采取与上述类似的步骤,除了不删除“内部可见到”的代码外,您必须用正确的公钥修改每份声明。





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签