"GattDeviceServicesResult" can not be found - visual-studio

I am trying to create client side app using C# for BluetoothLE in VisualStudio 2015 on Windows-10 laptop.
I have problem using Windows.Devices.Bluetooth.GenericAttributeProfile, the issue is my code has compile error saying GattDeviceServicesResult can not be found.
-> I have added package UwpDesktop 10.0.14393.3 by Valdimir Postel... (before installing this even "using Wndows.Devices.Bluetooth" was not working)
-> Then I added SDK, windows Kit that was recommended by VisualStudio when I tried to open one of the example (So I accept the recommendation to build that project and VS installed packages of around 9GB)
-> now I can use some of the Bluetooth api's I can scan and connect to a BLE device, but I can not use classes to deal with services and characteristics because GattDeviceServicesResult and GattCharacteristicsResult types are not found. Although these are mentioned on MSDN website
-> searching in forums I came to know I need to add one more reference System.Runtime.WindowsRuntime.dll, I browsed to proper folder through add reference utility of VS, I am trying to add this and it does nothing, after I select the dll and click 'Add' just nothing happens. (Add reference is not adding this dll).
Just for example if I select some other dll and try to add, that works fine!
Could somebody please help me with this,
using Windows.Devices.Bluetooth;
using Windows.Devices.Bluetooth.GenericAttributeProfile;
using Windows.Devices.Bluetooth.Advertisement;
Int16 uuid_count = 0;
BluetoothLEAdvertisement[] ble_adv = new BluetoothLEAdvertisement[5];
BluetoothLEAdvertisementReceivedEventArgs[] ble_received_adv = new BluetoothLEAdvertisementReceivedEventArgs[5];
BluetoothLEDevice bluetooth_LE_Device;
GattDeviceServicesResult result_service;// This line does not compile
//Error: CS0246 the type name 'GattDeviceServicesResult ' could not be found
// I am adding reference to "System.Runtime.WindowsRuntime" as mentioned in some solutions
// the reference does not seems to be added at first when I click add button, but I can see the reference dll being mentioned in solution explorer (assuming it's been added)
// using this to scan available devices
private void scann_ble()
{
var watcher = new BluetoothLEAdvertisementWatcher();
watcher.Received += Watcher_Received;
watcher.AdvertisementFilter.Advertisement.ServiceUuids.Clear();
watcher.Start();
while (true)
{
Thread.Sleep(10000);
break;
}
watcher.Stop();
}
// receiver event to collect addresses of available devices
private void Watcher_Received(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args)
{
bool update_adv = true;
Int16 i = 0;
if(uuid_count < 5)
{
if (uuid_count > 0)
{
while (i < uuid_count)
{
if (ble_received_adv[i].BluetoothAddress == args.BluetoothAddress)
update_adv = false;
i++;
}
}
if(update_adv != false)
ble_received_adv[uuid_count++] = args;
}
}
// now connecting and checking available services
// as per "https://learn.microsoft.com/en-us/windows/uwp/devices-sensors/gatt-client"
private async void BLE_connect_button_Click(object sender, EventArgs e)
{
int i = 0;
i = BLE_device_grid_view.CurrentCell.RowIndex; // getting index from item selected in gridView
bluetooth_LE_Device = await BluetoothLEDevice.FromBluetoothAddressAsync(ble_received_adv[i].BluetoothAddress);
// Connection works fine, I can see it on my peripheral device
//get services - This is not working
result_service = bluetooth_LE_Device.GetGattServicesAsync();
if (result_service.Status == await GattCommunicationStatus.Success)
{
var services = result_service.Services;
// ...
}
}
I am using UwpDesktop package.

I had the same problem. My problem was solved after I changed the reference to windows.winmd from C:\Program Files (x86)\Windows Kits\10\UnionMetadata\windows.winmd to C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17763.0\windows.winmd.
I'm using BLE 4.0 in a WinForm application and I'm working with Visual Studio 2017.
It is very likely that the directory 10.0.17763.0 doesn't exist on every computer, but you may look what versions of windows.winmd exists on your computer.

Related

ItemEvent in SAP B1 SDK with a SAP form created in Visual Studio 2015

