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

  • SEARCH
  • Home
  • 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 581473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:34:57+00:00 2026-05-13T14:34:57+00:00

i have a project that is structured with a .net namespace called ViewParts. This,

  • 0

i have a project that is structured with a .net namespace called ViewParts. This, on the other hand, consists of many different subfolder with wpf usercontrols in them.

I have added an XmlnsDefinition attribute to my AssemblyInfo.cs file to map that .net namespace to a uri for use in other window/usercontrol files. But i would really love to have the attribute work in “recursive-mode”. That is: i want it to include all subfolders below the .net namespace that i specify.
Otherwise i will have to go into the AssemblyInfo.cs file and add a line everytime i add a new viewpart/usercontrol and that is just-another-step-that-will-get-forgotten…

Is this possible in any way?

  • 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-13T14:34:57+00:00Added an answer on May 13, 2026 at 2:34 pm

    Anything is possible.

    In this case, though, it is not particularly easy. XmlnsDefinition attributes are read directly by the XAML parser, and it has no recursive namespace feature. Unless you actually have the XmlnsDefinition attributes on your assembly the XAML parser will not add them to its table and you will not get the mappings you want.

    Modifying the XAML parser is not a good idea because the internals you’d need to muck with are likely to change. Fortunately adding XmlnsDefinitions autoamtically is not that difficult.

    I’ll give you three ways to modify your build process to automate this. In each case you will start by moving your XmlnsDefinition attributes that you want to be recursive out of AssemblyInfo.cs and into another file that is rewritten by your build step. This is possible because [assembly:] attributes can be found in any file. No matter where they are found the C# compiler adds them to the same place in the resulting assembly.

    Now that your file is a separate one, here are the three approaches to rebuilding it automatically every time you hit F5 or Ctrl-Shift-B or whatever:

    1. Add a post-build event that loads the .dll, uses reflection to enumerate the types, and builds a list of namespaces with the desired prefix. Write this to your “XmlnsDefinitions.cs” file (must also remove read-only bit) so the next time you compile it will have the right definitions. Disadvantages: poor interaction with source control & must compile twice to get correct output.

    2. Add a build task (reference Microsoft.Build.Framework and subclass Microsoft.Build.Framework.Task) that constructs the “XmlDefinitions.cs” file as a generated file by parsing the source code. Include a call to this task in your .csproj file (or in a separate .targets file that is included from your .csproj). Disadvantages: More work than #1, writing source parser for namespaces complicated by possibility of nested namespaces.

    3. Add a build task that constructs the “XmlnsDefinitions.cs” file by reflecting on the .dll output. Then add a custom .targets file that compiles your app without XmlnsDefinitions.cs, then builds XmlnsDefintions.cs, then compiles again. Disadvantages: Complex build process, complex msbuild changes, show because of compiling twice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many, (15-20) different XML files that I need to load to VB.Net.
I have project that I'm working on that is going to require a webserver.
I have a project that I'm currently working on but it currently only supports
I have a project that I would like to start beta testing soon, it
I have a project that I'm working on and I need to be able
We have a project that generates a code snippet that can be used on
I have a project that I thought was going to be relatively easy, but
I have a project that I am building with Netbeans 6.1 and I am
I have a project that has a makefile with broken dependencies. Is there any
I have a project that has the following line in the additional includes section:

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.