Blog

Mai 11
Assembly {Name} could not be uninstalled because it is required by another application

Problem 

Trying to uninstall assembly in GAC.

gacutil /u AssemblyName
Assembly {Assembly} could not be uninstalled because it is required by another application.

Solution

(1) Assembly is still mapped to windows installer. Normally you can solve this problem by deleting the Windows Installer Key to this assembly. Delete Key: HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Assemblies\Global \{AssemblyName}

(2) Uninstall GAC:
gacutil /u AssemblyName

Trying to uninstall assembly in GAC.
gacutil /u AssemblyName
Assembly {Assembly} could not be uninstalled because it is required by another application.​

Mai 09
INotifyPropertyChanged - Implemenation

For the implementation of ViewModel we use INotifyPropertyCh​anged interface. Many realisation of this problem are possibly, this this article we go through different ways to solve this problem.​​

The easy one

 

public class MainViewModelSimple : INotifyPropertyChanged

{

private string _name;

public string Name

{

get { return _name; }

set

{

if(_name == value)

{

return;

}

_name = value;

OnPropertyChanged("Name");

}

}

 

public event PropertyChangedEventHandler PropertyChanged;

 

protected virtual void OnPropertyChanged(string propertyName)

{

PropertyChangedEventHandler handler = PropertyChanged;

if (handler != null)

{

handler(this, new PropertyChangedEventArgs(propertyName));

}

}

}


This is a easiest way to implement PropertyChanged and the problem is obvious if you take a closer look to OnPropertyChange arguments. For using you have to pass on the property name as string. During the small refactorings the property name might change without the changing the caller signature,so this is a high-maintanace solution.

 ​

The advanced imlemenatio​n


public class MainViewModelAdvanced : INotifyPropertyChanged

{

private string _name;

public string Name

{

get

{

return _name;

}

set

{

if (_name == value)

{

return;

}

_name = value;

OnPropertyChanged(() => Name);

}

}

 

public event PropertyChangedEventHandler PropertyChanged;

 

protected virtual void OnPropertyChanged(string propertyName)

{

var handler = PropertyChanged;

if (handler != null)

PropertyChanged(this, new PropertyChangedEventArgs(propertyName));

}

 

protected void OnPropertyChanged(Expression<Func<object>> expression)

{

if (expression == null || !(expression.Body is MemberExpression))

{

return;

}

var memberName = ((MemberExpression)expression.Body).Member.Name;

PropertyChanged(this, new PropertyChangedEventArgs(memberName));

}

}

 

 

 

The new possibilities with Framework 4.5

public class MainViewModelWith45 : INotifyPropertyChanged

{

private string _name;

public string Name

{

get { return _name; }

set

{

if (_name == value)

{

return;

}

_name = value;

OnPropertyChanged();

}

}

public event PropertyChangedEventHandler PropertyChanged;

 

protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = "")

{

var handler = PropertyChanged;

if (handler != null)

{

handler(this, new PropertyChangedEventArgs(propertyName));

}

}

}​​


Have fun ... 

Elena

Apr 09
Left/Right/Inner Join
class t1 {public string k {get;set;}}
class t2 {public string k {get;set;}}
void Main()
{
    var list1 = new List<t1>{new t1{k="a1"}, new t1{k="a2"}, new t1{k="a3"},};
    var li​​st2 = new List<t2>{new t2{k="a1"}, new t2{k="a2"}, new t2{k="a0"},};

    // inner join
    var query = from l1 in list1
                join l2 in list2 on l1.k equals l2.k
                select new{l1,l2};
    query.Dump();

    // left join
    var query2 = from l1 in list1
                 join l2 in list2 on l1.k equals l2.k into joned
                 from row in joned.DefaultIfEmpty()
                 select new {l1, row};
    query2.Dump();

    // right join
    var query3 = from l2 in list2
                 join l1 in list1 on l2.k equals l1.k into joned
                 from row in joned.DefaultIfEmpty()
                 select new {row, l2};
    query3.Dump();
}
Jul 01
Publish Microsoft Project data using XSL transformation

​Problem

For some of my customers I use Microsoft Project to schedule our work. In all of these cases I have a problem to inform all project members about newly planned features or changed deadlines, because they do not have a Microsoft Project version installed or do not know how to use it. What I need is an export of in-project planned tasks and features to a common readable format like HTML, which I would be able to publish in the company portal.​

Idea 

  • ​​Save M​icrosoft Project File as XML
  • Use XSL​ transformation to visu​​​alize the exported data

Important: The exporte​​d *.xml file does not have to be modified. All you have to do at the end is just save the project file as XML.

On the internet I found many solutions where the XSL files have to be added to XML or original project XML namespaces have to be removed first from the XML file to make the transformation. But come on guys who wants to modify the created document after each saving, no one would do this.​

Sol​​​ution

  1. Save your Microsoft Project as *.xml. I always do this once at the end of the working day and have the a fixed name for this, let’s say ProjectData.xml

  2. I created two files: Project.xml (container file for saving a connection to exported project data) and ProjectTransformation.xsl (transformations and styles for interpreting project data )

clip_image001 

A closer look

Project.xml

A really simple container with an inclusion of the original project xml export:

<?xml version="1.0" encoding="UTF-8" standalone="yes"> 
<?xml-stylesheet type="text/xsl" href="ProjectTransformation.xsl" ?>

<Root> 
     <ProjectFile name="ProjectData.xml" /> 
</Root>

ProjectTransformation.xsl

1. Include the original namespace to your translation:

<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:p="http://schemas.microsoft.com/project" 
    exclude-result-prefixes="p"
>

2. Now you can use the necessary ProjectData.Xml elements to create your own presentation.

<?xml version="1.0" encoding="iso-8859-1"?> 
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:p="http://schemas.microsoft.com/project" 
    exclude-result-prefixes="p"> 
    
    <xsl:template match="/"> 
        <xsl:for-each select="/Root/ProjectFile"> 
            <xsl:apply-templates select="document(@name)/p:Project" /> 
        </xsl:for-each> 
    </xsl:template> 
    
    <xsl:template match="p:Project"> 
        <html> 
            <body> 
                <h1> Project <xsl:value-of select="p:Title" /> Overview </h1> 
             
                <table border="0" style="border: gray 1px bottom;"> 
                    <tr> 
                       <td> 
                           <b>Id</b> 
                       </td> 
                       <td> 
                           <b>Title</b> 
                       </td> 
                       <td width="50%"> 
                           <b>Description</b> 
                       </td> 
                   </tr> 
                   <xsl:for-each select="p:Tasks/p:Task"> 
                       <tr> 
                           <td> 
                               <xsl:value-of select="p:ID"/> 
                           </td> 
                           <td>                      
                                <xsl:value-of select="p:Name"/>                        
                           </td> 
                           <td> 
                               <xsl:value-of select="p:Notes"/> 
                           </td> 
                       </tr>  
                   </xsl:for-each> 
               </table> 
       </body> 
       </html> 
    </xsl:template> 
</xsl:stylesheet>

  

Files

The example is created and tested with Microsoft Project 2010. You can download the code of the example ProjectAsXsl.zip.​