I'm trying to create an app that will eventually read my tablet inclinometer and control the aircraft using that but in order to do so I have to compile as a Universal App in windows. When I run the code it fails to open the connection and returns error 12. Im using the C# SDK class file and VS2013 for windows. When I run similar code using C# in a console windows program it works fine so am I missing a fundamental difference that exsists between how regular .net for window will interact versus Universal Apps .net? Thank you. Im using Windows 8.1 on a Surface Pro 3
This is the code for the main program window
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace FSMotionControl
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
// Call FSUIPC
Fsuipc f = new Fsuipc();
// Error code result
int dwResult = -1;
int token = 0;
int ElevatorPosition = 0;
public MainPage()
{
this.InitializeComponent();
}
private void ConnectButton_Click(object sender, RoutedEventArgs e)
{
// initialize fsuipc
f.FSUIPC_Initialization();
// open FSUIPC
DisplaySurfacePitch.Text = f.FSUIPC_Open(0, ref dwResult).ToString() + "," +dwResult;
f.FSUIPC_Close();
}
private void ReadData()
{
}
private void GetDataButton_Click(object sender, RoutedEventArgs e)
{
ReadData();
}
}
}
This is the code from the program that did work
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SourceFSUIPCTest
{
class Program
{
static void Main(string[] args)
{
// Create Object
FsuipcSdk.Fsuipc f = new FsuipcSdk.Fsuipc();
// Result Variable
int dwResult = 0;
bool result;
int token = 0;
// Initialize
f.FSUIPC_Initialization();
// Open
Console.WriteLine("Open Connection: " + f.FSUIPC_Open(0, ref dwResult).ToString());
// Read
Console.WriteLine("Read Variable: " + f.FSUIPC_Read(0x0BB2, 2, ref token, ref dwResult));
// Process
Console.WriteLine("Process Connection: " + f.FSUIPC_Process(ref dwResult));
// Get Variable
Console.WriteLine("Get Variable: " + f.FSUIPC_Get(ref token, ref dwResult));
// Show Results
Console.WriteLine("Results: " + dwResult);
f.FSUIPC_Close();
Console.ReadLine();
}
}
}