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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Notifyicon() not working when built into application (.exe)

Solved!
Go to solution

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.

0 Kudos
Message 1 of 12
(3,540 Views)

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.

0 Kudos
Message 2 of 12
(3,531 Views)

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


"Should be" isn't "Is" -Jay
Message 3 of 12
(3,526 Views)

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...

0 Kudos
Message 4 of 12
(3,520 Views)

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...


 


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 12
(3,518 Views)

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,

 

 

0 Kudos
Message 6 of 12
(3,514 Views)

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="v
2.0.50727"/>
</startup>
</configuration>

 

 

A lot of the issues may be related to HOW you build.  Are you building from a project or library?


"Should be" isn't "Is" -Jay
Message 7 of 12
(3,511 Views)

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.

0 Kudos
Message 8 of 12
(3,508 Views)
Solution
Accepted by topic author dthor

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...

Message 9 of 12
(3,504 Views)

GREAT NEWS!

 

you were begining to stump meSmiley WinkSmiley Very Happy

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!


"Should be" isn't "Is" -Jay
Message 10 of 12
(3,498 Views)