-
Notifications
You must be signed in to change notification settings - Fork 842
Closed
Labels
BugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Description
- VS 2015 Update 1
- New F# 4.0 console project, .NET 4.6.1
- Add COM reference to "Microsoft WMI Scripting V1.2 Library"
I know COM interop issues aren't so glamorous 😢
open System
open WbemScripting
let locator =
let comTy = Type.GetTypeFromProgID("WbemScripting.SWbemLocator")
Activator.CreateInstance(comTy) :?> SWbemLocator
let services = locator.ConnectServer()
let resultSet = services.ExecQuery("select * from Win32_Processor")
resultSet
|> Seq.cast<SWbemObject>
|> Seq.map (fun o -> o.GetObjectText_(0))
|> Seq.iter (printfn "%s")Above complete program compiles, but fails to verify & blows up with InvalidProgramException. Issue is a rogue ldarg.0 instruction in the main@ () method, which doesn't have any arguments.
Bogus instruction is emitted around the same place that default values for omitted COM method arguments are being loaded, which made me guess this is some mishandling of optional arguments.
Sure enough, program verifies and runs fine if you fill in all optional args manually:
let services = locator.ConnectServer(".", "", "", "", "", "", 0, null)
let resultSet = services.ExecQuery("select * from Win32_Processor", "WQL", 16, null)Metadata
Metadata
Assignees
Labels
BugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.