.net-4.0

System.Transactions.Diagnostics.DiagnosticTrace throwing TypeInitializationException

五迷三道 提交于 2019-12-18 09:14:49
问题 Seems related to Strange exception coming out of OdbcConnection.Open() but I'm not sure. I recently switched over to Win8 and hadn't run this app since. I'm using VS2012, but the projects have not been upgraded. The dump of the exception looks like this: Unhandled Exception: System.TypeInitializationException: The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to

How to force a user to take a suggested entry into a ComboBox?

强颜欢笑 提交于 2019-12-18 09:08:13
问题 I want a user to select a value from a ComboBox. Entries have to be suggested at user's text input. Do I have to use events to enforce a System.Windows.Forms.ComboBox to contain a value from its own DataSource ? Example: Entries have to be suggested to the user... If I write "CO", the combo should suggest "CONGO" and "COLOMBIA", but only one of those values should be entered by the user. The user should not introduce "COfdfgdfg" or any random string. Thanks! 回答1: You have to use combobox

DataGridComboBoxColumn cell not displaying selected item text?

和自甴很熟 提交于 2019-12-18 08:56:44
问题 I was wondering how you get the DataGridComboBoxColumn to display the selected item text when it is not in editing mode? And also is it possible to make it so the combo box in edit mode displays the selected item text initially? Here is my XAML: <DataGridComboBoxColumn Header="Formatter" SelectedItemBinding="{Binding Path=Format}"> <DataGridComboBoxColumn.ElementStyle> <Style TargetType=""> <Setter Property="Text" Value="{Binding Path=FormatView.Name}" /> </Style> </DataGridComboBoxColumn

How to get ticks from QueryPerformanceCounter in C#?

女生的网名这么多〃 提交于 2019-12-18 08:33:31
问题 I need to replace Stopwatch to avoid using getters for its properties. I am going to implement it using QueryPerformanceCounter. I only need ticks nothing else. Can anyone provide a code snipet please, to get correct ticks (1/10000 of ms) or any other small but stable value. Please note my server sets clock granularity down to 0.5 ms (not sure if it affects QueryPerformanceCounter) but just for you to know. Please also note - I do not need a timer. I only need to measure time intervals

XMLSerialize an ObservableCollection

守給你的承諾、 提交于 2019-12-18 08:15:10
问题 I am having a problem in the xml serialization of observable collection. Here is what I am serializing: public enum Status { Pending, Active, Completed, Cancelled } public abstract class Entity : INotifyPropertyChanged { ... } public class UserStory : Entity { public uint StoryID { get; set; } public Status Status { get; set; } ... public ObservableCollection<Task> Tasks { get; set; } } public class Task : Entity { public uint TaskID { get; set; } ... } Here is how I serialize it: public

XMLSerialize an ObservableCollection

爱⌒轻易说出口 提交于 2019-12-18 08:14:36
问题 I am having a problem in the xml serialization of observable collection. Here is what I am serializing: public enum Status { Pending, Active, Completed, Cancelled } public abstract class Entity : INotifyPropertyChanged { ... } public class UserStory : Entity { public uint StoryID { get; set; } public Status Status { get; set; } ... public ObservableCollection<Task> Tasks { get; set; } } public class Task : Entity { public uint TaskID { get; set; } ... } Here is how I serialize it: public

Updating fields of values in a ConcurrentDictionary

谁说我不能喝 提交于 2019-12-18 07:36:14
问题 I am trying to update entries in a ConcurrentDictionary something like this: class Class1 { public int Counter { get; set; } } class Test { private ConcurrentDictionary<int, Class1> dict = new ConcurrentDictionary<int, Class1>(); public void TestIt() { foreach (var foo in dict) { foo.Value.Counter = foo.Value.Counter + 1; // Simplified example } } } Essentially I need to iterate over the dictionary and update a field on each Value. I understand from the documentation that I need to avoid

Updating fields of values in a ConcurrentDictionary

余生长醉 提交于 2019-12-18 07:36:01
问题 I am trying to update entries in a ConcurrentDictionary something like this: class Class1 { public int Counter { get; set; } } class Test { private ConcurrentDictionary<int, Class1> dict = new ConcurrentDictionary<int, Class1>(); public void TestIt() { foreach (var foo in dict) { foo.Value.Counter = foo.Value.Counter + 1; // Simplified example } } } Essentially I need to iterate over the dictionary and update a field on each Value. I understand from the documentation that I need to avoid

Entity Framework and DbContext - Object Tracking

杀马特。学长 韩版系。学妹 提交于 2019-12-18 07:14:10
问题 I am a bit confused on the usage of DbContext in Entity Framework. Here's the scenario I'm confused about. I use a linq query from the dbcontext to get data. Something like: List<Transactions> transactions = DefaultContext.Transactions.ToList(); Then I update a column in one of the transactions returned in that query directly in the database. Then I call again: List<Transactions> transactions = DefaultContext.Transactions.ToList(); When the list returns back this time, it doesn't reflect the

Is there a way to tell which Tasks are currently running in Task Parallel Library?

邮差的信 提交于 2019-12-18 06:49:43
问题 I can't see a way to see which tasks are running. There is the Task.Current property, but what if there are multiple tasks running? Is there a way to get this kind of information? Alternately, is there a built in way to get notified when a task starts or completes? 回答1: Hey Mike, there is no public way of accessing the list of pending tasks in TPL. The mechanism that makes it available for the debugger relies on the fact that all threads will be frozen at enumeration time, therefore it can't