首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >选项严格后期绑定错误问题

选项严格后期绑定错误问题
EN

Stack Overflow用户
提问于 2014-09-28 07:10:11
回答 1查看 93关注 0票数 0

这个选项严格地抛出了后期绑定的错误,我总是将对象强制转换为正确的类型,但在这种特殊情况下,我不知道如何转换这个对象。

警告发生在指令Shell.ToggleDesktop()中。

以下是代码:

代码语言:javascript
复制
''' <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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-28 08:27:46

获得此错误是因为类型Object不公开名为ToggleDesktop的方法。

您可以为这个代码文件设置Option Strict Off,或者创建一个包装器并使用反射来调用该方法。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26082536

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档