Make it possible to call WinRT APIs from LinqPad
As explained here: http://www.hanselman.com/blog/HowToCallWinRTAPIsInWindows8FromCDesktopApplicationsWinRTDiagram.aspx
I often use LinqPad to test small pieces of code, but I can't do it when this code depends on WinRT APIs...
-
Kurt commented
The way with the windows.winmd does not work.
I got the following message:The type 'System.ComponentModel.EditorBrowsableAttribute' is available in both 'c: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ System.dll' and in 'c: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework \. NETcore \ v4.5.1 \ System.Runtime.dll 'available.
It look like an conflict between this Assemblies.
My Script:
------------<Query Kind="Statements">
<Reference><ProgramFilesX86>\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5.1\System.Core.dll</Reference>
<Reference><ProgramFilesX86>\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5.1\System.dll</Reference>
<Reference><ProgramFilesX86>\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5.1\System.Runtime.dll</Reference>
<Reference><ProgramFilesX86>\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5.1\System.Runtime.Extensions.dll</Reference>
<Reference><ProgramFilesX86>\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5.1\System.Runtime.InteropServices.dll</Reference>
<Reference><ProgramFilesX86>\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5.1\System.Runtime.InteropServices.WindowsRuntime.dll</Reference>
<Reference><ProgramFilesX86>\Windows Kits\8.1\References\CommonConfiguration\Neutral\Windows.winmd</Reference>
<Namespace>Windows.Devices.Sensors</Namespace>
</Query>LightSensor light = LightSensor.GetDefault();
Windows.Devices.Sensors.
if (light != null)
{
uint minReportInterval = light.MinimumReportInterval;
uint reportInterval = minReportInterval > 16 ? minReportInterval : 16;
light.ReportInterval = reportInterval;light.ReadingChanged += (s, a) =>
{
String.Format("There was light! {0}", a.Reading.IlluminanceInLux).Dump();
};}