If you are getting errors like “Plugin blah or one of its dependencies could not be resolved” you may find this useful.
There is an issue with Maven 3.0.3 (and I assume earlier) in that plug-in repositories need to be separately configured from the normal repository. The maven settings file must contain something like this:
With 3.0.4, maven will pick up the plugin repository information from the repositories configuration.
Found these reg settings that are very useful and didn't know where to put them for future reference. So here they are.
Windows Registry Editor Version 5.00
@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
@="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
I needed my WPF controls size in pixels to retrieve the correct sized image from a web service. The answer hit me one night and it’s very simple:
Create a known size image (say 100 x 100 pixels), put it in a image control on some bit of WPF screen (Hidden not collapsed), ensure no stretching by putting Stretch=None and a non-stretch value for both Horizontal and Vertical alignment and make the calculation from the Image controls actual width and height.
This bit of xaml shows what I did:
<Image x:Name="ImageControl" Stretch="Uniform"/>
A calculation with look something like this:
(In my case I wrapped it up in a UserControl with SizeTarget, a bound property, being a specific interface with just width and height that can be implemented elsewhere.)
SizeTarget.PixelWidth = (int)Math.Truncate(ActualWidth * 100 /
My problem: A program was using 127.0.0.2 (an alias for 127.0.0.1) to make a local connection on a specific port. However, one Windows 2003 server box was configured so that this port was being listened to on a specific network adapter (and hence a specific IP address). Hence, my local connection failed even though the port was open for listening.
Background: Type “netstat -p tcp -a -n” at the command prompt to get details of listening ports. The “Local Address” is adapter specific; “0.0.0.0” means it’s listening on all adapters (thus allowing connections to 127.0.0.1). In the case of this 2003 box, the port I wanted was specific to a particular IP address (adapter).
So, my program needed to connect to the adapter specific IP address and not 127.0.0.1. This is how to get the IP addresses and ports they’re listening on:
DWORD size = 0;
// first get the size of the buffer required
std::cerr << "Error " << err <<
" getting tcp table size." << std::endl;
// next get the table
MIB_TCPTABLE *tbl = reinterpret_cast(&(*buf.begin()));
std::cerr << "Error " << err <<
" getting tcp table." << std::endl;
// iterate through the entries
for (DWORD dw = 0; dw < tbl->dwNumEntries; ++dw)
if(tbl->table[dw].dwState == MIB_TCP_STATE_LISTEN)
ad.S_un.S_addr = tbl->table[dw].dwLocalAddr;
std::cout << "Listening " << inet_ntoa(ad) <<
", port " << ntohs(tbl->table[dw].dwLocalPort) << std::endl;
To use an icon resource embedded into your assemply:
1) Add icon to project and make it an “Embedded Resource” type (no need to copy to output directory).
2) Construct your System.Drawing.Icon like this:
Where MyShinyApp is the value specified in “Default namespace” property of your project (Application tab of project properties) and hammer.ico is the name of your icon.
I had to do a bit of searching so, here’s how to minimize your WPF app to a tray icon. Assume your window is called Window1 for the code below. Trap Closing, StateChanged and IsVisibleChanged (see xaml).
<window x:Class="MyApp.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="WCFAppVisualHost" Height="383" Width="680" Closing="OnClose" StateChanged="OnStateChanged" IsVisibleChanged="OnIsVisibleChanged"
private System.Windows.Forms.NotifyIcon m_notifyIcon;
// initialise code here
m_notifyIcon = new System.Windows.Forms.NotifyIcon();
m_notifyIcon.BalloonTipText = "The app has been minimised. Click the tray icon to show.";
m_notifyIcon.BalloonTipTitle = "The App";
m_notifyIcon.Text = "The App";
m_notifyIcon.Icon = new System.Drawing.Icon("TheAppIcon.ico");
m_notifyIcon.Click += new EventHandler(m_notifyIcon_Click);
void OnClose(object sender, CancelEventArgs args)
m_notifyIcon = null;
private WindowState m_storedWindowState = WindowState.Normal;
void OnStateChanged(object sender, EventArgs args)
if (WindowState == WindowState.Minimized)
if(m_notifyIcon != null)
m_storedWindowState = WindowState;
void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs args)
void m_notifyIcon_Click(object sender, EventArgs e)
WindowState = m_storedWindowState;
void ShowTrayIcon(bool show)
if (m_notifyIcon != null)
m_notifyIcon.Visible = show;
I’ve always wondered (and again two days ago) what “irreversible loss of information” is being referd to when you reset a local user password from the “Computer Management” console. Independantly, I’ve been tracking down a bug reported by one PMG Connect user in which the connection routine fails.
These things are linked. The bug was a call to cryptography API CryptAquireContext failing with error NTE_BAD_KEY_STATE. (Ok, I admit, if the software was reporting faults better, this could have been determined ages ago.) In short, it was attempting to open a key container that existed but couldn’t be used because the user had reset the password. Checkin the web, this occurs with a lot of software (one suggested work-around was to create a new user account!).
So, that’s some of what loss of information occurs. To fix this problem, the software attempts to open key containers with different names when that error is encounted.