.net

How to offer application settings to an end user of your library, at design time, in .net, winforms

I have a library with with a set of classes with a common property that i'd like an end user to be able to override without overriding all the classes. The important thing is, the property has to be overriden at design time. Lets say, for simplicity's sake, that it's the background colour of a UITypeEditor. I can do this by putting the...

What is the proper PInvoke signature for a function that takes var args?

There is a native function: int sqlite3_config(int, ...); I would like to PInvoke to this function. Currently, I have this declaration: [DllImport("sqlite3", EntryPoint = "sqlite3_config")] public static extern Result Config (ConfigOption option); (Result and ConfigOption are enums of the form enum Result : int { ... }.) I am actu...

FluentMigrator Failed Migrations Don't Rollback?

I just began experimenting with FluentMigrator. I noticed that failed migrations are not being rolled back. Has this just not been implemented yet? This seems rather bad because it leaves the database in a broken state. For example, the migration below will obviously fail when it tries to add Table1 for a second time (I'm just doing th...

How do you make a column an auto incremented primary key in the various .NET ORMs?

How do you make a column (let's call it OrderID) an auto incremented primary key in the various .NET ORMs? Linq To SQL [Column(Name="OrderID", IsPrimaryKey=true, IsDbGenerated=true)] Entity Framework [EdmScalarProperty(EntityKeyProperty=true, IsNullable=false)] (Not possible to specify autoinc?) NHibernate [Id(Name = "OrderId"...

CollectionViewSource Use Question

I am trying to do a basic use of CollectionViewSource and I must be missing something because it is just not working. Here is my XAML: <Window.Resources> <CollectionViewSource Source="{Binding loc:MainVM.Instance.MapItems}" x:Key="MapCV"> <CollectionViewSource.GroupDescriptions> <PropertyGroupDescription PropertyName="So...

What would be the best way to validate XML?

Hi I been looking at XML Serialization for C# and it looks interesting. I was reading this tutorial http://www.switchonthecode.com/tutorials/csharp-tutorial-xml-serialization and of course you can de serialize it back to a list of objects. So I am wondering would it be better to de serialize it back to to a list of objects and then go...

OwnerDraw ComboBox is not "styled" anymore

Hello, I've created a custom combobox with DrawMode = OwnerDrawVariable. Everything is fine, except it doesn't use visual styles anymore in DropDownList mode, i.e. it looks like old combobox. How can I make it drawn using visual styles? I checked VisualStyleElement class but haven't found there anything that could help me. Does it mean ...

I can never predict XMLReader behavior. Any tips on understanding?

It seems every time I use an XMLReader, I end up with a bunch of trial and error trying to figure out what I'm about to read versus what I'm reading versus what I just read. I always figure it out in the end, but I still, after using it numerous times, don't seem to have a firm grasp of what an XMLReader is actually doing when I call th...

WPF - Get the ListBox row object from a button that is on the DataTemplate

I have a list box with a data template. The template has a button on it. When the button is clicked I want to do some logic with the object that is each row (in this cased an object called WorkItemTypeMappings). In the OnClick how can I go from the Button (object sender) to the object that is row that the button is on? Here is the XA...

Multiple User Controls referencing the same object.

Hi, I have created a UserControl in C# that I have put a DataGridView on. When I have only one instance of this UserControl in a WinForms project, it works like intended. When I have two instances of this UserControl in a WinForms project, the second instance of my UserControl behaves the way it should but the first one does not. It se...

how to get the current opened applications in windows using c++ or vb.net?

i need the current opened applications(those that appear in the task bar) and NOT the currently running processes. thanks ...

LINQ - problem with mapping an association

Hello, I've a table Role associated in 1-many relation with table User in my database. I've created LINQ mapping classes manually: [Table(Name="Role")] public class Role { private EntitySet<User> _Users; [Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)] public int RoleID { get; set; } [C...

why licenced code is packed and then is reviewable using Disassembler at the same time ?

Is it legal / ethical to copy code for any reason, or utilize it (like code review) from the .Net framework or any other .Net based API using Reflector or similar tools ? If it is, what advantages do Microsoft and other licence based softwares have for packing there code ? If it is not, Why can we use ILDasm and Reflector ? An...

.NET Parameter passing - by reference v/s by value

I'm trying to validate my understanding of how C#/.NET/CLR treats value types and reference types. I've read so many contradicting explanations I stil This is what I understand today, please correct me if my assumptions are wrong. Value types such as int etc live on the stack, Reference types live on the managed heap however if a refer...

How to get the application path at design time in winforms, .net?

If you use Application.StartupPath in a referenced dll, the path points to the path of the IDE. Is there anyway to get the path of the actual application? Just to be clear, this is at design time. ETA: I've posted the solution below: ETA2: Because it's related, I thought i'd post a snippet of another useful design-time service. Lik...

Create managed .NET array without initializing to all zeros

Take the following C# method: static double[] AddArrays(double[] left, double[] right) { if (left.Length != right.Length) { throw new ArgumentException("Arrays to add are not the same length"); } double[] result = new double[left.Length]; for (int i = 0; i < left.Length; i++) { result[i] = left[i] + righ...

What is nAnt, and how it can be useful to me as a C# developer?

I'm always compile my project, and copy the dll's from the dependency projects to the UI bin folder. after a few days with 'copy & paste' operations each time that I recompile my project, I concluded that I need a tool that will do it to me automatically. after a few searches a founded that this tool is nAnt. I search for information ho...

.NET Security Error accessing external API

Hi, i'm building a small Twitter web app for myself. I am using TweetSharp but I keep getting an error: Server Error in '/test' Application. Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system...

Threading UI Update (not the invoke required question)

I have a case where I am getting lots of sockets requests coming in. I would like to update the UI 3 seconds after the last socket request has come in. E.g If socket request comes in and the previous one was only 2 seconds ago it should clear the UI Update and start waiting for 3 seconds. Notes: Each Socket Request comes in on a differ...

Sending fax via asp.net

i'm trying to send faxes with a asp.NET (C#) program , Can you please suggest any reliable third party control . Need to generate PDF and send it via Fax in my web application. Any pointers and suggestion would be much appreciated. Thanks ! ...