Strong Signed Assemblies

拜拜、爱过 提交于 2019-12-17 15:53:52

问题


I have a project I made in Visual Basic 2008 Express. I converted it from someone else's C# project, but it works. It has several DLL dependencies. I went to publish my project so I can install it on another machine and for each DLL, I get an error: "Assembly must be strong signed in order to be marked as a prerequisite." I've done some research, but am not finding a lot and what I have found I don't really understand. What does this error mean? What is the best way to resolve it? One other thing: it took me a LONG time to be able to get all my dll's to reference correctly, so I prefer that the solution has NOTHING to do with moving DLL's around because that will likely break the functionality in my main project.


回答1:


If you're publishing via ClickOnce, go to the publish page and click on "Application Files". From there you should see a list of your DLL's. Ensure that the ones that are giving you trouble have their Publish Status marked as "Include" rather than "Prerequisite".

What this error message means is that the current publishing settings are going to expect all of the assemblies in question to be present in the Global Assembly Cache on the target machine before installation can take place. Since all assemblies in the GAC must be strong signed, any assembly marked as a prerequisite that isn't strong signed will give you this error.




回答2:


The workaround is more simple than that:

  1. Go to your project.
  2. Right click and Select Properties.
  3. Go to the Security Tab.
  4. Uncheck Enable ClickOnce security Settings.

Unless you are deploying this application through ClickOnce, you don't need to StrongName your assemblies.




回答3:


Strongly named assemblies are mainly assemblies which have are signed by a cryptographic key. This is fairly easy to do with Visual Studio and does not require re-ordering of your dependencies.

I'm using non-express Visual Studio so the steps may be slightly different for you.

  • Right click on the project and select properties
  • Click on the Signing tab
  • Check "Sign the assembly"
  • In the combo box select "<New...>"
  • Complete the wizard
  • Rebuild



回答4:


Check this link out...it has instructions for signing your assembly with a strong name:

MSDN: Signing an Assembly with a Strong Name




回答5:


To create a strong name just go to the SDK Command Prompt or Visual Studio 200X Command Prompt then type in the following

sn -k sgKey.snk

Refer this link for details

Then associate the strong name to your assembly by running the below command

al /out:MyAssembly.dll MyOldAssembly.dll /keyfile:sgKey.snk

Refer this link for details




回答6:


This just worked for me after the above mentioned solutions failed:

Remove the reference to the assembly in error, then add it again.




回答7:


I found my problem to be in the .csproj file

<Reference Include="OtherProjectNothingToDo">
  <HintPath>..\..\..\..\Pedidos\XBAP\Pedidos\Pedidos\bin\Release\Pedidos.exe</HintPath>
</Reference>

Then I removed it using notepad and it is okay now.




回答8:


Using Adam Robinson's solution allowed me to publish, but I found that users could not install the project once it was published, as the end user system would complain of an inability to install, noting hard drive space. As this seemed highly unlikely to be the root cause, I looked further into it.

Apparently the basis for my problem was that one of my references was also referencing a .dll that my project used, but a different version. ClickOnce was not having this, and refused to copy the second version of the .dll to the user's system, citing the version already present. Fixing it so the .dll and the project referenced the same version of the other .dll removed the error and corrected the install problem.




回答9:


Check that the Target Framework is actually set to 3.5 or whatever framework you want to target. Sometimes it will error out when it's not set properly.




回答10:


I just had this problem too. In my case the blabla.dll was referenced in my solution but blabla.dll was also used in another.dll which i had referenced in my project.

On checking the versions of both blabla.dll they were not the same. So i updated another.dll with the correct blabla.dll and then referenced the new another.dll in my solution. The error was gone.

In short: i was using 2 versions of blabla.dll

I hope this makes sense, if not let me know. :)

Check my blog for more detailed explanation: Blog article

Regards, Jacob Iedema



来源:https://stackoverflow.com/questions/721340/strong-signed-assemblies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!