致谢
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'propertiesLoader' defined in URL
[file:/.../tomcat/work/Catalina/localhost/_/loader/conf/spring/springmvc/springmvc-util.xml]: Invocation of init method failed;
nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/home/.../propertyfilename.properties]
答案 0 :(得分:1)
选项1-使用NotifyIcon
您可以使用的最简单的修复方法是使用不可见的NotifyIcon
组件,因为它可以在内部code中处理这种情况。
将NotifyIcon
的实例拖放到窗体上,然后将其用于显示上下文菜单,将上下文菜单条分配给其ContextMenuStrip
属性,然后使用以下方法调用其ShowContextMenu
私有方法反思。
示例
Private Sub ShowContextMenu(menu As ContextMenuStrip)
NotifyIcon1.Visible = False
NotifyIcon1.ContextMenuStrip = menu
Dim m = NotifyIcon1.GetType().GetMethod("ShowContextMenu",
Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance)
m.Invoke(NotifyIcon1, Nothing)
End Sub
Protected Overrides Sub WndProc(ByRef Window_Message As Message)
If Window_Message.Msg = Hot_Key Then
Dim id As IntPtr = Window_Message.WParam
Select Case (id.ToString)
Case "100"
ShowContextMenu(CMS_01)
End Select
End If
MyBase.WndProc(Window_Message)
End Sub
选项2-使用本机窗口
这是不使用NotifyIcon
或使用NativeWindow
的修复程序。以下代码关心活动窗口,如果当前窗体处于活动状态,则它不使用本机窗口,否则将创建并使用本机窗口。
示例
Private window As NativeWindow
Private Sub ShowContextMenu(menu As ContextMenuStrip, p As Point)
If (Form.ActiveForm IsNot Me) Then
If (window Is Nothing) Then
window = New NativeWindow()
window.CreateHandle(New CreateParams())
End If
SetForegroundWindow(window.Handle)
End If
menu.Show(p)
End Sub
并显示菜单:
ShowContextMenu(CMS_01, Cursor.Position)
在关闭/处置表单时,请记住要释放窗口句柄:
If (window IsNot Nothing) Then
window.DestroyHandle()
window = Nothing
End If