none
Install dlls to winsxs RRS feed

  • Question

  • Hi All!

     

    How I can install myself dll to winsxs storage?

    I tried to use Windows Installer, but he want to know correct dirrectory name.. for exapmle

    x86_Microsoft.VC80.DebugOpenMP_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_66b81908

    I want to use something like

    x86_My.Test.TestDll_<public_key_tocken>_1.0.0.1_x-ww_<hash_value>.

    But I don't not how to calculate hash value?

    What is it?

    May be is there any way to install?

     

    Thanks!

    Wednesday, June 13, 2007 9:29 AM

Answers

  • The error indicates that MSI is looking for a managed assembly. And indeed you should set Attributes in the MsiAssembly table to 1 for Win32 assemblies.

     

    -hg

    Friday, June 15, 2007 10:47 AM

All replies

  • Everything you need should be in the side by side assemblies section of the MSDN library.
    Wednesday, June 13, 2007 6:20 PM
  • In my experience Fusion is one of the most poorly documented technologies (almost close to Active Script Debugging). When I tried to get mt.exe working for one of my DLLs it turned out that 90% of the information was incorrect or outdated. It might be a better idea to grab a recent SDK and use its mt.exe /? screen as a starting point.

     

    Ah and don't even try to use the VC IDE support for manifest generation, if it supports that scenario at all it's certainly not worth the effort.

     

    However, once you've managed to build the DLL you should use Windows Installer's integrated support to install the assemblies. That seems to worked relatively easily.

     

    -hg

    Wednesday, June 13, 2007 6:30 PM
  • Yes, I tried to use Windows Installer as it describe in MSDN.

    But i have troubles.

    In msdn said that windows installer install dll in winsxs himself.

    But in practice he need complite name of the winsxs dll directory.

    For example Visual Studio msm modules have already formed name inside. Whis calculated hash value..

     

    I found article:

    http://blogs.msdn.com/jonwis/archive/2005/12/28/507863.aspx

     

    "If you're trying to find files in the WinSxS directory, you should be using the CreateActCtx/ActivateActCtx/SearchPath set of APIs. If you're trying to write files into the WinSxS directory, you should be using MSI which knows about installing components into the right places. If you're writing your own binder, don't - it's really hard to get right. It should be sufficient to say "the generation of this string is opaque and must be assumed to change."

     

    Is it true?

     

    Anybody have real experience to install dll to winsxs?

    Anybody can say how do it step by step?

     

     

    Thursday, June 14, 2007 7:41 AM
  • Well, if you managed to create the correct manifest you will already have the hashes. And I agree, don't try to install manually.

     

    What you should do is create your DLL along with the manifest and the run mt.exe to populate the file hashes. Once, you have that MSI authoring should be pretty straightforward.

     

    The tedious task is getting the mt.exe build step right. As I have said take a look at the docs and always double check with mt.exe /? screen.

     

    There really is no point in trying to install an assembly into SxS before you have a correct manifest.

     

    -hg

    Thursday, June 14, 2007 12:32 PM
  • No, I do not meen file hash, I meen <hash_value>, the last part of directory name. It is not hash, it's like CRC or something else.. But in msdn it's named <hash_value>.

     

    Example: x86_Microsoft.VC80.DebugOpenMP_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_<hash_value>

     

    I did all necessary steps (from MSDN). Create dll, certificate, sing dll, get public key token, create manifest, create msm,

    MsiAssembly and MsiAssemblyName table, fill it..

    After that I need set directory for my assembly (dll).

    All msm from microsoft (Directory table) already contain full directory name (86_Microsoft.VC80.DebugOpenMP_1fc8b3b9a1e18e3b_x-ww_aadac93f with calculated hash_value = aadac93f)

    That is question, how to calculate it before create msm module?

    It's clear that this hash_value was'n created by windows installer...

     

    And one more question, are there winsxs dll that are not provide by microsoft? Do someone know application that install himself dll in winsxs?

    Thursday, June 14, 2007 12:57 PM
  • So you're looking for the entry in the directory for the relevant component? I was under the impression that Windows Installer ignores the directory if you decided to install the assembly as a shared assembly.

     

    I did create a shared assembly along with a MSI package to set it up a while ago, but it was never included in the shipping package. But I think it really worked quite nicely.

     

    -hg

    Thursday, June 14, 2007 2:20 PM
  • I look at Microsoft_VC80_DebugOpenMP_x86.msm from ..\Program Files\Common Files\Merge Modules\

     

    Do you have some msi that will install dll to winsxs? May I look at it?

    Thursday, June 14, 2007 2:52 PM
  • I did that for a client a year or so ago. I certainly have a copy somewhere, just don't ask me where. I'll try to dig it up.

     

    In the mean have you tried to use just an arbitrary directory? Does it really install things into that directory then?

     

    -hg

    Thursday, June 14, 2007 5:51 PM
  • I try to do all steps from the beginning.

    There are:

     

    Part 1 (Assembly Signing Example, MSDN)

    1. Create test dll "TestDLL.dll" that exporting one test function.

    2. Create certificate "makecert.exe -sv test.pvk -a sha1 -len 2048 test.cer"

    3. Extract the public key valur from the certificate file "pktextract.exe test.cer",
    Certificate: "Root Agency" - 2048 bits long, publicKeyToken="bde2dec54339634d"

     

    4. Create manifest:
    п>ї<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urnTongue Tiedchemas-microsoft-com:asm.v1" manifestVersion="1.0">
        <noInheritable></noInheritable>
        <assemblyIdentity type="win32"
            name="My.Test.TestDLL"
            version="1.0.0.1" processorArchitecture="x86"
                   publicKeyToken="bde2dec54339634d">
        </assemblyIdentity>
        <file name="TestDLL.dll" hash="" hashalg="SHA1"/>
    </assembly>

     

    5. Update hash and create *cdf file "mt.exe -manifest Test.manifest -hashupdate -makecdfs"
    Test.manifest file after:

    п>ї<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urnTongue Tiedchemas-microsoft-com:asm.v1" manifestVersion="1.0">
        <noInheritable></noInheritable>
        <assemblyIdentity type="win32"
                          name="My.Test.TestDLL"
                          version="1.0.0.1"
                          processorArchitecture="x86"
                          publicKeyToken="bde2dec54339634d">
        </assemblyIdentity>
        <file name="TestDLL.dll" hash="be5d62f53575f05a8058af6c4f087cb312a7c790" hashalg="SHA1">
              <asmv2:hash xmlns:asmv2="urnTongue Tiedchemas-microsoft-com:asm.v2"
              xmlnsBig Smilesig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms>
              <dsig:Transform Algorithm="urnTongue Tiedchemas-microsoft-com:HashTransforms.Identity">
              </dsig:Transform></dsig:Transforms><dsigBig SmileigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1">
              </dsigBig SmileigestMethod><dsigBig SmileigestValue>LxFXBP7C/W/thQjy8lL3TsEWm+4=</dsigBig SmileigestValue></asmv2:hash>
        </file>
    </assembly>

     

    Test.manifest.cdf:

    [CatalogHeader]
    Name=Test.cat
    ResultDir=D:\work\Test_WinSxs\4

    [CatalogFiles]
    <HASH>Test.manifest=Test.manifest
    Test.manifest=Test.manifest

     

    6. Create the security catalog for the assembly "MakeCat.Exe Test.manifest.cdf"
    Test.cat is created.

    7. Convert cert to spc "Cert2Spc.Exe test.cer"
    Test.spc is created.

    8. Convert pvk to pfx "pvk2pfx.exe -pvk test.pvk -spc test.spc -pfx test.pfx"
    Test.pfx is created.

    9. Sign the catalog file with the certificate
    "signtool sign /f test.pfx /du http://www.mycompany.com/MySampleAssembly /t http://timestamp.verisign.com/scripts/timstamp.dll Test.cat"

     

    Part 2 (Installing Win32 Assemblies for Side-by-Side Sharing on Windows XP, MSDN)

    1. Create msi project in VS

    2. Add to "Application folder" TestDLL.dll, Test.manifest and Test.cat

    3. Build it by VS.

    4. Open msi by Orka

    5. Open Component table, there are three components.
    Rename component binding with TestDLL.dll file to C__Test.
    Component=C__Test, Directory=TARGETDIR, Attribute=0, PathKey=<TestDLL.dll file ID from "File" table>

    6. Open File table, set C__Test component for TestDLL.dll

    7. Open FeatureCompanents table. Remane component for TestDLL.dll to C__Test component.

    8. Open MsiAssembly table. Add new Row. Component=C__Test, Feature=DefaultFeature,
    File_Manifest=<Test.manifest file ID from "File" table>, File_Application=<null>, Arrtibute=<null>

    9. Open MsiAssemblyName table. Add Rows:
    Component=C__Test, Name=type, Value=win32;
    Component=C__Test, Name=language, Value=en;
    Component=C__Test, Name=name, Value=My.Test.TestDLL;
    Component=C__Test, Name=processorArchitecture, Value=x86;
    Component=C__Test, Name=publicKeyToken, Value=bde2dec54339634d;
    Component=C__Test, Name=version, Value=1.0.0.1;

    10. Save msi.

    Finish.

     

    Trying to install msi. It returns error HRESULT 0x80131532.

     

    What I do wrong?

     

    Friday, June 15, 2007 10:25 AM
  • The error indicates that MSI is looking for a managed assembly. And indeed you should set Attributes in the MsiAssembly table to 1 for Win32 assemblies.

     

    -hg

    Friday, June 15, 2007 10:47 AM
  • Oh.. yes, thanks!

    I fixed it. But it was just mistake.

     

    Real error is returned now. HRESULT = 0x8007054F

    Friday, June 15, 2007 11:08 AM
  • Works for me. The error message is odd, I suspect something is really wrong with your package (are you sure the files still belong to the C__Test component?) Also msiexec /l*v is your friend (just search for a "Return value 3" to identify the error).

     

    If you have chance, grab the latest WiX toolchain and use it to build the MSI. Create a component, add dll, manifest and catalog. Under the DLL add the AssemblyManifest and Assembly attributes and add AssemblyName elements.

     

    That should pretty much do the trick.

     

    One thing that you didn't metnion explicitly in your OP, you need a VERSIONINFO resource with the corresponding version number of the manifest. But I think, there should be a more useful error message if you hadn't.

     

    -hg

    Friday, June 15, 2007 12:23 PM
  • It works!! Smile

    You are right, problems was with component table.

    In step 5 part 2 my way need to remove all components except C__Test.

    After that msi installer crate x86_My.Test.TestDLL_bde2dec54339634d_1.0.0.1_x-ww_ce27510c folder in winsxs directory.

     

    Thanks a lot!

     

     

    Friday, June 15, 2007 1:24 PM