WiX burn: how to change 'WixBundleManufacturer' in bootstrapper application? - c#

I am building a customizable setup application with WiX, having started with this tutorial:
http://bryanpjohnston.com/2012/09/28/custom-wix-managed-bootstrapper-application/
The setup needs to be customizable, so I need to set some Variables from inside my MainViewModel this is an example:
var customProductName = "The Custom Product";
this.Bootstrapper.Engine.StringVariables["WixBundleName"] = theCustomProduct;
This works how expected. However, I cannot set the Variable WixBundleManufacturer. I get a System.ArgumentException: Value does not fall within the expected range.
Is it somehow possible to set the manufacturer value from inside my view model at runtime?

No, the WixBundleManufacturer is read-only variable set from the authored Bundle element Manufacturer attribute. You could open a feature request.

The feature request was implemented in v3.10.0.1719. The variable is now writable like any other Burn variable.

Related

AuthnContextDeclRef Issue

I'm using the latest C# SAML2 library (4.3.1), and have been able to use it successfully with Okta; however, when trying to integrate with another identity provider, I'm getting the following error:
ArgumentException: IDX13300: 'System.String' must be an absolute Uri, was: 'System.Uri'
It seems to be complaining about the saml:AuthnContextDeclRef attribute, which has the value:
ncid/secure/form/30min/uri
I'm not sure, but I think maybe this attribute is expected to be an absolute Uri by the library. The customer says this value comes from their contract and is the same for everyone, so it can't be changed. They have other applications successfully integrated (they mentioned some are using ComponentSpace). Is there any setting I can change or fix you can provide for this to work? I've looked through the available settings and nothing looks like it is relevant. The only thing I can think to do at this point is to try another SAML library.
UPDATE:
So I was able to track the issue down to the Declaration Reference attribute not being an absolute Uri. This validation is in the Microsoft.IdentityModel.Tokens.Saml2.Saml2AuthenticationContext class which represents a portion of the Saml2 token. I agree that the best solution would be to change the Declaration Reference to an absolute Uri, but since the customer says they can't or won't change the value, I needed a solution.
I was able to download the ITFoxtec.Identity.Saml2 source code and make a few tweaks so it uses a custom Saml2Serializer that overrides the ReadAuthenticationContext method and skips the part that sets the Declaration Reference on the Authentication Context. ITFoxtec doesn’t use this property… in fact, it has code that sets it to null if it has a value, so preventing the property from getting set in the first place shouldn’t cause any issues, and it allows the SAML token to be read without triggering the validation error.
It sounds correct that the AuthnContextDeclRef value should be an absolute Uri.
Her an example of how to set a AuthnContextClassRef value:
RequestedAuthnContext = new RequestedAuthnContext
{
Comparison = AuthnContextComparisonTypes.Minimum,
AuthnContextClassRef = new string[]
{
//"https://data.gov.dk/concept/core/nsis/loa/Low"
"https://data.gov.dk/concept/core/nsis/loa/Substantial",
//"https://data.gov.dk/concept/core/nsis/loa/High"
},
}

Get the teamproject collection from a WorkItem

I want to add the WebPageControl to a WorkItemType and need to define the Teamproject collection of the current Work Item as a path parameter of the URL. The WebPageControle shows a C# Webapplication. Is there a field like System.Teamproject or an other way that gives me the Teamproject collection? I know that the ID of the Work Item isn't unique to all collections and the area path includes only the Project but not the collection.
I don't believe there is a field you can pass along to the page being called, but since the Process Template configuration is stored at the project level, you can customize the work item type definition and simply hard-code the uri to the project collection in the WebpageControl's properties.
There's also the option to update the process template before registering it to the Project Collection. Since each project collection has it's own Template library, you only need to update it when you update the template at the collection level in that case.
This is unfortunately something you'll have to do each time you create a new project or update a process template of an existing Team project. It should not be terribly hard to script though...
If you already have a WorkItem object then you can do wi.Store.[Collection].xxx.
Once you have the store you can get all of the data.

Get all writeable properties of an ADLDS-Class

I'm developing an application which can deal with a MS-ADLDS-Service.
Currently it is possible to create Directory-Entries and assign values to some properties.
Not a realy exciting task until this:
Im my application it's possible (it should be) to configure which properties of a class (for instance: the CN=Person class) should be assigned with values which are evaluated at runtime in my application.
Long story short:
I want to retrieve all (writeable) properties of a class. Without creating and saving a new CN=Person-Object before.
Currently i use my schemaBinding to get the Directory-classSchema-Entry of the Person-Class (CN=Person) from where i read some property-values (like "AllowedAttributesEffective", "mayContain", "AllowedAttributes") - i get the most properties by this way - but some Properties are missing! For instance the "telephoneNumber"-Property (attributeSchema: CN=Telephone-Number)
Does anybody know how to get these properties of a class? ADSI-Edit does this: when i create a new object with adsi-edit i can assign values to all possible properties before committing the new entry.
thanks a lot for any hint!
(.net code is welcome)
I have found the solution for my task!
Some of these properties are "calculated" and not persistent at the directoryentry.
So its meant to call the RefreshCache() Method and pass the needed property names as an string array.
directoryEntry.RefreshCache(new string[] { "allowedAttributesEffective",
"allowedAttributes",
"systemMayContain",
"systemMustContain" });
After that call, the properties have values....
if (directoryEntry.Properties["systemMayContain"]).Value != null)
{
/// Success
}

