I have a problem with FilePicker in Windows Phone 8.1
I'm set up a FilePicker object like that:
FileOpenPicker filePicker = new FileOpenPicker();
filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
filePicker.ViewMode = PickerViewMode.List;
filePicker.FileTypeFilter.Add(".xml");
filePicker.FileTypeFilter.Add(".txt");
filePicker.PickSingleFileAndContinue();
view.Activated += View_Activated;
Before that I'm setting up a view object:
view = CoreApplication.GetCurrentView();
File Picker is invoked properly, I'm selecting a file, after that I got unhandled exception in App class.
"Error in line 1 position 229. Element 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:anyType' contains data of the 'http://schemas.datacontract.org/2004/07/SQLite:Task' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'Task' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer."
View_Activated method is never invoked.
What can be wrong?
You shouldn't be using the activated for the page. The activation process should start in the App.xaml.cs
Check this link for SilverLight: https://msdn.microsoft.com/en-us/library/windows/apps/dn642086(v=vs.105).aspx
Check this link for normal: https://www.jayway.com/2014/04/16/windows-phone-8-1-for-developers-contracts/
You are not showing the code that generates the error. Based on the error you should show us the code that handles the selected file. The error says that the XML could not be parsed. So the file is selected, just not parsed correctly
I think the timeline is: FilePicker => Parse => View
Since the error is in the Parsing, the view is never activated
If you need help with the parsing error you should ask a new question with the parsing code in it.
Related
I'm trying to use Quartz in a new Project with windows10 and .net4. I've added "Windows\system32\quartz.dll" to may Project and I can play audio files without a problem.
The problem arises when using the "Owner" property in order to show video, I get a conversión error in runtime. This is the sample code:
Panel panel = new Panel();
FilgraphManagerClass graphManager = new QuartzTypeLib.FilgraphManagerClass();
graphManager.Owner = panel.Handle.ToInt32();
graphManager.RenderFile(#"c:\temp\simple.mp4");
This is the error message:
System.InvalidCastException: Specified Cast is not valid
I am using POS tagger for a project and it works successfully when it reads the tagger file from my computer (project's folder).
But I need to upload the tagger file first and read the tagger file from a URL.
To do so, I have uploaded the POS tagger file and I am trying to read the tagger file by giving the URL to the constructor of the MaxentTagger method: (my code is in C# and I have overridden the MaxentTagger class so it's constructor looks like this:
public Tagger ()
{
java.io.ByteArrayInputStream inputStream = new java.io.ByteArrayInputStream(System.IO.File.ReadAllBytes(#"C:\models\english-left3words-distsim.tagger"));
base.readModelAndInit(null, new java.io.DataInputStream(inputStream), false);
}
However I get this error when I run my code:
"An unhandled exception of type 'java.lang.RuntimeException' occurred in stanford-postagger.dll
Additional information: java.io.FileNotFoundException: Could not find a part of the path 'C:\u\nlp\data\pos_tags_are_useless\egw4-reut.512.clusters'."
Does anybody know why this happens and how I can resolve this? I appreciate any sort of help very much!
This error comes from the program trying to load a file which gives the distributional similarity mapping from words to clusters. It's trying to get it from the location that is specified in the training properties file (and you naturally don't have a file at that location). This happened because you don't have a properly initialized TaggerConfig object at the time readModelAndInit() is called. The way it gets initialized is unintuitive (was badly architected), but you're only encountering this because you're trying to use a non-public API.
Why can't you just use the public API as follows?
MaxentTagger base = new MaxentTagger("http://my.url.com/models/english-left3words-distsim.tagger");
Has anyone used a custom dictionary into WPF 4.0?
I am having an issue getting the Custom Dictionaries to work in my WPF project.
I have been trying to follow the example msdn offers but have made no progress.
http://msdn.microsoft.com/en-us/library/system.windows.controls.spellcheck.customdictionaries.aspx
glossary.Definition.SpellCheck.IsEnabled = true;
Uri uri = new Uri(#"pack://application:,,,/Prog.Proj;component/dictionary.lex");
glossary.Definition.SpellCheck.CustomDictionaries.Add(uri);
Due to the nature of my work sub folders have been renamed.
My .lex file is set as a resource file.
EDIT
I am able to get this to work only if I set it up in a separate button event after the page has already loaded. It seems that something is preventing the 'Speller' property of CustomDictionariesSources to load until after a postback? If anyone knows anything on this please post your insight.
FINAL EDIT
My desired text box was within a grid which had a enabled disabled flag that was set deep within the code. Another link commented below talks towards this point. Another issue faced is my page is rendered by parts depending on user selection. To create consistent behavior I am loading my spellcheck as a last step each time my textbox would be loaded/re-loaded.
I created a context menut extension to allow users to either take a suggestion or add to a custom dictionary. I am then submitting my custom dictionary into the registry based on current user. I found this direction to be very user friendly and easy to implement. To retrieve the items back I need to create a temporary file, pack the uri for that file then after loading the custom dictionary I deleted the file.
If this helps you implement your custom spell check or if you have questions please let me know!
The URI in your example is a Disk path to a folder on your C: drive. If you want to access the lex file embedded as a resource within your application, you need to use a "Pack URI."
Refer to the article which you already linked to, for an example of a Pack URI being used to load a custom dictionary:
private void button1_Click(object sender, RoutedEventArgs e)
{
IList dictionaries = SpellCheck.GetCustomDictionaries(richTextBox1);
// customwords2.lex is included as a resource file
dictionaries.Add(new Uri(#"pack://application:,,,/WPFCustomDictionary;component/customwords2.lex"));
}
In my case the problem was fixed by changing the Build Action on my custom.lex file from None to Resource
I am using C# to read the Windows Event Log and I want to select/filter entries from it. The problem is that the information displayed in the Event Viewer is not always matching the data I get from c#.
for example:
EventViewer "Source": "User Profile Service"
Using the EventLogEntry class: Property "Source": "Microsoft-Windows-User Profiles Service"
Using the EventLogReader class: Property "ProviderName": "Microsoft-Windows-User Profiles Service"
Using WMI: "SourceName": "Microsoft-Windows-User Profiles Service"
I need to be able to read the exact information displayed in the EventViewer, where can I get this information from?
Reading the EventLog message...
When reading the EventLog message using the EventLogEntry class I occasionally get the following string:
The description for Event ID "xxx" in Source "xxx" cannot be found
Again, this does not match the message displayed in the EventViewer... I have tried using the EventLogReader.FormatDescription() method and it gives me the right (the same as the EventViewer) message, BUT for some entries it simply returns null, while the EventLogEntry.Message contains the proper text.
What is the correct way to retrieve the message of the event to get the same message as the one displayed in the EventViewer?
var eventLog = new EventLog("logName", "machine", "source");
foreach(var entry in eventLog.Entries)
{
}
That is a fairly basic swag at interacting with the log. If you need deeper filtering that source, you can write a LINQ query on the Entries. As shown here.
As for the error, one common reason is not having the proper access to the events and/or registry on the box in question. Since you can see data in question in EventViewer, I am suspecting a permissions error is a good possibility.
It appears that the "Source" string shown in the "Source" column in the Event Viewer is abbreviated. Also it seems that when you try to create an EventLog in C# only the logtype matters e.g. "Application", "System" etc. Once you create an EventLog it will contain all the entries for that logtype regardless of what you specified a source.
In order to get an event based on "Source" you want to iterate over the entries and filter only the entries for that "Source". Just keep in mind that the actual source name is not the same as what you see in the Event Viewer. For example for Source "Winlogon" the actual source name would be: "Microsoft-Windows-Winlogon" and so on.
I am into my sixth hour battling with what hopefully should have a simple solution, so I thought I would post here.
I have an feature with a feature receiver whose sole purpose is to activate a deployed list definition feature and then create an instance of that new list definition.
The list definition feature, called "Custom Access List", is scoped at web.
So my feature receiver activates this list definition feature, having GUID "1E503BDA-803B-4a1a-A042-019FA1A70C4C":
...
string featureGuid = "1E503BDA-803B-4a1a-A042-019FA1A70C4C"; // my 'Custom try
{
SPFeatureCollection featureCollection = web.Features;
featureCollection.Add(new Guid(featureGUID), true); // activat the 'Custom Access List' feature
}
catch (Exception e)
{
// log exception
}
This code executes fine, and the list definition feature is activated, and the new list definition appears in the "Create" site menu option in the UI.
However, this is where my issue starts. The next line of my feature receiver code then tries to create an instance of this newly-available list:
SPListTemplate listTemplate = web.ListTemplates["Custom Access List"]; // exception! Value does not fall within the expected range
web.Lists.Add("My new custom access list","", listTemplate);
But the line SPListTemplate listTemplate = web.ListTemplates["Custom Access List"]; throws an exception with "Value does not fall within the expected range." - the list template, despite being deployed, visible and available in the UI under the "Create" site menu action, cannot be found in the receiver code.
Debugging the code confirms that the web.ListTemplates SPListTemplateCollection does not contain a entry for this new "Custom Access List", despite the UI suggesting otherwise.
And here is the weird thing. An exception is thrown, but if I then re-run the code i.e. reactivate the feature in the UI, to re-execute that feature receiver, the list template is then found -
SPListTemplate listTemplate = web.ListTemplates["Custom Access List"]; // found this time. It sees it the second time around
web.Lists.Add("My new custom access list","", listTemplate); // works fine
So, in a nutshell - initially, after activating a feature which, through receiver code, activates a list definition feature, that list definition is not visible until after a "postback" or some form of "SPWeb refresh". Then it is visible.
Am I missing something here? A call of web.Update() here:
try
{
SPFeatureCollection featureCollection = web.Features;
featureCollection.Add(new Guid(featureGUID), true); // true to force activation
web.Update();
}
...
does nothing. Is there some way I can "refresh" the SPWeb object so that the new list template can be seen and used?
The workaround I have found, for now, is to add the "Custom Access List" list template feature as an activation dependency in the "parent" feature receiver itself, and to make the "Custom Access List" list template feature hidden. That way, to my knowledge, the custom list definition feature is forcibly activated and I find that web.ListTemplates["Custom Access List"]; is found.
But I would much rather the former approach work - to activate, in my receiver code, the list definition feature and then to find it so that an instance of the list can then be created.
Andrew,
The problem is to do with internal async events and the timing of the activity. As you say if you go away and come back it works - i.e. the async event has completed. You are treating the featureCollection.Add as a synchronus method.
What you really should be doing if you need a template and a list instance created at the same time is using the XML framework for this.
Add a to your feature that has the list template, or alternatively add a new feature for the list instance and reference the FeatureID of the list template.
Andrew
You need to call EnsureListsData on the SPListCollection that you just updated.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistcollection.ensurelistsdata.aspx
Seems that the list template is not yet created. You can try to do a loop and wait to be created
using(SPWeb web = site.OpenWeb())
{
SPListTemplate listTemplate = null;
while (listTemplate == null)
{
Thread.Sleep(1000);
try
{
listTemplate = web.ListTemplates["Custom Access List"];
if (listTemplate != null)
{
// here your code
web.Lists.Add("My new custom access list", "", listTemplate);
}
}
catch
{
web = site.OpenWeb();
}
}
}