2

i'm trying to install dlls to GAC, I get this error:

The assembly is not strongly named or is not signed with the minimal key length.

Code below. How do I get around this?

    <Product Id="4C76EAE3-148A-4597-A994-0178693C5B25" Name="MySolutionInstaller" Language="1033" Version="1.0.0.0" Manufacturer="Me" UpgradeCode="a5e6cbeb-18be-4f7e-9ab5-f1adb1d947eb">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate />
    <Feature Id="ProductFeature" Title="MySolutionInstaller" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
    </Feature>
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <!--<Directory Id="INSTALLFOLDER" Name="MyDLLCoreLibrary">-->
        <Directory Id="ProductDirectory" Name="MySolutionInstaller">
          <Directory Id="GAC" Name="GAC"/>
        </Directory> 
      </Directory>
    </Directory>
  </Fragment>

<Fragment>
<ComponentGroup Id="ProductComponents">
      <Component Id='DataLibraryGAC' Directory="GAC" Guid='a3b57886-4d27-4e4c-a28f-60a061cdd12d'>
        <File Id='DataDLLGAC' Name='MyProject.Data.dll' Source='C:\projects\MyProject.Data\bin\Debug\MyProject.Data.dll' 
              KeyPath="yes" Assembly=".net" />
        <!--<RemoveFile Id="RemoveDataDLLGAC" Name="My.Data.dll" On="uninstall" />-->
      </Component>

    </ComponentGroup>
  </Fragment>
Rob Mensching
  • 33,834
  • 5
  • 90
  • 130
newbie_86
  • 4,520
  • 17
  • 58
  • 89

2 Answers2

2

This error shows your assembly is not signing with strong name key. We need to sign the assembly using .snk file to install it in GAC. Check this to sign the assembly.

Community
  • 1
  • 1
Vinoth
  • 1,975
  • 21
  • 34
  • i've tried to sign the assembly but now i get this error - "Friend assembly reference is invalid. Strong-name signed assemblies must specify a public key in their InternalsVisibleTo declarations." What happens to third party dlls that are referenced in my dll I want to strongly name e.g. mvcContrib? – newbie_86 May 17 '13 at 14:56
0

Another way around the error is to not put it in the GAC. Instead put your assembly where your EXE(s) can find it. The simpliest layout is all in one folder. But there are other options, such as automatically probing subfolders, as explained by How the Runtime Locates Assemblies.

An advantange of not installing into the GAC is that you can still design the installer to work without an administrator.

Tom Blodget
  • 20,260
  • 3
  • 39
  • 72
  • if i don't place my assembly in the gac, but in a common folder, will i still need to reference it for each dependent project? does this mean it will appear in the bin for each project? i want to avoid this as the dlls get quite big – newbie_86 May 20 '13 at 06:52
  • Let's put aside the quesition of how an assembly can be big relative to a hard drive. There are only two "common" places for an assembly, the GAC, or a folder at or below the EXE. If you have more than one EXE that need to load common assemblies from the same folder, then they must arranged so that the assemblies are at or below the folder of the EXE that loads it. So that means all EXEs in one folder or spread into decendent folders with the common assemblies at or below the lowest EXE. Note: you are asking about running an installed app. On a dev box, Copy Local can be the most convenient. – Tom Blodget May 20 '13 at 15:15
  • It's a special case, but you can locate assemblies anywhere if you write code (usually in the EXE) to find them. See [AppDomain.AssemblyResolve Event](http://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve.aspx), which "occurs when [every built-in] resolution [method for] an assembly [has] fail[ed]" and it's up to the method handling the event to succeed or fail as a last chance. – Tom Blodget May 20 '13 at 16:09