选项Strict会抛出 Late Binding 的错误,我总是将对象转换为正确的类型,但在这个特定的情况下,我不知道如何投射这个物体。
警告发生在指令Shell.ToggleDesktop()
以下是代码:
''' <summary>
''' "Shell" CLASSID.
''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/bb776890%28v=vs.85%29.aspx
''' </summary>
Private Shared ReadOnly CLSIDShell As New Guid("13709620-C279-11CE-A49E-444553540000")
''' <summary>
''' Gets the objects in the Shell.
''' Methods are provided to control the Shell and to execute commands within the Shell.
''' There are also methods to obtain other Shell-related objects.
''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/bb774094%28v=vs.85%29.aspx
''' </summary>
Private Shared ReadOnly Property Shell As Object
Get
If _Shell Is Nothing Then
_Shell = Activator.CreateInstance(Type.GetTypeFromCLSID(CLSIDShell))
Return _Shell
Else
Return _Shell
End If
End Get
End Property
Private Shared _Shell As Object = Nothing
''' <summary>
''' Shows or hides the desktop.
''' </summary>
Friend Shared Sub ToggleDesktop()
Shell.ToggleDesktop()
End Sub
答案 0 :(得分:1)
您收到此错误,因为Object
类型未公开名为ToggleDesktop
的方法。
您可以为此代码文件设置Option Strict Off
,或者创建一个包装器并使用反射来调用该方法。