Hey all,

I've been doing a few C# based custom actions and find the DTF "stuff" very
easy to use and it works quite well. 

However I'm wondering if there is anyway to include my custom action DLL's
PDB file with the actual CA? If the .PDB was extracted and copied to the
same location as the .DLL then if the .DLL throws an unhandled exception the
stack trace would include an exact line number reference.

I find that having an exact line number reference to be exceptionally useful
when diagnosing problems. Especially null object errors that can creep in at
unexpected places. Have an exact line number reduces the possible places a
single function could be failing because of a null reference error.

Having this would avoid needed to add logging after each and every line
(which is overkill and brute force... but if I need to know exactly where a
function is crapping out there's not much choice).

For example here is a custom action that installs a list of assemblies and
their associated PDB's into the GAC:

/// <summary>
/// Install a list of files into the GAC.
/// </summary>
/// <param name="session"></param>
/// <returns>ActionResult.Success if the files where installed successfull. 
/// Otherwise the action has thrown an unexpected exception.</returns>
[CustomAction]
public static ActionResult InstallFilesToGac(Session session)
{
    //
    // Show a nice status message
    //
    session.Message(InstallMessage.ActionStart, new Record(new object[] {
"Installing assemblies in the Global Assembly Cache" }));
    session.Log("Installing assemblies in the Global Assembly Cache");

    //
    // Build a reference using specific values
    //  - The reference is used by the GAC for reference count purposes.
Each
    //    installer that installs a given assembly should provide its own 
    //    reference. When all references have been removed from the GAC
    //    then the assembly will actually be removed from the GAC.
    //
    string ReferenceGuid = "{USE_YOUR_OWN_GUID}";
    string ReferenceDescription = "Your Installer";
    InstallReference Reference = new
InstallReference(InstallReferenceGuid.OpaqueGuid, ReferenceGuid,
ReferenceDescription);

    //
    // Process each file
    //
    session.Log("Number of files to install: {0}",
session.CustomActionData.Values.Count);
    foreach (string Filename in session.CustomActionData.Values)
    {
        //
        // Ought not happen but rather safe than sorry
        //
        if (!string.IsNullOrEmpty(Filename))
        {
            //
            // Add the assembly to the GAC
            //
            session.Log("Install in the GAC: {0}", Filename);
            AssemblyCache.InstallAssembly(Filename, Reference,
AssemblyCommitFlags.Default);

            //
            // If a PDB exists then copy it to the GAC as well
            //
            string PdbFilename = Path.ChangeExtension(Filename, "pdb");
            if (!File.Exists(PdbFilename))
            {
                session.Log("No PDB was found: {0}", PdbFilename);
            }
            else
            {
                session.Log("PDB found: {0}", PdbFilename);
                string StrongName = GetStrongTypeName(Filename);
                session.Log("Assembly strong name: {0}", StrongName);
                string GacFileLocation =
AssemblyCache.QueryAssemblyInfo(StrongName);
                session.Log("GAC location: {0}", GacFileLocation);
                string GacPDbFileLocation =
Path.ChangeExtension(GacFileLocation, "pdb");
                session.Log("PDB GAC location will be: {0}",
GacPDbFileLocation);
                File.Copy(PdbFilename, GacPDbFileLocation);
                session.Log("PDB copied to GAC");
            }
        }
    }

    //
    // Success
    //
    session.Log("All assemblies installed in the GAC");
    session.Log("Returning ActionResult.Success");
    return ActionResult.Success;
}


When I was first putting this together I was having trouble getting
parameters passed in and a couple of other problems... but debugging was
challenging. I couldn't get the actual debugger to work... and even if I had
I would still prefer to have the DTF runtime be able log the exact error
location.

So... any ideas on how to get a .PDB for a DTF custom action to be "carted
around" with the actual dll?

Regards,

Rob





------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to