Exception thrown when navigating to a page with PDFTron - c#

I have to say this exception is really weird. In Windows 10, universal C#-XAML app. I have two monitors (the one from the laptop, and a 2nd screen) and a surface. I have a very simple app, with 2 pages, PageA and PageB. If I put the the PDFTron logic from the samples provided in PageA, it works in all 3 screens. If I put the PDFTron logic in PageB and use the laptop monitor WITHOUT having changed anything it breaks and throws a helpful "Unknow error!". If I use the same app in my 2nd monitor or the surface it works!!
I call
pdftron.PDFNet.Initialize();
In the App.xaml.cs and build PDFViewCtrl = new PDFViewCtrl(); in the UI thread in the constructor of PageB.
any help please?
PDFTron sample
Be aware that the sample works in certain conditions as a Surface. But in a 3840x2160 Dell laptop screen puting the logic in PageB it does not work.

First, there is most likely an actually useful exception message, but you have to retrieve it from PDFNet using the exception you got. See this blog post. This is a limitation of how Microsoft implemented their latest mobile technology (COM API boundary).
As for the error, most likely this has already been fixed. Windows 10 introduced pixel densities that are not recognized in the Windows.Graphics.Display.DisplayProperties.ResolutionScale enumerator from Windows 8.1.
This is why certain devices would fail, and others would not, using older versions of PDFNet.
Please contact PDFNet support to get the latest version.

Related

D3DImage loses device on WPF application

I am developing a WPF application that displays a directX scene.
The code that generates the directX scene is not mine and I have no access to it. (Its not a public code I can references you guys to)
Everything was working fine until I had to format my PC and installed Windows 10. (Before that I had Windows 7)
Now I can't see the DirectX scene and the RenderCapability.Tier on WPF returns 0.
The code works on other computers (Windows 7 and Windows 10) so I'm guessing its something to do with my computer but nothing changed hardware-wise..
I tried reinstalling DirectX and I tried reinstalling the display driver (tried several different drivers) but nothing works I still get RenderCapability.Tier = 0.
The code that displays the DirectX scene is mostly taken from this link:
https://www.codeproject.com/Articles/28526/Introduction-to-D3DImage
I couldn't find any help around the internet that actually solved my problem.
Any help would be appreciated.
Thanks!
Run dxdiag.exe, Display tab, ensure it prints "D3D acceleration: enabled" and "No problems found".
Also the linked sample has a bug, on some systems you must use a query to wait for completion of rendering before passing the texture to WPF. Otherwise WPF may show incomplete renderings, or none at all. If you render with DX9, see this, you need D3DQUERYTYPE_EVENT query, issue D3DISSUE_END after you've done rendering, then sleep until GetData returns S_OK.

UWP ListView/GridView DragItems results to Catastrophic Failure

