From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-16-2011 01:44 PM
Hey everyone,
I'm using the NotifyIcon() from System.Windows.Forms.dll (.NET 2.0) to create a menu for controlling an application. I began work using the example shown here http://zone.ni.com/devzone/cda/epd/p/id/3915, and the code works when running in the LabVIEW IDE.
However, when I build the code into an executable, the icon is not displayed when running. Anyone have any idea what could be wrong?
My code is still very messy (still in the try-everything-and-see-what-works phase), so I'll clean it up before returning and posting it.
For reference, I'm trying to make a system-tray-only monitor for a NI DAQ 6009. Program starts off in the system tray and starts recording data. User can right click to show the main window where he can change the update interval or view plots.
Solved! Go to Solution.
05-16-2011 03:14 PM - edited 05-16-2011 03:24 PM
Here's the code. It works in the LabVIEW IDE, but not when built into an executable. What am I missing?
EDIT: Forgot to mention, this requires the OpenG "Wait (ms)" subVI. Everything else needed should be included.
05-16-2011 03:19 PM - edited 05-16-2011 03:27 PM
the DLL needs to be located where the executable can find it. The IDE knows to look for the dll in all the normal places however the RTE does not. Place a copy of the dll in the same folder as your executable and you should be golden.
Getting a exe to work with a .NET ref is an easy way to get in trouble- but if you check out HERE you'll find where I got schooled in the art
and several KBs are here
05-16-2011 03:26 PM
And which DLL would that be? My code doesn't use any DLL calls, it uses the .NET 2.0 framework NotifyIcon() constructor.
Unless I'm misunderstanding something and there's a hidden DLL call somewhere...
05-16-2011 03:29 PM
the .net methods are in a dll. Lots of good info out there
@dthor wrote:
And which DLL would that be? My code doesn't use any DLL calls, it uses the .NET 2.0 framework NotifyIcon() constructor.
Unless I'm misunderstanding something and there's a hidden DLL call somewhere...
05-16-2011 03:53 PM
Ok, so I found the DLL (...\Windows\Microsoft.NET\Framework\v2.0.50727) and copied it to the executable folder. This didn't solve the problem. Next, I copied it to the project directory, added it to the project, had it "always included" in the build, and rebuilt the app. No dice. Then I changed the constructor node to point at the .dll file that I'd copied to the project folder, rebuilt the app. Still nothing.
One of the links you gave me suggested restarting LabVIEW, so I tried that. Again, not working as a .exe, but is working in the IDE.
Have any other suggestions?
Thanks,
05-16-2011 04:14 PM
add this the the exe config?
Per this KB "The configuration file needs to be placed next to LabVIEW.exe and be named LabVIEW.exe.config. The following example will instruct LabVIEW to load the CLR:"
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
A lot of the issues may be related to HOW you build. Are you building from a project or library?
05-16-2011 04:45 PM
Forgot to mention that one, yes I have that labview.exe.config in the ...\LabVIEW 2010 folder. The icon is still not showing up.
I'm building from a project, with almost all the standard (default) options. I've changed the build spec name, target filename, and destination directory, none of which should have any effect. I have my main.vi as the Startup VI, and I added System.Windows.Forms.dll to the always included list, and set its destination to be "Same as Caller." Other than that, no changes to the build settings.
05-16-2011 05:02 PM
Ok, I got it working!
Turns out that I had a few mistakes:
1. When I copied over the System.Windows.Forms.dll, I also needed to copy System.Drawing.dll because I used that when creating the icon.
2. I had the .dll files put into the build directory, but I'd forgotten to also include the icons used by the program.
Turns out the NotifyIcon() was being called, but an icon image was never created! Hence why I couldn't see it...
05-16-2011 08:10 PM - edited 05-16-2011 08:11 PM
GREAT NEWS!
you were begining to stump me
Congrats!
@dthor wrote:
Ok, I got it working!
Turns out that I had a few mistakes:
1. When I copied over the System.Windows.Forms.dll, I also needed to copy System.Drawing.dll because I used that when creating the icon.
2. I had the .dll files put into the build directory, but I'd forgotten to also include the icons used by the program.
Turns out the NotifyIcon() was being called, but an icon image was never created! Hence why I couldn't see it...
I guess you get the solution!