NDOC 2005 document your code

I downloaded the latest sources and binaries for NDOC 2005 (at time of writing in November 2007) it was not working for our project.

I changed the piece of sourcecode (see below) which worked for me.

Replace the entire method at the end of this article with the code given and it should work again. At least, it worked for me.

With NDOC 2005 you can generate beautifull source code documentation for your classes components. Works with Visual Studio 2005 C# .Net 2.0

Addition: later I found out that there is another version of NDOC 2.0 which is working right from scratch.

However if you want to play around with NDOC 2005, here is the code you definately will need to run the software:

Namespace: NDoc.Documenter.Msdn
class MsdnHtmlUtilitiesV20

/// <summary>
/// Initialize namespace dictionary
/// </summary>
public static void InitializeNamespaces(Project project)
{
// If we don't have namespaces list yet, go through each referenced assembly,
// load the assembly, get the types, then cache the namespaces for all public types.
if (namespaces.Count == 0)
{
foreach (AssemblySlashDoc doc in project.AssemblySlashDocs)
{
//

string strDllFullPath = doc.Assembly.Path;

string strDllPath = strDllFullPath.Substring(0, strDllFullPath.LastIndexOf(@"\") + 1);

//

Assembly theAssembly = Assembly.LoadFrom(doc.Assembly);
AssemblyName[] assemblies = theAssembly.GetReferencedAssemblies();
foreach (AssemblyName an in assemblies)
{
//Assembly assembly = Assembly.LoadWithPartialName(an.Name);
Assembly assembly = null;

try
{

assembly = Assembly.LoadFrom(strDllPath + an.Name + ".dll");

}

catch (Exception ex)
{

try
{

assembly = Assembly.Load(an.FullName);

}

catch (Exception ex1)
{

continue;

}

}

if (assembly == null)
{
throw new System.IO.FileNotFoundException(String.Concat("Unable to locate the referenced Assembly ", an.Name));
}
try
{
Type[] assemblyTypes = assembly.GetTypes();
foreach (Type type in assemblyTypes)
{
if (type.IsPublic)
{
if (type.Namespace != null)
{
namespaces[type.Namespace] = type.Namespace.Replace('.', '_') + '_';
namespaces[type.Namespace.Replace(".", "")] = type.Namespace.Replace('.', '_') + '_';
}
}
}
}
catch (System.Reflection.ReflectionTypeLoadException refException)
{
// could not getTypes
continue;

}

}
}
}
}