I truly really need your help.
I want to be able to deal with a Click on an Item on my Form which has been created in Visual Studio 2015
this is my Main Methode :
static void Main(string[] args)
{
try
{
Application oApp = null;
if (args.Length < 1)
{
oApp = new Application();
}
else
{
oApp = new Application(args[0]);
}
Menu MyMenu = new Menu();
MyMenu.AddMenuItems();
oApp.RegisterMenuEventHandler(MyMenu.SBO_Application_MenuEvent);
Application.SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent);
oApp.Run();
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
and this code is automatically generated by Visual studio when i creat a new SAP B1 Project.
now i want to add an ItemEvent to handle some klick events on some Forms.
when i add this to the code :
Application.SBO_Application.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(SBO_Application_ItemEvent);
und of course the Methode SBO_Application_ItemEvent then i got a compiler error in this code line that an object reference is requiered for non-static fields...
what did i miss?
I just want to be able to do something when the User clicks on the Grid in my Form.
A Method to add a click event to a grid on a custom user form,
using Visual Studio and SAP BUSINESS ONE STUDIO:
Open the .b1f file in visual studio designer.
an example form:
Click on the Grid you wish to add the event for and navigate to the properties window
Click the lightening symbol to see the events
Double click the space next to your Desired Event
visual studio should then add the code for the event as required, something similar to the below should appear in code:
private void docRowGrid_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg
pVal, ref bool BubbleEvent)
{
}

Get IntelliJ IDEA/Android Studio Opened Project Folder with ElectronJS Application

I'm trying to make an application which can communicate with android studio, but IntelliJ plugin SDK is not giving me enough option to build the features that I want, so I'm thinking about trying a different approach to create a separate windows application for functionality but as application needs to know the project folder that is currently opened with android studio, I'm trying to search the same from 4-5 days but haven't found anything helpful if this is possible to read folder location of open project in android studio with a different application please help me, if there is some way that building plugin that can send location to external application please tell me.
Thank you
Just manage to achieve the same with WPF, still don't know if electron can do it or not
if someone is finding the answer for this here's my approach, not the best and final but just figured out how I can do it make sure you will optimize code before implementation
private void Button_Click(object sender, RoutedEventArgs e)
{
var allProcesses = Process.GetProcesses();
String data = "";
for(int a =0; a < allProcesses.Length; a++)
{
Console.WriteLine(data);
if (allProcesses[a].MainWindowTitle.Contains("Android"))
{
Console.WriteLine(data);
data = allProcesses[a].MainWindowTitle;
if(data.Contains("["))
{
data = data.Substring(data.IndexOf("["));
data= data.Substring(0, data.IndexOf("]") + 1);
data = data.Replace("[", "");
data = data.Replace("]", "");
Console.WriteLine(data);
MessageBox.Show(data);
return;
}
else
{
MessageBox.Show("Project is not open in Android Studio");
return;
}
}
}
MessageBox.Show("Android Studio Not Running");
return;
}

TFS 2015 server side plugin deployment (using VS 2013)

