.net

How can I obtain the group of "dirty" rows or cells from a DataGridview?

I am working with a DataGridView filled up from a view in my database. Being a view (maybe I'm wrong) I can't use the TableAdapter.Update() method so I need to know the altered cells from the DataGridView so I can update the values in their respective tables programatically. Can you help me? ...

Winforms reflector app

Years ago I had seen a tool that when running would allow you to click on a running Winforms application and it would reflect on whatever portion you clicked on to display properties etc of the code. (It saved some time as you could find the exact form/panel/tab etc. that a control lived in) eg. I have a Winforms app with tabs, panels, ...

How to use IDisposable to fix memory leaks

I have an .net app that seems to have a memory leak issue(s). The .net service starts out around 100MB of memory, but under load it hits around 400-500MB. Most of my classes don't have unmanaged resources, and the ones that do already implement IDisposable. So my question is would slapping IDisposable on my classes help? The 4-500 MB is...

How to test than an XML string is well formed in .net

I'm looking for some code in .net to allow me to test an xml file to determine if it is well-formed. I am not validating the file against a schema at this point in my code, just testing that it conforms to xml specification for being well formed. Any assistance is appreciated. ...

Multiple views in project

I want to create a project that contains 2 views and 2 viewmodels. One of the views will display persons that i get from a feed and the other will display the weather which I also receive from a feed. Now in my viewmodellocator constructor I have static ViewModelLocator() { Container = new UnityContainer(); ...

Double Buffering when not drawing in OnPaint(): why doesn't it work?

I'm working on a simple vector drawing app in C#/.Net. The drawing is done in a panel, but I'm not using the OnPaint() event for all of it - in fact the OnPaint() even just calls another method which actually draws everything in the document. I tried to add double buffering, but when I set DoubleBuffered to true, the flicker issue is ev...

TypeLoadException occurred when drag-and-drop a User Control into VS Designer

I created a customized ListView class, BinableListView, which inherits from ListView. I was able to drag and drop the custom ListView into a Form in the designer window. Now, I am trying to add the custom ListView in another User Control first, and add that User Control into the form. However, VS displayed TypeLoadException when I drag a...

How to disable VS compile warning "class or css class is not defined"

In VS 2008, when I compile, I get a large series of The class or CssClass value is not defined messages. How do I get the error/warning code (something like "C0167") for that message, so I can disable it? Answers that won't work: The compiler gives you the warning number. No, it doesn't. See the list of MSDN compiler errors (found a...

Generic method for accessing remoting and WCF classes

I am working on a project at the moment which is using WCF for all communication. Standard sort of coding, using ChannelFactory and CreateChannel to access methods and objects running on the server. Now, I have a form of event system setup, where a db table stores all the endpoints to inform given certain condiitons. So something happen...

Can a windows form display the min and max buttons without the close button?

Is there any way (in C#) to display a form with just the minimise and maximise buttons? Without the close button? The only way of removing the close button (that I'm aware of) is: form.ControlBox = false; But this also gets rid of both the other buttons. ...

Why exceptions are not propagated by WPF Dispatcher.Invoke?

Here's my hypothetical example. I have a very simple WPF window with a one Button. The Button.Click event has a handler that goes like this. Action doit = () => { Action error = () => { throw new InvalidOperationException("test"); }; try { this.Dispatcher.Invoke(error, DispatcherPriority.Normal); } catch (Exception ...

WPF Exception-Based Validation, Initial State not triggered...

(I know there's some close duplicates out there, but none of them were able to help me, please hear me out) I have the setters of my model throwing appropriate exceptions when something attempts to set an invalid value. This works wonders for validation when the user types a new value. However, when I create a new model object, the ini...

Switching from Linq-To-SQL to Entity Framework for WCF Data Services Issue with FK "Properties"

So, In my old Linq-To-SQL I would write code like this var tableItem = new Table { Prop1 = var1 Prop2 = var2, Prop3 = var3, ParentTableID = parentRecordID }; db.Table.InsertOnSubmit(tableItem); db.SubmitChanges(); After converting my working code from Linq-To-SQL to Entity Framework (v3.5) the ParentTableID property i...

How to sort a list of objects by a specific member?

Say I have a list of Person objects: class person { int id; string FirstName; string LastName; } How would I sort this list by the LastName member? List<Person> myPeople = GetMyPeople(); myPeople.Sort(/* what goes here? */); ...

Customer-customizable ORM in .NET

I have a need for allowing business rules to be defined in a commercial, shipping product with respect to data authorization rules. The rules need to be customizable in the field, and the customizations need to survive updates of the application. The system is C#/ASP.NET. I've considered using a DSL for this, but it seemed like a lot ...

How to write Internal mockable method

We are using Moq as our mocking framework, the problem is that type that needs to be mock-able is done using an interface, the problem with that is anything in that interface will be public and therefore considered part our public API. is there a way to have to have a member that is mockable and not public? ...

Entity Framework does not return object

Hi I found problem with EF. Here is my Model I loaded asset: POCO.Asset asset = _context.Assets.Where(a => a.UID == assetUid).First(); then I go through all properties foreach (POCO.Property p in asset.Properties) /* request to db */ { /*...*/ } categories: foreach (POCO.Category p in > asset.Categories) /* request to db */ { /*...

Regular Expression for Valid Active Directory Account Name

Does anyone have a regex that checks if a string is a valid AD account name? e.g. accounts can't have "@" and so forth. ...

[Microsoft Sync Framework] How-to modify the FilterClause of an already existent Scope?

Hello, I am learning the ropes of Microsoft Sync Framework, and have a question. For the sake of simplicity, let's say I have a table called [Project] in SQL Server with the following structure: [Project].[ProjectId] (PK, UID) [Project].[Name] (varchar) [Project].[Leader] (varchar) I create an Scope called 'filtered_proj...

String.Format escaping VB vs C#

While searching on how to escape a single quote in String.Format, I found the answer at SO: Escaping single quote in String.Format() It seems to be different for VB though. I tested it, and indeed C# needs string s = DateTime.Now.ToString("MMM d \\'yy 'at' H:mmm"); while VB needs Dim s As String = Now.ToString("MMM d \'yy 'at' H:mmm...