コードでオプション strict ON を設定するために、実際には問題なく動作するコードでエラーが発生します。
Public Function ModifyRegistryKey(ByVal rClass As String, ByVal rKey As String, ByVal rValName As String, ByVal rValue As String) As Integer
'Grant Read, Write and Create permissions for the key
Dim f As New RegistryPermission(RegistryPermissionAccess.Read Or _
RegistryPermissionAccess.Write Or _
RegistryPermissionAccess.Create, rKey)
Dim regKey As Object
Try
'Check if it exists. If it doesn't it will throw an error
regKey = My.Computer.Registry.CurrentUser.OpenSubKey(rKey, True).GetValue(rValName)
Catch ex As Exception
regKey = Nothing
End Try
If regKey Is Nothing Then
'It doesn't exist here. Create the key and set the key name and value.
regKey = My.Computer.Registry.CurrentUser.CreateSubKey(rKey)
regKey.SetValue(rValName, rValue) 'LATE BINDING HERE
Else
'Registry key exists
If Not regKey Is rValue Then
My.Computer.Registry.SetValue(rClass & "\" & rKey, rValName, rValue)
End If
End If
End Function
エラー メッセージが表示される理由: 「Option Strict On は遅延バインディングを許可しません。」ここで遅延バインディングを取り除く方法は?