Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error LGHT0001: Failed to compare two elements in the array. #4563

Closed
wixbot opened this issue Oct 21, 2014 · 23 comments
Closed

error LGHT0001: Failed to compare two elements in the array. #4563

wixbot opened this issue Oct 21, 2014 · 23 comments
Assignees
Milestone

Comments

@wixbot
Copy link

wixbot commented Oct 21, 2014

The linker on v4.0.2220.0 throws this error:
light.exe(0,0): error LGHT0001: Failed to compare two elements in the array.

The bug did not exist in v4.0.2115.0.

Originally opened by mberchtold

@wixbot
Copy link
Author

wixbot commented Oct 21, 2014

Please provide the exception stack that is provided with this error message. If you are building via MSBuild, the log file will have the stack information.

Originally posted by robmen
AssignedTo set to robmen

@wixbot
Copy link
Author

wixbot commented Oct 21, 2014

Exception Type: System.InvalidOperationException
Stack Trace:
at System.Array.SorterObjectArray.DepthLimitedQuickSort(Int32 left, Int32 right, Int32 depthLimit)
at System.Array.Sort(Array keys, Array items, Int32 index, Int32 length, IComparer comparer)
at System.Collections.ArrayList.Sort(Int32 index, Int32 count, IComparer comparer)
at System.Collections.ArrayList.Sort()
at WixToolset.Linker.Link(IEnumerable`1 inputs, OutputType expectedOutputType)
at WixToolset.Tools.Light.Run()
at WixToolset.Tools.Light.Execute(String[] args)

Originally posted by mberchtold

@wixbot
Copy link
Author

wixbot commented Oct 23, 2014

Release changed from v4.x to v4.0

@wixbot
Copy link
Author

wixbot commented Feb 24, 2015

I just wanted to report that this still happens with the latest 4.0 release:
v4.0.2603.0

Originally posted by mberchtold

@wixbot
Copy link
Author

wixbot commented Mar 21, 2015

This still happens in v4.0.2719.0

Originally posted by mberchtold

@wixbot
Copy link
Author

wixbot commented Mar 21, 2015

Yes, and it'll very likely continue to repro until the bug is marked Resolved fixed.

Originally posted by robmen

@wixbot
Copy link
Author

wixbot commented May 5, 2015

Is there anything I can do (aside from fixing the bug) to get this resolved?

Originally posted by mberchtold

@wixbot
Copy link
Author

wixbot commented May 5, 2015

You could debug into the code and provide more detail about exactly what the issue is and what your .wxs code is doing to hit it. That's one step less than fixing the bug yourself but should make it significantly easier to design the fix.

At this point, it isn't exactly clear what is causing the issue.

Originally posted by robmen

@wixbot
Copy link
Author

wixbot commented May 14, 2015

I have tracked down the problem. It happens when two components have a File element with a non unique Name attribute value and a long name in the value. Example:

<Component Id="Comp1">
<!-- < Windows 8.1 -->
<Condition>VersionNT &lt; 603</Condition>
<File Id="file.dll" Name="wrapperlong.dll" KeyPath="yes" Source="$(var.SourceDir)source.dll" />
</Component>

<Component Id="Comp2">
<!-- >= Windows 8.1 -->
<Condition>VersionNT &gt;= 603</Condition>
<!-- Note: Same destination filename as Comp1 but components are mutually exclusive -->
<File Id="fileWin81.dll" Name="wrapperlong.dll" KeyPath="yes" Source="$(var.SourceDir)sourcewin81.dll" />
</Component>

If the Name value contains a short name (<= 8 chars) the bug is not triggered. A workaround is to explicitly set the ShortName as following:
<File Id="file.dll" Name="wrapperlong.dll" ShortName="wrap146" KeyPath="yes" Source="$(var.SourceDir)source.dll" />

So it seems the problem is related to the short name generation in combination with non unique Name values.

Originally posted by mberchtold

@wixbot
Copy link
Author

wixbot commented May 20, 2015

The problem is here:
File: https://github.com/wixtoolset/wix4/blob/develop/src/tools/wix/Linker.cs
// sort the rows by DiskId
fileRows.Sort();

The Sort happens if there are at least 2 files with the same short file name.

The problem is now that the IComparable implementation in the FileRow class has been comment out.
File: https://github.com/wixtoolset/wix4/blob/develop/src/libs/WixToolset.Data/Rows/FileRow.cs
public sealed class FileRow : Row //, IComparable

Hence these elements cannot be compared.

A temporary solution would be to stop sorting the ArrayList as it is only used for the error message.

Originally posted by mberchtold

@wixbot
Copy link
Author

wixbot commented May 20, 2015

Please see the following pull request for the proposed fix:
wixtoolset/wix#134

Originally posted by mberchtold

@wixbot wixbot added this to the v4.0 milestone Dec 20, 2015
@Gerolkae
Copy link

Gerolkae commented Jul 14, 2016

Is this Still an Issue?

I'm getting the error with July 5 Wix 4.0

My Code is
Ok I’ve updated the snippet

</Component>
          <Component Id="SilverMonkeyExt" Guid="{DEC333A0-7393-4097-AB77-A2847D121A3C}">
            <File Id="SilverMonkey" Source="$(var.SilverMonkey2.TargetDir)SilverMonkey.exe" KeyPath="no" Checksum="yes" />
        <ProgId Id='SilverMonkeys' Description='Bot information File' >
          <Extension Id='bini' ContentType='application/BotInformationFile'>
            <Verb Id='open' Command='Open' TargetFile='SilverMonkey' Argument='"%1"' />
          </Extension>
        </ProgId>
      </Component>

I'm using a harvest project in VS2015 that contains the SilverMonkey.exe

@robmen
Copy link
Member

robmen commented Jul 14, 2016

Yes, the issue is still Open so it is still needs to be fixed.

@SonnyAD
Copy link

SonnyAD commented Jul 30, 2016

What about the fix proposed by mberchtold? Or could we sort by the entire path of the file instead of short name?
I'll try to clone the repo see if I can come up with a fix.

@SonnyAD
Copy link

SonnyAD commented Jul 30, 2016

What should I have to be able to rebuild entirely wix4? VS2013 with C# and C++ features? Anything more?

@fourpastmidnight
Copy link

This issue also occurs if you use pre-processor variables:

<Component Directory="MingwFolder:\bin\">
<?if $(sys.BUILDARCH)=x64?>
    <File Id="OpenSSLCurl" Source="mingw64\bin\curl.exe" />
<?else?>
    <File Id="OpenSSLCurl" Source="mingw32\bin\curl.exe" />
<?endif?>
</Component>
<Component Directory="MingwFolder:\bin\">
<?if $(sys.BUILDARCH)=x64?>
    <File Id="OpenSSLLibCurl" Source="mingw64\bin\libcurl-4.dll" />
<?else?>
    <File Id="OpenSSLLibCurl" Source="mingw32\bin\libcurl-4.dll" />
<?endif?>
</Component>

I would've expected pre-processing to already have occurred, removing the unused XML (or, more accurately, ignoring the "duplicate" entry). In any event, for me at least, I simplified the above WiX XML and this is not a blocking issue for me. But just wanted to report my own findings.

@robmen
Copy link
Member

robmen commented Jul 22, 2020

This code is being reimplemented completely differently in issue #6212

@robmen robmen closed this as completed Jul 22, 2020
@rseanhall rseanhall added this to Obsolete in wix.4.0-preview.0 Nov 16, 2020
@rseanhall rseanhall moved this from Obsolete to Done in wix.4.0-preview.0 Nov 16, 2020
@RajagurunathanManikandan
Copy link

RajagurunathanManikandan commented Apr 7, 2022

Hi @robmen , @Gerolkae , @fourpastmidnight , @wixbot , @SonnyAD

I'm still facing this issue in the below versions.

  • wix-4.0.2719.0
  • wix-4.0.0.5918
  • wix-4.0.0.5512
  • wix-4.0.0.5205
  • wix-4.0.0.5204
  • wix-4.0.0.4506
  • wix-4.0.0.4305
  • wix-4.0.0.3922
  • wix-4.0.0.3826
  • wix-4.0.0.3729
  • wix-4.0.0.3430
  • wix-4.0.0.3226
  • wix-4.0.0.2926
  • wix-4.0.0.2603
  • wix-4.0.0.2220
  • wix-4.0.0.2115
  • wix-4.0.0.2102
  • wix-4.0.0.1726
  • wix-4.0.0.1621
  • wix-4.0.0.1320
  • wix-4.0.0.1216
  • wix-4.0.0.1210
  • wix-4.0.0.1203
  • wix-4.0.0.1015
  • wix-4.0.0.1007
  • wix-4.0.0.0701
  • wix-4.0.0.0424
  • wix-4.0.0.0012
  • wix-4.0.0.0004

error snap:
image

Can you share the V4.0 download link which doesn't have this issue?
Thanks in advance.

@RajagurunathanManikandan

Hi @robmen , I guess this issue is not fixed, can you share the stable V4 version download link?
Thanks in advance...

@robmen
Copy link
Member

robmen commented Apr 7, 2022

It's fixed in v4-preview.0. Get that from NuGet.

@RajagurunathanManikandan
Copy link

RajagurunathanManikandan commented Apr 7, 2022

It's fixed in v4-preview.0. Get that from NuGet.

@robmen, @barnson, @rseanhall

Is there any option to build and generate msi from wix v4 project using wix dotnet tool?
Or should I wait till wix v4 supports MSBuild?

Thanks in advance.

@RajagurunathanManikandan

@robmen, @barnson, @rseanhall

Is there any option to build and generate msi from wix v4 project using wix dotnet tool?
Or should I wait till wix v4 supports MSBuild?

Thanks in advance.

@barnson
Copy link
Member

barnson commented Apr 10, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

7 participants