We are developing an UWP App that needs the ability to drag items from one GridView to another.
While testing this functionality we encountered multiple catastrophic failures 0x80000FFFF.
After almost 2 days of research we were not able to find a solution for our problem.
We found out that these failures happen, when there's an ItemTemplate set for the GridView the item is dragged from.
Even trying out the official drag-drop sample provided by Microsoft “XamlDragAndDrop”,(https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlDragAndDrop), when you drag the items in Scenario1 from the source ListView to the target ListView (~30-50) times, you will encounter the failure as well.
Has someone else encountered this problem before? We would be super grateful for any advice!
Our developing machines run Windows 10 Enterprise, Version 1803, OS build 17134.285.
Opened an issue on the official GitHub repo.
https://github.com/Microsoft/Windows-universal-samples/issues/977
I recorded a small video of the sample crashing.
https://1drv.ms/v/s!AiZ-jksNqbXLi9kZPPfSeGmQr_YeHg
We managed the get the native trace here.
When running in release mode its crashing earlier, and also when the redraw function is turned on in the display heatmap section.
According to the Raymond Chen this is a plataform specific problem which was solved in the Windows 10 May 2019 update.
So the solution is: update your version of the windows to the latest.
Find out here how you can update it.
Windows 10 May 2019 (What's new)
Windows 10 May 2019 changelog

Is it possible to use both windows phone cameras at the same time?

While trying to use both cameras for windows phone app i am not able to display both cameras at the same time..
one of them freeze when the other is working. i used the same code that has been given for reference here:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202956(v=vs.105).aspx
any suggestion or code that shows an example of it?
This scenario is not supported by the API. Opening an additional instance of the camera will close the previous one.
However, to behave nicely with battery usage, you should explicitly .Dispose the device as soon as you are done with it (instead of relying on the auto-close behavior).
(Note that some hardware actually shares resources between the FFC and the BFC, so even if the API allowed for it, it is still unlikely to work with the current version of the OS).
refer this link
http://social.msdn.microsoft.com/Forums/wpapps/en-US/cdefd4cb-94f8-4d98-a4b4-7671606815c6/can-i-use-frontcamera-and-primary-camera-at-the-same-time
but in the phone like S4 it is possible
refer this link
http://www.wpxbox.com/dual-shot-camera-apps-wp/

Windows Phone 8 app randomly crashes with error code -2147220717 (0x80040313)

I am currently developing a stopwatch and timer app in C#/XAML for Windows Phone 8. While using my app on my phone, I found that it randomly closed out/crashed and that too at different points of use (i.e. I wasn't doing the same thing each time it closed out). While debugging, I found that my app closed out with the following error code in my output window:
"The program '[1100] TaskHost.exe' has exited with code -2147220717 (0x80040313)."
I am very confused as to why this is happening. I tried creating an entirely new solution and moving my code over and I've still been getting the same issue. I have tried using the app on multiple different devices, and the same thing happens (even in the Emulator). Sometimes the app crashes after 5 minutes of use, sometimes it crashes after 30 minutes of use, it's very unpredictable which makes it very hard to find the root of the problem. My app uses the XNA Framework to play an audio sound and the Coding4Fun Toolkit for a TimeSpanPicker control, and besides that there isn't much else that's particularly notable about my app. I have tried removing the playing of the audio file and removing references to the XNA Framework, and the problem persists.
Any ideas on what the problem could be?
Thanks in advance!
That what David said +
are you sure that the phone is not running out of memory?
Edit try a windows phone analysis(Alt +F1 | Debug->Start windows phone application analysis)
If you're using XNA framework in WP project you can get a crash when updating the UI thread.
You might need to run it through a Dispatcher?
Dispatcher.BeginInvoke(() => {
// Call your update UI methods here..
});
You might also find this post helpful:
http://social.msdn.microsoft.com/Forums/wpapps/en-US/c2751845-cb70-4301-aa1a-796fa1bb8e8c/the-program-241435222-taskhostexe-managed-has-exited-with-code-0-0x0

Capture visual output of a DirectX application - even in background?

I need to capture the visual output (like a screenshot) of a DirectX window.
Currently, I use this approach.
But, when the window is in background, it captures whatever is in front of it.
I see that DirectX windows render even when minimized or in background, so this should be possible.
But, how? (It also needs to be fast, and it needs to work on Windows XP too, unfortunately...)
Edit: I am very busy these days... Don't worry, I'll put the bounty back if it expires.
To capture Direct3D windows that are in the background (or moved off screen), I believe you have the following options:
Inject and hook Direct3D within the target application via the link you have already posted or this more up-to-date example (EasyHook can be difficult to get setup but it does work really well) - you can always ask for help about getting it working. I have used that technique for capturing in a number of games without issues (most recently for an ambilight-clone project). The problem with this approach is your concern about game protection causing bans, however FRAPs also uses hooking to achieve this, so perhaps your concerns are exaggerated? I guess gamers being banned for a screen shot is an expensive way of finding out.
For windowed applications on Vista/Win 7 - you could inject and hook the DWM and make your capture requests through its shared surface. I have had this working on Vista, but have not finished getting it working on Windows 7, here is an example of it working for Windows 7 http://www.youtube.com/watch?v=G75WKeXqXkc. The main problem with this approach is the use of undocumented API's which could mean your application breaks without any warning upon a windows patch release - also you would have to redo the technique for each new major Windows flavour. This also does not address your need to capture in Windows XP.
Also within the DWM, there is a thumbnail API. This has limitations depending on what your trying to do. There is some information on this API along with other DWM API's here http://blogs.msdn.com/b/greg_schechter/archive/2006/09/14/753605.aspx
There are other techniques for intercepting the Direct3D calls without using EasyHook, such as substituting the various DLL's with wrappers. You will find various other game hooking/interception techniques here: http://www.gamedeception.net/
Simply bring the Direct3D application to the foreground (which I guess is undesirable in your situation) - this wouldn't work for off-screen windows unless you also move the window.
Unfortunately the only solution for Windows XP that I can think of is intercepting the Direct3D API in some form.
Just a clarification on Direct3D rendering while minimised. During my fairly limited testing on this matter I have found this to be application dependant; it is generally not recommended that rendering take place while the application is minimized (also this reference), it does continue to render while in the background however.
UPDATED: provided additional link to more up-to-date injection example for point 1.
A quick google and i found this Code Project which relates to Windows XP. I dont know if you can apply this knowledge to Windows Vista and 7??
http://www.codeproject.com/Articles/5051/Various-methods-for-capturing-the-screen
EDIT:
I found this article as well:
http://www.codeproject.com/Articles/20651/Capturing-Minimized-Window-A-Kid-s-Trick
This links off from Justins blog post here from the comments. It seems he was working on this with someone (i see thats your link about).
http://spazzarama.com/2009/02/07/screencapture-with-direct3d/
The code that you linked to (from spazzarama), which you said you were using in your project, captures the front buffer of your DirectX device. Have you tried capturing the back buffer instead? Going from the code on your linked site, you would change line 90 from
device.GetFrontBufferData(0, surface);
to
Surface backbuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);
SurfaceLoader.Save("Screenshot.bmp", ImageFileFormat.Bmp, backbuffer);
This would also involve removing lines 96-98 in your linked example. The backbuffer might be generated without the obstructing window.
EDIT
Nevermind all of that. I just realized that your linked sample code is using the window handle to define a region of the screen, and not actually doing anything with the DirectX window. Your sample code won't work around the obstruction because your region is already drawn with the other window in front of it by the time you access it.
Your best bet to salvage the application is probably to bring the DirectX window to the top of the screen before running the code to capture the image. You can use the Wind32API BringWindowToTop function to do that (http://msdn.microsoft.com/en-us/library/ms632673%28VS.85%29.aspx).

Categories

Resources