UWP app release version hangs on splash screen? - c#

Debug versions (86, 64, ARM) all work fine, release versions build fine, but when they run all that happens is my app window opens and remains blank (white background). The only errors I see in the output are a whole bunch of:
...PDB file was not present when IL code was compiled to native.
I'm not sure if the missing .pdb files are the culprit - pretty sure they're not, cause they're just for debugging purposes right?
Anyways, this is the first UWP app I have tried to get ready for the Windows Store, and not completely sure if I have to do anything special like sign it to test release versions on my own computer?
Edit 1: Thank you #Alan for your suggestions, manually uninstalling the app sometimes gets me past the blank window to load the app bar, but then I am getting these errors when it doesn't hang on the splash screen:
Debugger Error 1,
Debugger Error 2
I have done nothing special to the splash screen, loaded all my visual assets using the built in tools in manifest, and have not modified App.xaml.cs from its default. Here is my Mainpage.cs:
using Sublist.Classes;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace Sublist
{
public sealed partial class MainPage : Page
{
const string TAG = "MainPage: ";
// for loading and saving user data and settings
public static DataHandler dataHandler;
public static MasterList<Entry> masterList;
//public static int listViewSelectedIndex = -1;
public MainPage()
{
this.InitializeComponent();
dataHandler = new DataHandler(this);
masterList = new MasterList<Entry>();
// load user data
if (dataHandler.userDataList != null)
masterList = dataHandler.userDataList;
masterList.UpdateListView(this);
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
dataHandler.LoadUserSettings();
}
private void AppBarAdd_Click(object sender, RoutedEventArgs e)
{
masterList.AddRow(this);
}
private void AppBarRemove_Click(object sender, RoutedEventArgs e)
{
if (!(mainListView.SelectedIndex < 0))
{
masterList.RemoveRow(this);
}
}
private void AppBarMoveDown_Click(object sender, RoutedEventArgs e)
{
}
private void AppBarMoveUp_Click(object sender, RoutedEventArgs e)
{
}
private void AppBarIndent_Click(object sender, RoutedEventArgs e)
{
// indent the row control if currently selected index is a list view item
if (-1 < mainListView.SelectedIndex && mainListView.SelectedIndex < mainListView.Items.Count)
{
// but don't allow more than one indent past above row's indent level
RowControl rc = (RowControl)mainListView.Items[mainListView.SelectedIndex];
int indexMinus1 = mainListView.SelectedIndex - 1;
if (-1 < indexMinus1 && rc.indentProp <= masterList[indexMinus1].indent)
{
rc.indentProp++;
}
}
// then update list view
masterList.UpdateListView(this);
}
private void AppBarUnindent_Click(object sender, RoutedEventArgs e)
{
// unindent the row control if currently selected index is a list view item
if (-1 < mainListView.SelectedIndex && mainListView.SelectedIndex < mainListView.Items.Count)
{
// but don't allow unindenting off left side of page
RowControl rc = (RowControl)mainListView.Items[mainListView.SelectedIndex];
if (rc.indentProp > 0)
{
rc.indentProp--;
}
}
// then update list view
masterList.UpdateListView(this);
}
public void AppBarShowCompl_Click(object sender, RoutedEventArgs e)
{
dataHandler.SaveUserSettings();
masterList.UpdateListView(this);
}
public void AppBarMarkAsCompleted_Click(object sender, RoutedEventArgs e)
{
// toggle hidden state of active entry
if (-1 < mainListView.SelectedIndex && mainListView.SelectedIndex < masterList.Count)
{
masterList[mainListView.SelectedIndex].completed = (masterList[mainListView.SelectedIndex].completed) ? false : true;
masterList.UpdateListView(this);
}
}
}
}
I have added the FileService and SettingsService classes from the opensource Template10 to the project.
The build setting "compile with .NET Native tool chain" was unchecked, I've tried deploying with it checked/unchecked for both debug/release versions, and now the debug version also often hangs on the splash screen? With it checked, I get a whole bunch of these errors as well:
'Sublist.exe' (Win32): Loaded 'C:\Windows\System32\biwinrt.dll'. Skipped loading symbols. Module is native, and native debugging is currently disabled.
I've tried downloading the server symbols with no success...

