I'm trying to show a route from point-to-point on the bing-maps (testing on real device). I've entered 2 waypoints (GeoCoordinate) and I'm trying to get the route via the Windows PhoneToolKit using the await query.GetRouteAsync(). Unfortunately, I'm getting an unknown error:
The result of the async call:
'e.Result' threw an exception of type 'System.Reflection.TargetInvocationException'
The inner exception:
Exception from HRESULT: 0x8004231C
I've checked the MSDN website and noticed that this errorcode is not listed in the errorlist...
The related code is below. I've used the exact same code as in the sample set of the Windows Phone Toolkit, but removed the things which has nothing to do with getting the route:
private async void BtnShowRoute_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
try
{
RouteQuery query = new RouteQuery();
List<GeoCoordinate> wayPoints = new List<GeoCoordinate>();
wayPoints.Add(new GeoCoordinate(47.23449, -121.172447));
wayPoints.Add(new GeoCoordinate(47.062638, -120.691795));
query.Waypoints = wayPoints;
Route route = await query.GetRouteAsync();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
throw;
}
}
I have no idea what is going wrong here. Does anyone else experienced this issue? If so, did you resolve it? And how?
Note: I'm running Windows Phone 8.1. Dev Preview
This happens when the underlying service call times out before completing the query. Hopefully this will be fixed in next version , but for now you can use following code:
private async void BtnShowRoute_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
RouteQuery query = new RouteQuery();
List<GeoCoordinate> wayPoints = new List<GeoCoordinate>();
wayPoints.Add(new GeoCoordinate(47.23449, -121.172447));
wayPoints.Add(new GeoCoordinate(47.062638, -120.691795));
query.Waypoints = wayPoints;
query .QueryCompleted += geoQ_QueryCompleted;
query.GetRouteAsync();
}
private void geoQ_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e)
{
try
{
Route myRoute = e.Result;
}
catch (TargetInvocationException)
{
Thread.Sleep(1000); // waiting for completing the query
geoQ_QueryCompleted(sender, e);
}
}
Related
I'm testing Hangfire to use it in my application
the task is running as expected
now i make the task fail with try catch block the exception not showed in Failed tasks in dashboard
then i used log4net it works fine logging the exception to a text file but still not visible in hangfire dashboard what is the problem
Framework 4.7 - WebForms - log4net : 2.0.13.0 , hangfire.core : 1.1.1.0
installed by : Install-Package Hangfire_net40
Code
1- Startup.cs
public void Configuration(IAppBuilder app)
{
app.UseHangfire(config =>
{
config.UseSqlServerStorage("Hangfire_Blog");
config.UseServer();
});
}
2- web.Config
3- Global.ascx
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private BackgroundJobServer _backgroundJobServer;
protected void Application_Start(object sender, EventArgs e)
{
log4net.Config.XmlConfigurator.Configure();
JobStorage.Current = new SqlServerStorage("Hangfire_Blog");
using (var connection = JobStorage.Current.GetConnection())
{
foreach (var recurringJob in connection.GetRecurringJobs())
{
RecurringJob.RemoveIfExists(recurringJob.Id);
}
}
//create an instance of BackgroundJobServer
_backgroundJobServer = new BackgroundJobServer();
//add your recurring job
RecurringJob.AddOrUpdate(() => Code(), "*/2 * * * *");
// RecurringJob. AddOrUpdate(() => Actualizacoes(), Cron.m();
}
[AutomaticRetry(Attempts = 10)]
public void Code()
{
try
{
string s = "";
int n = int.Parse(s);
}
catch (Exception ex)
{
log.Error(ex.Message);
}
}
for any one facing the same problem #madreflection Comment was a part of the answer
first Hangfire will not catch the exception in try catch block either remove try catch
or in the catch log the error the throw it to be catched by hangfire
but most important
[AutomaticRetry(Attempts = 10)]
that tag means that hangfire will not consider the task fail until it tries to execute 10 times and all the 10 times fail
hope some one find it useful
Thanks
I am trying to made windows phone application with offline routing. I have found that It is possible by using Bing API.
I have registered and got the key, but I can't find, how can I use the key.
I am using following code:
private async void Button_Click(object sender, RoutedEventArgs e)
{
RouteQuery query = new RouteQuery();
List<GeoCoordinate> wayPoints = new List<GeoCoordinate>();
wayPoints.Add(new GeoCoordinate(47.23449, -121.172447));
wayPoints.Add(new GeoCoordinate(47.062638, -120.691795));
query.Waypoints = wayPoints;
query.QueryCompleted += geoQ_QueryCompleted;
query.QueryAsync();
}
private void geoQ_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e)
{
try
{
Route myRoute = e.Result;
MessageBox.Show("Completed");
}
catch (TargetInvocationException)
{
/// Unauthorized access exception 0x8004231C
Thread.Sleep(1000); // waiting for completing the query
geoQ_QueryCompleted(sender, e);
}
}
But I am getting Unauthorized access exception 0x8004231C.
I would like to ask you, how can I fix it?
You don't need the key to show offline map. If you have map downloaded on your device, then offline routing should work. You can see the sample to get more details.
Following is the quote from msdn sample,
However, mapping services also work without Internet connectivity when maps are downloaded for offline use.
I am developing software for landline phones and full-duplex voice modems using C# and TAPI 3 library. Call answering is working fine but call hangup is throwing an exception. I did a lot of search to find solution but I could not. Following are the errors:
Exception is occurring on calling method ici.ReleaseUserUserInfo();
{"This implementation doesn't take advises (Exception from HRESULT:
0x80040003 (OLE_E_ADVISENOTSUPPORTED))"} System.Exception
{System.Runtime.InteropServices.COMException}"
My goal is to save recorded calls. One interesting thing is that if, before call hangup, I close the application, it successfully saves the recorded call.
My code:
private void BtnAnswer_Click(object sender, EventArgs e)
{
IEnumCall ec = ia[line].EnumerateCalls();
uint arg = 0;
ITCallInfo ici;
ITTerminal recordTerminal;//NY test record
try
{
ec.Next(1, out ici, ref arg);
ITBasicCallControl2 bc = (TAPI3Lib.ITBasicCallControl2)ici;
recordTerminal = bc.RequestTerminal(TapiConstants.CLSID_String_FileRecordingTerminal,
TapiConstants.TAPIMEDIATYPE_MULTITRACK,
TAPI3Lib.TERMINAL_DIRECTION.TD_RENDER);
ITMediaControl mediacontrol = (ITMediaControl)recordTerminal;
ITMediaRecord mediarecord = (ITMediaRecord)recordTerminal;
mediarecord.FileName = "a.wav";
bc.SelectTerminalOnCall(recordTerminal);
bc.Answer();
mediacontrol.Start();
}
catch (Exception exp)
{
MessageBox.Show("There may not be any calls to answer! \n\n" + exp.ToString(), "TAPI3");
}
}
private void BtnHang_Click(object sender, EventArgs e)
{
IEnumCall ec = ia[line].EnumerateCalls();
uint arg = 0;
ITCallInfo ici;
try
{
ec.Next(1, out ici, ref arg);
ITBasicCallControl bc = (ITBasicCallControl)ici;
bc.Disconnect(DISCONNECT_CODE.DC_NORMAL);
ici.ReleaseUserUserInfo();
}
catch (Exception exp)
{
MessageBox.Show("No call to disconnect!", "TAPI3");
}
}
I believe that the error code you're seeing is actually TAPI_E_NOTSUPPORTED!
According to the MSDN documentation for ITCallInfo::ReleaseUserUserInfo:
The ReleaseUserUserInfo method informs the service provider that the application has processed the user-user information obtained from the ITCallInfo::GetCallInfoBuffer method, called with the CIB_USERUSERINFO member of CALLINFO_BUFFER, and subsequently received user-user information can now be written.
Hwoever, User-user information is specific to the ISDN Q.931 standard and not all service providers support it.
Unless you specifically want to exchange this information between your client and the remote end, it is probably sufficient to simply delete the offending line of code, as it is otherwise both unused and unsupported.
I just started playing with bluetooth communication on WP8.
I found a example here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207007(v=vs.105).aspx
But as soon as Peerfinder.Start() is hit, i get this error:
A first chance exception of type 'System.UnauthorizedAccessException' occurred in PhoneApp3.DLL
public MainPage()
{
InitializeComponent();
PeerFinder.Start();
}
async private void AppToApp_Click(object sender, RoutedEventArgs e)
{
// PeerFinder.Start() is used to advertise our presence so that peers can find us.
// It must always be called before FindAllPeersAsync.
var peers = await PeerFinder.FindAllPeersAsync();
if (peers.Count == 0)
{
Debug.WriteLine("Peer not found.");
}
else
{
Debug.WriteLine(peers.Count + " peers found");
}
}
Make sure you've added the capabilities ID_CAP_PROXIMITY and ID_CAP_NETWORKING to your application manifest.
I'm not very sure but for some reasons I can't use a BlueToothListener that receives string information.
I tried following this example, and it doesn't seems to work.
Code Snippet
private Guid Rffcomm = BluetoothService.RFCommProtocol;
private void btnConnect_Click(object sender, EventArgs e)
{
if (comboBox1.SelectedValue != null)
{
try
{
BluetoothClient btSender = null;
btSender = new BluetoothClient();
btSender.Connect(new BluetoothEndPoint(selectedAddr, Rffcomm));
MessageBox.Show("1");
StreamWriter swSender = new StreamWriter(btSender.GetStream());
swSender.WriteLine("Test 1");
//swSender.Flush();
// swSender.Close(); // At first it worked, but after some tries, IOsocket exception keeps popping out.
}
catch (Exception se)
{
MessageBox.Show(se.Message);
}
}
}
void listening()
{
try
{
bool run = true;
BluetoothListener btl = new BluetoothListener(Rffcomm);
btl.Start();
while(run)
{
BluetoothClient btReceiver = btl.AcceptBluetoothClient();
StreamReader srReceiver = new StreamReader(btReceiver.GetStream());
String writeInfo = srReceiver.ReadLine();
test = writeInfo;
srReceiver.Close();
}
MessageBox.Show(test);
}
catch(Exception ex) { MessageBox.Show(ex.Message); }
}
private void button1_Click(object sender, EventArgs e)
{
// Start a new thread to deal with an incoming Bluetooth connection
Thread t = new Thread(new ThreadStart(listening));
t.Start();
}
So as I wrote to you in another forum: :-)
Yeh, using BluetoothService.RFCommProtocol will have the client connect to a random RfComm-based service
Note "random"!!!
You need to not use "RFCommProtocol" as your Service Class Id, but do as the user guide says:
Bluetooth applications/services are identified and registered by UUID (Universally Unique Id), a 128-bit value that is represented by the System.Guid class in .NET. If one is creating a new service then a new UUID should be created at design time and entered into the two applications’ source code, a new value can be created either by calling Guid.NewValue or using the guidgen.exe Windows SDK program — in Visual Studio access it with menu item Tools, “Create GUID”.
And use that Guid as the Service Class Id value in both server (in its constructor) and client (Connect method). Do that and see what happens.