Can't get feature reporting to work on console app

smudasmuda Posts: 24
edited January 11, 2012 7:25AM in SmartAssembly
Hi All!

I have three apps (1 winform and 2 console apps) that I'm trying to enable feature usage reporting on.

All is well on the winform and one console app, but the last console app doesn't show the "Would you like to send feedback..." question. The one thing that puzzles me is that at first run the console application automatically adds a registry entry "SmartAssemblyReportUsage" with the value of "False". If I change the value to "True", feature reports are generated.

What have I missed to get the "Would you like to send feedback..." question?

I have verified in the project that FeatureUsage Reporting is enabled with the standard template provided by SmartAssembly "With consent dialog box on first run".

From the saproj file:
<FeatureUsageReporting ReportUsages="1" Template="res:SmartUsageWithUIConsentFirstRun1033.dll" />

Best Regards,

John

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Hi John,

    Sorry, I don't know what could be wrong. The "first run" dialog should come up and set the registry key according to the user's wishes.

    The "standard template" should be embedded into your assembly so if it's not coming up I probably couldn't tell you why not without seeing the assembly.
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Based on one of your other posts, I have to ask, are you trying to put the feature usage reporting in a DLL? Because as I recall it has to go on the main assembly if you want the "first use" dialog to come up.
  • Hi Brian!

    Yes, I'm trying to handle feature usage in the common dlls for the three projects. However, since I read somewhere that to get the feature usage template working I need to set the ReportUsage on the entry method, which I've done for both the console apps:
    internal class Program
    &#123;
    	&#91;ReportUsage&#40;"ApduScriptPlayer"&#41;&#93;
    	&#91;STAThread&#93;
    	private static void Main&#40;string&#91;&#93; args&#41;
    	&#123;
    
    I'd be happy do upload the obfuscated assembly, project file or even the input assemblies to you, if you think it can help.

    John
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    You only have to put the attribute on the methods you want to report on and then reportusage in the places where you want the feature usage reported. Please see: http://www.red-gate.com/supportcenter/C ... _using_fur

    According to this you don't have to do anything to the entry point.
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    I just went through the SmartAssembly source code to confirm this -- Feature Usage asks the user whether or not he wants to send reports the first time feature usage is gathered from the program. So unlike Error Reporting, it should work on the dll without having to do anything to the main assembly.

    As far as I can work out from the source (and maybe this is a bad assumption), you should be able to get the user request box back up if the SmartAssemblyReportUsage registry key does not exist or has no value.
  • Yes, removing the SmartAssemblyReportUsage registry entry on the other two assemblies makes the dialog re-appear, but not this one.

    Is there any logging that can be enabled for the feature usage within the merged assembly?

    I suppose the default template is the one included in SA. If you look on line 21 it sets the registry value to false and AskUserForReportUsageConfirm(). If something happens there it will have the exact same behavior that I'm experiencing. I think I'll try with a custom template (based on this) with more error handling.

    Best Regards,

    John
  • By adding message boxes in the UsageReporterWithUI sample I realized that the thread used for displaying the dialog for user permission is run on a background thread.

    This means that when the console app is done on it's thread, all background threads are simply dismissed.

    I added a Thread.Sleep in the console application and the dialog for the user pops up nicely. I can wait and then see it disappear once the application ends.

    :idea: Perhaps there could be a checkbox to NOT make the thread a background thread in the saproj settings would be a good thing?

    :idea: I note that once the reporting is added, the application takes another half second (roughly) to end and I suppose this is because of the actual reporting. During that time, you could also check if the reporting thread you spawned which is waiting for the user input has ended. Perhaps a Thread.Join would be a good thing at that point?

    Best Regards,

    John
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Hi John,

    I'm told the idea is not to leave a console process hanging,waiting for input, if the dialog comes up. Apparently we are already looking at alternate ways of "opting in" on console applications.
Sign In or Register to comment.