I found the hang happens at the following line in GetIfFileExitsAsync.
retval = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync(key);
I made the following change in you code and it should work now.
In DataHandler's constructor, use Task.Run to initialize the userDataList.
public DataHandler(MainPage mp)
{
mainPage = mp;
settingsHelper = new SettingsHelper();
fileHelper = new FileHelper();
LoadUserSettings();
Task.Run(() =>
{
userDataList = LoadUserData();
});
Task.WaitAll();
}
I am still not sure why the .net native compile will make this issue, but will try to simplify the project and report it in MS internal channel.

Related

how to make sure that function only fires once (RawInputEventArg)

I'm currently working on a method that gives the user the possibility to add a handscanner to a dicitionary in order to scan some barcodes with it. (before i started the scanners were hardcoded in the dictionary). my colleague from which i got this project, implemented the rawinput_dll in order to get all of the necessary data from the barcode scanner. The method to get the data is shown below:
private void OnKeyPressed(object sender, RawInputEventArg e)
{
if (!Scanners.ContainsKey(e.KeyPressEvent.DeviceName))
{
return;
}
else if (Scanners.ContainsKey(e.KeyPressEvent.DeviceName))
{
if (e.KeyPressEvent.KeyPressState == "MAKE")
{
return;
}
if (e.KeyPressEvent.VKeyName != "\n")
{
scanNumber += e.KeyPressEvent.VKeyName;
return;
}
devID = e.KeyPressEvent.DeviceName;
Debug.Print(devID);
Aufrufen(scanNumber);
scanNumber = "";
}
}
Basically there are three classes in this program (FrmMenu, FrmSettings and a Class for the Scanner itself). If you want to add settings for the program you click on a button that opens up a new instance of FrmSettings
private void BtnSettings_Click(object sender, EventArgs e)
{
FrmSettings settings = new FrmSettings();
settings.ShowDialog();
settings.BtnSave_Click(sender, e);
settings.Dispose();
}
In this form there 2 buttons where you can choose if you want to add a scanner that scans even numbers or one that scans odd ones. If you press one of the buttons you need to scan a barcode in order to get the information (VID of Scanner) which is used as key to add the new scanner to the dictionary.
private void OnKeyPressed(object sender, RawInputEventArg e)
{
if (newScanner == true)
{
devIDnew = e.KeyPressEvent.DeviceName;
scannerAnlegen(devIDnew);
}
}
scannerAnlegen is the methode that adds the scanner to the dict.
public void scannerAnlegen(string devIDnew)
{
if(EvenOrOdd == true)
{
Scanner ger = new Scanner("dev3", "even");
FrmMenu.Scanners.Add(devIDnew, ger);
newScanner = false;
}
else
{
Scanner ug = new Scanner("dev4", "odd");
FrmMenu.Scanners.Add(devIDnew, ug);
newScanner = false;
}
}
my problem rn is, that it seems like i cant get out of this OneKeyPressed method of the Settings class. the logic of the OneKeyPressed method of the FrmMenu Class is that it can only proceed if the scanner is in the dictionary. Adding the scanner seems to work because when i debug and try to add one scanner the second time it throws and exception and says something like "element with this key already added". But why does this code doesn't continue then?

Office VSTO AddIn stops responding after invoking Regex several times

