I am building a WP8 app. On the initial page of my app (after login), I am using the GestureService to manipulate the screen and create the effect of a slideout menu. This is all fine, but the problem is the GestureService is activated whenever a swipe action is performed on ListPicker controls on ANY other page of the app, and throws an unhandled Object reference not set exception, like so:
I've done some digging and this appears to be a bug within the WP Toolkit. The behaviour is the same on both the WP8 emulator and the Nokia WP8 dev phone I am using. According to this thread, I can use the ManipulationDelta and ManipulationCompleted events to achieve the same thing the GestureListener does. So I commented out the GestureService code and added Manipulation events onto the grid on my main page. Low and behold, the problem has disappeared.
Here is the GestureService call (on my initial xaml page), which is now commented out:
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener DragDelta="GestureListener_OnDragDelta" DragCompleted="GestureListener_OnDragCompleted" />
</toolkit:GestureService.GestureListener>
The problem I am now facing is translating the code into the new format. Here is the Gesture code I am using (in VB):
If e.Direction = System.Windows.Controls.Orientation.Horizontal AndAlso e.HorizontalChange > 0 AndAlso Not _isSettingsOpen Then
Dim offset As Double = _feContainer.GetHorizontalOffset().Value + e.HorizontalChange
If offset > _dragDistanceToOpen Then
Me.OpenSettings()
Else
_feContainer.SetHorizontalOffset(offset)
End If
End If
If e.Direction = System.Windows.Controls.Orientation.Horizontal AndAlso e.HorizontalChange < 0 AndAlso _isSettingsOpen Then
Dim offsetContainer As Double = _feContainer.GetHorizontalOffset().Value + e.HorizontalChange
If offsetContainer < _dragDistanceToClose Then
Me.CloseSettings()
Else
_feContainer.SetHorizontalOffset(offsetContainer)
End If
End If
Not all the properties in the GestureListener are available/ comparable to the Manipulation events.
So am I best off soldiering on and attempting to recreate the effect within the Manipulation (if it's even possible), or does anyone know of a better way of doing this; i.e. a way of fixing or circumventing the bug to allow the GestureService to work...?
I already tried adding the GestureListener code and empty Try Catch statements to the pages with ListPicker controls on them, but it didn't solve the problem.
On another (related) note, I can avoid the error by simply setting the exception to Handled in App.Xaml. There is still an unhandled exception there, I'm just ignoring it. Is this behaviour likely to cause my app to be rejected from the store?
Any help is appreciated.
Ok, so low views and no replies to this for almost a week, so here's my temorary fix for anyone finding this via Google.
In the app.xaml, I simply stopped unhandled exceptions from displaying messages to the user:
Public Sub Application_UnhandledException(ByVal sender As Object, ByVal e As ApplicationUnhandledExceptionEventArgs) Handles Me.UnhandledException
' Show graphics profiling information while debugging.
If Diagnostics.Debugger.IsAttached Then
'There is a bug in the WP Toolkit which throws an unhandled exception when GestureListener events are used within the app,
'and a ListPicker control is swiped over. Altering this method ignores these exceptions.
'Diagnostics.Debugger.Break()
e.Handled = True
Else
e.Handled = True
'MessageBox.Show(e.ExceptionObject.Message & Environment.NewLine & e.ExceptionObject.StackTrace,
' "Error", MessageBoxButton.OK)
End If
End Sub
This is certainly not an ideal soultion, but is the only thing I could come up with in place of spending countless hours trying to circumvent the Toolkit bug. It's been a while since the last release, so hopefully it will be fixed in the next one. I'll edit this answer if that happens, or if this fix prevents the app from entering the store.
EDIT: App was submitted to the store successfully, so although not a perfect solution, it will do the job.
Related
I currently use Azure Mobile Services with Offline Sync and I it has been working fine. However I now have come to a problem I can't seem to debug. On the PullAsync it never returns, never goes to the Web API, it never errors, it just seems to be stuck somewhere and I don't know where.
IMobileServiceSyncTable<ResponseType> responseTypeTable = MobileService.GetSyncTable<ResponseType>();
await responseTypeTable.PullAsync(responseTypeTable.Where(c => c.CompanyId == companyId));
I use identical code elsewhere with a different type and it works well.
The only thing that happens is the Windows Phone emulator UI locks up, I can press buttons on the keyboard but the input or buttons are all frozen.
I get this on the Debug Output
The thread 0xb80 has exited with code 259 (0x103).
After a 5 seconds and that's about it. Breakpoints everywhere, nothing happening.
The method was in a Command (I'm using MVVMLight). When I call the function on the class initialization and just hold the value it works fine. There is obviously some bug that occurs when calling PullAsync on an event, in an async RelayCommand but getting the call out of there solves the issue.
I'll leave it at that unless anyone comes back with why it is actually happening. This is just a workaround at the moment.
I am trying to show an array of TPANELs to be used by the user as a menu system. It all seems to work fine but here's the issue.
If I always click the first item (i.e., TPanel), then I can click the other items as well. But if I start by clicking the last item, it shows the error "Access violation" AFTER it has shown the items.
The strange thing is that despite the error, the system does not crash. So I enabled the debugger (DBG). Now it crashes with the error as follows:
And once the program stops, I see the following in the history window of the debugger.
Please note that I'm not keen right now in fixing this error as I think this is trivial. But I want to be able to capture the error as it occurs and do something (for now I want to ignore it).
I'm using Ubuntu 12.04 with Lazarus 1.0.10.
The method I use must work on WINDOWS and LINUX.
Thanks in advance for any help!
Generally, to catch an exception, there's the try..except block. For sure your goal is not to catch an exception and ignore it, but find it in your code and fix the source of the problem. Of course, there might be situations, where the risk of an exception is high or expected so the use of a try..except block is necessary there. Those blocks of code we are enclosing this way:
procedure TForm1.Button1Click(Sender: TObject);
var
NotExistingPanel: TPanel;
begin
try
NotExistingPanel.Caption := ''; // <- this will raise an access violation
except
on E: Exception do
ShowMessage('An exception was raised: ' + E.Message);
end;
end;
Your problem will be somewhere in an OnMouseUp event handler of some of your controls and it's been caused by accessing the memory, that the CPU cannot physically address. This might happen e.g. when you access an object which has not been created, or already released, but there are also many different ways how to cause an access violation.
First, a big thank you to TLama for all the explanations and directions. I have to accept his answer as I've built mine based on that. I'm only posting this as an answer so that another person who's a beginner to Lazarus may find this useful. I'm not in anyway suggesting that this is the best thing to do, but this is what I want to do for now. That is, when a certain exception occurs, I want to trap it and deal with it.
Given that,
I am dynamically creating a set of TPanels to look like buttons
Each TPanel has assigned to it a mouseclick event
Let's assume that there are 10 such 'buttons' (actually TPanels).
The problem:
When I first click on the first button, I can then click on another one (eg: the 5th). But if I first click the 5th or anything else other than the first, the program throws the 'Access violation' error. Note however, that the program doe not crash despite the ugly warning about data corruption and stuff. So the user can simply click ok and continue. Strangely then, with subsequent clicks, this problem reduces! I know that's funny.
Now, as explained by TLama, the error occurs when the mouse is being released AFTER clicking a button.
But here's my problem... I don't have a mouseup event. That's part of Pascal.
So now, I want to ignore the mouseup event (at least for now). There MUST be a better way.
But there's another issue. I cannot ignore what I don't have! And I don't have a mouseup event. So I finally decided to capture this error at application level like this:
On the main form, I put this code:
procedure TfrmMainForm.CatchErr(Sender: TObject; e:exception);
begin
if e.Message <> 'Access violation' then ShowMessage('MOL: ' + e.Message);
end;
And then on form create, I put this:
Application.OnException:=#CatchErr;
And (for now) I can circumvent this issue.
Once again, as TLama has indicated, this is not good advice. Nonetheless, it is what I wanted to do.
Also what makes it harder is that the error is occuring in mouseup, which is in control.inc. And this is not my file. Rather it's part of Lazarus. I think it would be better if we had a way of telling Lazarus to delete that event for the TPanels in the code. I think it involves re-writing a derived class for it and I don't see how that's any good for me right now :)
Thanks again TLama!
I am creating a project for windows phone, and have made numerous backups over the past month, however when I ran the project this morning I received a Value does not fall within the excepted range error. I have researched this on the internet and all I could find was a few isolatedstorage saving issues which does not apply to me
It happens when I try to navigate to my homepage which is a panorama view, all my server calls are done without issues. And all my backups now also gives this issue. I have no idea where to start looking. the inner stack trace looks something like this:
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, Double d)
at System.Windows.DependencyObject.SetValue(DependencyProperty property, Double d)
at System.Windows.FrameworkElement.set_Width(Double value)
at Views.homePanorama.dashboard()
at Views.homePanorama.<OnNavigatedTo>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__0(Object state)"
Width of UI element was coming through as "infinite", just changed that and it worked
I'm trying to capture audio using WASAPI. My code is largely based on the ChatterBox VoIP sample app. I'm getting audio buffers, but they are all silent (flagged AUDCLNT_BUFFERFLAGS_SILENT).
I'm using Visual Studio Express 2012 for Windows Phone. Running on the emulator.
I had the exact same problem and managed to reproduce it in the ChatterBox sample app if I set Visual Studio to native debugging and at any point stepped through the code.
Also, closing the App without going through the "Stop" procedure and stopping the AudioClient will require you to restart the emulator/device before being able to capture audio data again.
It nearly drove me nuts before I figured out the before mentioned problems but I finally got it working.
So..
1. Be sure to NOT do native debugging
2. Always call IAudioClient->Stop(); before terminating the App.
3. Make sure you pass the correct parameters to IAudioClient->Initialize();
I've included a piece of code that works 100% of the time for me. I've left out error checking for clarity..
LPCWSTR pwstrDefaultCaptureDeviceId =
GetDefaultAudioCaptureId(AudioDeviceRole::Communications);
HRESULT hr = ActivateAudioInterface(pwstrDefaultCaptureDeviceId,
__uuidof(IAudioClient2), (void**)&m_pAudioClient);
hr = m_pAudioClient->GetMixFormat(&m_pwfx);
m_frameSizeInBytes = (m_pwfx->wBitsPerSample / 8) * m_pwfx->nChannels;
hr = m_pAudioClient->Initialize(AUDCLNT_SHAREMODE_SHARED,
AUDCLNT_STREAMFLAGS_NOPERSIST | AUDCLNT_STREAMFLAGS_EVENTCALLBACK,
latency * 10000, 0, m_pwfx, NULL);
hr = m_pAudioClient->SetEventHandle(m_hCaptureEvent);
hr = m_pAudioClient->GetService(__uuidof(IAudioCaptureClient),
(void**)&m_pCaptureClient);
And that's it.. Before calling this code I've started a worker thread that will listen to m_hCaptureEvent and call IAudioCaptureClient->GetBuffer(); whenever the capture event is triggered.
Of course using Microsoft.XNA.Audio.Microphone works fine to, but it's not always an option to reference the XNA framework.. :)
It was a really annoying problem which waste about 2 complete days of mine.My problem was solved by setting AudioClientProperties.eCatagory to AudioCategory_Communications instead of AudioCategory_Other.
After this long try and error period I am not sure that the problem won't repeat in the future because the API doesn't act very stable and every run may return a different result.
Edit:Yeah my guess was true.Restarting the wp emulator makes the buffer silent again.But changing the AudioClientProperties.eCatagory back to AudioCategory_Other again solve it.I still don't know what is wrong with it and what is the final solution.
Again I encounter the same problem and this time commenting (removing) the
properties.eCategory = AudioCategory_Communications;
solve the problem.
I can add my piece of advice for Windows Phone 8.1.
I made the following experiment.
Open capture device. Buffers are not silent.
Open render device with AudioDeviceRole::Communications. Buffers immediately go silent.
Close render device. Buffers are not silent.
Then I opened capture device with AudioDeviceRole::Communications and capture device works fine all the time.
For Windows 10 capture device works all the time, no matter if you open it with AudioDeviceRole::Communications or not.
I've had the same problem. It seems like you can either use only AudioCategory_Other or create an instance of VoipPhoneCall and use only AudioCategory_Communications.
So the solution in my case was to use AudioCategory_Communications and create an outgoing VoipPhoneCall. You should implement the background agents as in Chatterbox VoIP sample app for the VoipCallCoordinator to work .
So our corporate IT dept has determined that it is time to force SP1 on everyone's PC's.
Which means I need to get my Access 2003 ADE application working with the stupid ADO incompatibility problem.
I got the ADO portion to work by following KB2517589, but now several of my textboxes say #Name?.
These are bound to code, so, for example, the data field in the textbox is =CalcShippingAddr().
As a test, I replaced the code with the following:
Public Function CalcShippingAddr() As String
msgbox "Func Called"
CalcShippingAddr = "Test"
End Function
This works fine on my dev machine, but as soon as I make an ADE and send it to a PC without SP1, I get #Name? on the textbox. The msgbox nevers pops up.
Any ideas what might be happening?
This is a fault to do with the field calculation, I haven't seen it myself but have heard that clicking in to the relevant text box would then show the value although this is not a solution. I would always recommend using unbound forms as you can control step by step what your fields/objects are doing. As you already have a custom function to calculate the shipping address then it should be simple enough for you to add the code the the forms 'Open' or 'Load' event e.g.
Private Sub Form_Load()
textbox = CalcShippingAddr
End Sub