Share application settings between projects and use data binding from one of the project in wpf

I am working on an Application which has multiple projects in it. Lets just consider two for now ProjectCore and ProjectUI.
I need to share Application settings between these projects. What i did was, created Settings file at Solution level and add those settings as link in these projects (Add Existing Item -> Add as Link).
ProjectUI has some UIControls that are bind to Settings.Default's different Settings. And ProjectCore sets value to Settings.Default as well.
Now if i use each project's Settings instance from Settings.Designer, they will be two different instances. So binding will not work if i set some value from ProjectCore.
ProjectUI depends on ProjectCore, so i can not just add Settings in ProjectUI and write a wrapper in ProjectUI and use that to set value from ProjectCore. This will create circular dependency.
Now how can i share and Settings file and keep the binding working for ProjectUI?
Hope it may help you, I just create a sample in which i took two projects as you said, then i add setting to core project and change its access modifier to public and give its reference to UI, now i can access those setting in my UI project.
for. e.g.
test.Settings1.Default.SettingTest = "test";
here test is namespace, Setting1 is class and Default is static instance of Setting1 class.
SettingTest is my setting of type string. Though SettingTest is read-only i change its definition in desginer.cs to
public string SettingTest {
get {
return ((string)(this["SettingTest"]));
}
set {
this["SettingTest"] = value;
}
}

C# property attributes

I have seen the following code:
[DefaultValue(100)]
[Description("Some descriptive field here")]
public int MyProperty{...}
The functionality from the above snippit seems clear enough, I have no idea as to how I can use it to do useful things. Im not even sure as to what name to give it!
Does anyone know where I can find more information/a tutorial on these property attributes?
I would be also interested in any novel / useful tasks this feature can do.
The functionality from the above
snippit seems clear enough,
Maybe not, as many people think that [DefaultValue()] sets the value of the property. Actually, all it does to tell some visual designer (e.g. Visual Studio), what the code is going to set the default value to. That way it knows to bold the value in the Property Window if it's set to something else.
People have already covered the UI aspect - attributes have other uses, though... for example, they are used extensively in most serialization frameworks.
Some attributes are given special treatment by the compiler - for example, [PrincipalPermission(...)] adds declarative security to a method, allowing you to (automatically) check that the user has suitable access.
To add your own special handling, you can use PostSharp; there are many great examples of using PostSharp to do AOP things, like logging - or just code simplification, such as with automatic INotifyPropertyChanged implementation.
They are called Attributes, there is a lot of information in msdn, e.g. http://msdn.microsoft.com/en-us/library/z0w1kczw.aspx
In general they don't "do" anything on their own, they are used by some other code that will use your class. XmlSerialization is a good example: XmlSerializer (provided by Microsoft as part of the framework) can almost any class (there are a number of requirements on the class though) - it uses reflection to see what data is contained in the class. You can use attributes (defined together with XmlSerializer) to change the way XmlSerializer will serialize your class (e.g. tell it to save the data as attribute instead of an element).
The ones in your example is used by the visual designer (i.e. MS Expression Blend and Visual Studio designer) to give hints in the designer UI.
Note that they are metadata and will not affect the property logic. Setting DefaultValue for instance will not set the property to that value by default, you have to do that manually.
If you for some reason want to access these attributes, you would have to use reflection.
See MSDN for more information about designer attributes.
We use it to define which graphical designer should be loaded to configure
an instance of a specific type.
That is to say, we have a kind of workflow designer which loads all possible command
types from an assembly. These command types have properties that need to be configured,
so every command type has the need for a different designer (usercontrol).
For example, consider the following command type (called a composite in our solution)
[CompositeMetaData("Delay","Sets the delay between commands",1)]
[CompositeDesigner(typeof(DelayCompositeDesigner))]
public class DelayComposite : CompositeBase
{
// code here
}
This is information is used in two places
1) When the designer creates a list of commands, it uses the CompositeMetaData
to display more information about the command.
2) When the user adds a command to the designer and the designer creates
an instance of that class, it looks at the CompositeDesigner property,
creates a new instance of the specified type (usercontrol) and adds it
to the visual designer.
Consider the following code, we use to load the commands into our "toolbar":
foreach (Type t in assembly.GetExportedTypes())
{
Console.WriteLine(t.Name);
if (t.Name.EndsWith("Composite"))
{
var attributes = t.GetCustomAttributes(false);
ToolboxListItem item = new ToolboxListItem();
CompositeMetaDataAttribute meta = (CompositeMetaDataAttribute)attributes
.Where(a => a.GetType() == typeof(Vialis.LightLink.Attributes.CompositeMetaDataAttribute)).First();
item.Name = meta.DisplayName;
item.Description = meta.Description;
item.Length = meta.Length;
item.CompositType = t;
this.lstCommands.Items.Add(item);
}
}
As you can see, for every type in the assembly of which the name ends with "Composite",
we get the custom attributes and use that information to populate our ToolboxListItem instance.
As for loading the designer, the attribute is retreived like this:
var designerAttribute = (CompositeDesignerAttribute)item.CompositType.GetCustomAttributes(false)
.Where(a => a.GetType() == typeof(CompositeDesignerAttribute)).FirstOrDefault();
This is just one example of how you might be able to use custom attributes,
I hope this gives you a place to start.
These attributes customize the design time experience.
http://msdn.microsoft.com/en-us/library/a19191fh.aspx

Categories