I am writing a VSTO C# code that would copy the content of active projects in Visual Basic editor in any Office application and process it following some rules. The AddIn adds a button to the VBE toolbar and an event for a click.
When debugging, it works fine the first couple of times (between 8 and 12) I click the button but then it just stops responding to the clicks. Restarting the application does not help, but repeat debugging does (again, for the first 8 - 12 clicks).
I experimented with the code and found that it behaves this way whenever the code uses Regex, even something rather basic. Any ideas what may be going wrong?
This piece of code is for the illustration only. All it is supposed to do is to produce a message box "OK" after it applies Regex to each code module content. And so it does - for the first 8 to 12 times. After that, the button clicks produce no response whatsoever.
No error messages are shown, except when it is building the solution, among many lines it shows Exception thrown: 'System.Deployment.Application.DeploymentException' in System.Deployment.dll, which does not seem to affect the program during the first clicks.
using Office = Microsoft.Office.Core;
using VBA = Microsoft.Vbe.Interop;
using System.Text.RegularExpressions;
namespace CodeControl
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
AddButton();
}
public void AddButton()
{
Office.CommandBar cbr = Globals.ThisAddIn.Application.VBE.CommandBars["Edit"];
Office.CommandBarButton button = cbr.Controls.Add(Type: 1, Temporary: true).Control;
button.FaceId = 10;
button.Visible = true;
Globals.ThisAddIn.Application.VBE.Events.CommandBarEvents[button].Click +=
new VBA._dispCommandBarControlEvents_ClickEventHandler(DoWork);
}
void DoWork(object CommandBarControl, ref bool handled, ref bool CancelDefault)
{
foreach (VBA.VBComponent component in Globals.ThisAddIn.Application.VBE.ActiveVBProject.VBComponents)
{
VBA.CodeModule module = component.CodeModule;
if (module.CountOfLines < 4)
continue;
string text = module.Lines[1, module.CountOfLines];
foreach (string lineText in Regex.Split(text, #"(?:\r\n|\n|\r)"))
Console.WriteLine(lineText);
System.Windows.Forms.MessageBox.Show(module.Name);
}
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e){}
#region VSTO generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}

Bring up keyboard in C# for Windows 8 tablet

I am working on a UI for a Windows 8.1 tablet, which has a full version of Windows on it. There is a keyboard icon at the bottom of windows 8.1, which brings up a keyboard, and I want that to automatically trigger after clicking a numericUpDown box. I then would also like it to close after leaving or clicking off of the box.
I am basically just trying to focus it when it is clicked, but this does not seem to bring up the keyboard. Also, note, I am setting some other numericUpDown box to the one in the function so I can call it outside, so I hope that doesn't make it difficult to see what's going on, let me know if you need any clarifications and thank you for the help. Here is what I have so far:
copiedNUD.Click += CopiedNudPass_Focus;
//copy copied nud
CopiedNudPass = copiedNUD;
...
void CopiedNudPass_Focus(object sender, EventArgs e)
{
CopiedNudPass.Focus();
}
I tried looking around a bit, but some of the solutions weren't too clear to me. I really appreciate the help. Thank you.
I figured it out. Here is my code specifically for a tablet with window 8 or higher:
copiedNUD.Click += CopiedNudPass_Focus;
//copy copied nud
CopiedNudPass = copiedNUD;
...
//Launch keyboard
void CopiedNudPass_Focus(object sender, EventArgs e)
{
Version win8version = new Version(6, 2, 9200, 0);
if (Environment.OSVersion.Version >= win8version)
{
string progFiles = #"C:\Program Files\Common Files\Microsoft Shared\ink";
string keyboardPath = Path.Combine(progFiles, "TabTip.exe");
Process.Start(keyboardPath);
}
}
//Close keyboard
void CopiedNudPass_LostFocus(object sender, EventArgs e)
{
Version win8version = new Version(6, 2, 9200, 0);
if (Environment.OSVersion.Version >= win8version)
{
Process[] oskProcessArray = Process.GetProcessesByName("TabTip");
foreach (Process onscreenProcess in oskProcessArray)
{
onscreenProcess.Kill();
}
Refresh();
}
}
My only problem right now is that when the keyboard closes my main form in the background gets cut off and I tried to refresh it using Refresh(); , but that did not seem to work :(.
Here is a better closing function:
After killing the process for TabletKeyboard(TabTip.exe) application doesn't bring back to its original size in wpf
Here is my new close code:
//Close keyboard
void CopiedNudPass_LostFocus(object sender, EventArgs e)
{
Version win8version = new Version(6, 2, 9200, 0);
if (Environment.OSVersion.Version >= win8version)
{
uint WM_SYSCOMMAND = 274;
uint SC_CLOSE = 61536;
IntPtr KeyboardWnd = FindWindow("IPTip_Main_Window", null);
PostMessage(KeyboardWnd.ToInt32(), WM_SYSCOMMAND, (int)SC_CLOSE, 0);
}
}
I also had to add a reference to WindowsBase and add external functions to the project. The steps and additional code are in the url I linked to in this post. Here's how you add a reference for WindowsBase to get using System.Windows.Interop; to work:
Right click on project
Highlight Add and click Reference
Ensure you have Framework selected under Assemblies
Scroll down and check in "WindowsBase" and hit ok
Add using System.Windows.Interop; at the top of your code and your done
This worked for me (in Java & eclipse RCP)
text.addFocusListener(new FocusListener()
{
#Override
public void focusLost(FocusEvent arg0)
{
LogUtil.logInfo("Closing OSK");
try
{
if(Settings.getBoolean(Settings.OSK_USETABTIP)) {
Runtime.getRuntime().exec("cmd /c taskkill /IM tabtip.exe");
} else {
Runtime.getRuntime().exec("cmd /c taskkill /IM osk.exe");
}
}
catch (IOException e)
{
LogUtil.logError(e.toString());
}
}
#Override
public void focusGained(FocusEvent arg0)
{
try
{
String sysroot = System.getenv("SystemRoot");
if(Settings.getBoolean(Settings.OSK_USETABTIP)) {
LogUtil.logInfo("Opening TabTip");
ProcessBuilder pb = new ProcessBuilder("C:/pathtotabtip/tabtip.exe");
pb.start();
} else {
LogUtil.logInfo("Opening OSK");
ProcessBuilder pb = new ProcessBuilder(sysroot + "/system32/osk.exe");
pb.start();
}
}
catch (Exception e)
{
LogUtil.logError(e.toString());
}
}
});

windowless wpf application example?

Any advice or links or sample application (for VS2010) re how to develop a "windowless" WPF application?
That is the ones that look quite modern and don't seem to have the historical window chrome around the edges - they seem to have rounded edges etc...
I wrote a project that did exactly what you are talking about, we used the following project from Microsoft,
http://code.msdn.microsoft.com/WPFShell
Initially I tried writing it myself by turning off the chrome, not a good idea unless you don't want to be able to drag your window around in the standard windows method.
Just remove StartupUri and in the Application Startup method dont load a window:
public partial class App
{
public static bool IsTrue ;
public App()
{
Startup += AppStartup;
}
public void DoWork()
{
for (int i = 0; i < 10; i++)
{
Thread.Sleep(1000);
Trace.WriteLine("blah");
}
IsTrue = false;
}
void AppStartup(object sender, StartupEventArgs e)
{
IsTrue = true;
new Thread(DoWork).Start();
while (IsTrue)
{ }
Current.Shutdown();
}
}
}

Application settings do not allways save

I have a bit of a Heisenbug. I have a list of what was recently searched for sometimes it will save the history some times it does not. When I attach the debugger and step through StartFind() it works every time.
public Form1()
{
oldClinicsBindingSource.DataSource = ContractFlowTool.Properties.Settings.Default.RecentClinics;
}
private void StartFind()
{
(...)
if (oldClinicsBindingSource.Contains(newClinic))
oldClinicsBindingSource.Remove(newClinic);
oldClinicsBindingSource.Insert(0, newClinic);
oldClinicsBindingSource.EndEdit();
while (ContractFlowTool.Properties.Settings.Default.NumberOfClinicsToRemember < oldClinicsBindingSource.Count)
{
oldClinicsBindingSource.RemoveAt(oldClinicsBindingSource.Count - 1);
}
ContractFlowTool.Properties.Settings.Default.Save();
(..)
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{ //Breakpoint on this line
ContractFlowTool.Properties.Settings.Default.Save();
}
//In Settings.Designer.cs
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::System.Collections.ArrayList RecentClinics {
get {
return ((global::System.Collections.ArrayList)(this["RecentClinics"]));
}
set {
this["RecentClinics"] = value;
}
}
If I put a breakpoint on the { before the save inside Form1_FormClosing then hit continue (I don't even step over) it saves correctly. If the breakpoint is not there it does not save.
The program does use background workers in other parts but they not being run in my test case case.
Any help would be greatly appreciated.
Commenting out the Save() inside StartFind() appears to have fixed it.
I am still curious why it was happening. Do binding sources use internal threading?

Categories

Resources