I am using Visual Studio 2013 and wrote a TFS 2015 server side plugin. Created a local TFS 2015 environment and checked-in files to test it, I found that it works as expected.
I want to deploy my plugin: Following the instructions on internet I changed my plugin code's output path to : ..............\Program Files\Microsoft Team Foundation Server 14.0\Application Tier\Web Services\bin\Plugins. So, my plugin.dll and plugin.pdb files are in this location.
After this step; I am stuck, I tried to go to Team Explorer -> Settings -> Source Control(under Team Project)-> Check-in Policy -> Add but I wasn't able to find my file.
I need help to deploy my plug-in.
Your server side plugin will not show up in the Check-in Policy Add dialog. It will however execute when the Check In button is hit for every client that connects to the TFS server where the plugin is deployed. Based on the plugin code it will either approve or deny the check-in. In case it denies the check-in you can supply a message for the user about what to fix.
Here is an example that just rejects if the code reviewer is claimed to be GOD. You can also check the comment section and look for required elements if you like.
using System;
using System.Diagnostics;
using System.Linq;
using Microsoft.TeamFoundation.Build.Server;
using Microsoft.TeamFoundation.Common;
using Microsoft.TeamFoundation.Framework.Server;
using Microsoft.TeamFoundation.WorkItemTracking.Server;
using System.Collections.Generic;
using Microsoft.TeamFoundation.VersionControl.Server;
namespace TFSPlugin
{
public class FittingSoftwarePlugin : ISubscriber
{
public string Name { get { return this.GetType().Name; } }
public SubscriberPriority Priority { get { return SubscriberPriority.Normal; } }
public Type[] SubscribedTypes() { return new[] { typeof(CheckinNotification) }; }
public EventNotificationStatus ProcessEvent(IVssRequestContext requestContext, NotificationType notificationType, object notificationEventArgs,
out int statusCode, out string statusMessage, out ExceptionPropertyCollection properties)
{
statusCode = 0;
properties = null;
statusMessage = String.Empty;
try
{
var checkinNotificationArgs = notificationEventArgs as CheckinNotification;
if (notificationType == NotificationType.DecisionPoint && checkinNotificationArgs != null)
{
var codeReviewer = checkinNotificationArgs.CheckinNote.Values.FirstOrDefault(v => v.Name.Equals("Code Reviewer"));
if (codeReviewer!=null && codeReviewer.Value.Equals("GOD", StringComparison.InvariantCultureIgnoreCase))
{
statusMessage = "GOD cannot be used as a code reviewer as he is not trustworthy!";
return EventNotificationStatus.ActionDenied;
}
}
}
catch (Exception e)
{
// Log error
}
return EventNotificationStatus.ActionPermitted;
}
}
}
The check-in policy has to be deployed to the local machines of anyone who is going to use it.
Check-in policies are not the same thing as server-side plugins.

How to work out TFS uri and location for currently loaded solution projects in Visual Studio Extension

I am trying to work out how, in my Visual Studio Extension, I can work out which of the currently loaded projects are in TFS and then the TFS server uri and location for each of these projects.
I would like to be able to do something like this:
foreach (EnvDTE.Project project in dte.Solution.Projects)
{
if (project.IsInTFS) {
var uri = project.TFSUri; // http://tfsserver:8080/tfs
var location = project.TFSLocation; // $\TeamProject\Project
}
}
Can anyone help me?
Thank you.
You can use the SourceControl2 interface to accomplish this in the following way:
foreach (Project project in dte.Solution.Projects)
{
if (dte.SourceControl.IsItemUnderSCC(project.FileName))
{
var bindings = project.GetSourceControlBindings();
var uri = bindings.ServerName;
var location = bindings.ServerBinding;
// your logic goes here
}
}
Where GetSourceControlBindings is an extension method:
public static SourceControlBindings GetSourceControlBindings(this Project project)
{
SourceControl2 sourceControl = (SourceControl2)project.DTE.SourceControl;
return sourceControl.GetBindings(project.FullName);
}
Note: you will have to a add reference to the EnvDTE80.dll assembly.
If you're interested exclusively in TFS source control, then you should add one more condition:
if (bindings.ProviderName == "{4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}")
Where that magic guid specifies the Team Foundation Source Control Provider.

filesavedialog.showdialog hangs in windows 7

I am making custom setup project for msi.
There is very strange problem in one of the windows while installation goes. there is a show dialog call on click of a button. the installer is running fine on XP but on win 7 installer goes to not-responding and never comes back.
Below is the piece of code i am using for showing the dialog:
private void btnSetFileLocationWS_Click(object sender, EventArgs e)
{
saveFileDialog1.Title = "Set WS Log File Path";
saveFileDialog1.DefaultExt = "log";
saveFileDialog1.Filter = "Log files (*.log)|*.log|Text files (*.txt)|*.txt";
saveFileDialog1.FilterIndex = 0;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
txtFilePathWS.Text = saveFileDialog1.FileName;
}
btnNextWSLogging.Enabled = EnableDisabledNextWSLoggingButton();
}
Anybody??
The MSI is running under an account which doesn't have access to the desktop. This thread suggests a possible workaround, setting AutoUpgradeEnabled to false.
To fix it properly, you need to set msidbCustomActionTypeNoImpersonate in your MSI, for which you will need to use the Orca MSI editor.

Resources