Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5983795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:16:56+00:00 2026-05-22T22:16:56+00:00

I will start off with the code… private static void File() { wixFile =

  • 0

I will start off with the code…

private static void File()
{
    wixFile = XDocument.Load(filePath);

    var fileElements = from file in wixFile.Descendants(GetWixNamespace() + "File")
                        select file;
    foreach (var file in fileElements)
    {
        if(file.Attributes("Name").Any())
            file.Attribute("Name").Remove();
    }
    wixFile.Save(filePath);
}

I actually check for quite a few attributes in the list and remove or correct them, but just to keep it short I took everything out except for one example of what I was doing. The problem that I am having is that this code is not removing the Name attribute from anything like I would expect it. When I put a break point in and watch it the “file” is getting updated as expected, but the changes are not going over to the wixFile when I save (or during the editing either). I am not entirely sure what I am missing here so any help would be greatly appreciated.

EDIT:

Here is a snippet of the code that is being changed:

<?define ApplicationPath=\\dwdata\develope\DocuWare\DW5\Mast_dsk\?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Directory Id="DATADIR" Name="data">
                            <Directory Id="mysql" Name="mysql">
                                <Component Id="procs_priv.MYI" Guid="{1148181A-4818-434F-B2D1-E4B417586168}">
                                    <File Id="procs_priv.MYI" Name="procs_priv.MYI" KeyPath="yes" Source="$(var.ApplicationPath)Common\MySql\Server\data\mysql\procs_priv.MYI" />
                                </Component>
                                <Component Id="procs_priv.MYD" Guid="{A6688F48-71AF-4242-B6D0-CA69452A01B4}">
                                    <File Id="procs_priv.MYD" Name="procs_priv.MYD" KeyPath="yes" Source="$(var.ApplicationPath)Common\MySql\Server\data\mysql\procs_priv.MYD" />
                                </Component>
                                <Component Id="procs_priv.frm" Guid="{3025C26C-8DFF-43D4-A62A-79E78D2D807D}">
                                    <File Id="procs_priv.frm" Name="procs_priv.frm" KeyPath="yes" Source="$(var.ApplicationPath)Common\MySql\Server\data\mysql\procs_priv.frm" />
                                </Component>
                                <Component Id="proc.MYI" Guid="{FD4AA2E1-E059-4549-AE61-222878185A0A}">
                                    <File Id="proc.MYI" Name="proc.MYI" KeyPath="yes" Source="$(var.ApplicationPath)Common\MySql\Server\data\mysql\proc.MYI" />
                                </Component>
                                <Component Id="proc.MYD" Guid="{12EE6EE8-AC44-4601-84C5-14B27CF9A3E6}">
                                    <File Id="proc.MYD" Name="proc.MYD" KeyPath="yes" Source="$(var.ApplicationPath)Common\MySql\Server\data\mysql\proc.MYD" />
                                </Component>
                                <Component Id="proc.frm" Guid="{8A6F2928-5484-4B55-B75F-8475C684A091}">
                                    <File Id="proc.frm" Name="proc.frm" KeyPath="yes" Source="$(var.ApplicationPath)Common\MySql\Server\data\mysql\proc.frm" />
                                </Component>
</Directory>
</Directory>
</Wix>

I am getting the exact same thing back as well. What I am trying to do is remove the “Name” attribute, but it just isn’t working for whatever reason. The GetWiXNamespace() method returns the same namespace that is listed in the wix element as an XNamespace.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:16:57+00:00Added an answer on May 22, 2026 at 10:16 pm

    I’m going to read between the lines here and guess you are converting from an old version of WiX ( say 2.0 ) that required a File@Name attribute to a version ( say 3.0-3.6 ) that can infer this attribute and doesn’t require it.

    Here’s some code that I just whipped up that I know works assuming the source xml is WiX 3.x. I’m not sure what is wrong with your code but perhaps the method that returns the namespace hasn’t accounted for the url change.

        XNamespace ns = "http://schemas.microsoft.com/wix/2006/wi";
        var doc = XDocument.Load(@"C:\before.wxs");
        var elements = from element in doc.Descendants( ns + "File")
                       where element.Attribute("Name") != null
                       select element;
    
        foreach (var element in elements)
        {
            element.Attribute("Name").Remove();
        }
        doc.Save(@"C:\after.wxs");
    
    
    <?xml version="1.0" encoding="utf-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
      <?define SourceDir="."?>
      <Module Id="YourModuleHere" Language="1033" Version="1.0.0.0">
        <Package Id="31c7722e-c2a0-4328-92a2-eacd443c10a9" Manufacturer="YourCompanyHere" InstallerVersion="200" />
        <Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Id="MergeRedirectFolder">
            <Component Id="owc7CEF9B0C53324FC23404D2AAAB5D12B8" Guid="6898e947-fa51-8efb-bda4-2e256dea8ed1">
              <File Id="owf7CEF9B0C53324FC23404D2AAAB5D12B8" Name="bfsvc.exe" Source="$(var.SourceDir)\Windows\bfsvc.exe" KeyPath="yes" />
            </Component>
            <Component Id="owc8C6EA26177072C0006EEF8265FEF72A4" Guid="91737806-0b20-24ad-9653-cca05b5778fb">
              <File Id="owf8C6EA26177072C0006EEF8265FEF72A4" Name="explorer.exe" Source="$(var.SourceDir)\Windows\explorer.exe" KeyPath="yes" />
            </Component>
          </Directory>
        </Directory>
      </Module>
    </Wix>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a bookmarklet that will start off an AJAX call to
I have a .Net console App which using a scheduled event will start, call
When I'm inside a destructor is it possible that some other thread will start
I am using Windows, and I have two monitors. Some applications will always start
I start build a system with distributed architecture by all applications will communication by
I'm about to start a project that will record and edit audio files, and
I'm about to start a project where programmers will be contributing from their homes
I'm about to start a project where I will be the only one doing
I am going to start a C# project from scratch that will consist of
Trying to write a PowerShell cmdlet that will mute the sound at start, unless

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.