.net

How do I specify the exit code of a console application in .net?

I have a trivial console app in .net. It's just a test part of a larger application. I'd like to specify the "exit code" of my console app. How do I do this? Thanks! ...

I need a LINQ expression to find an XElement where the element name and attributes match an input node.

I need to replace the contents of a node in an XElement hierarchy when the element name and all the attribute names and values match an input element. (If there is no match, the new element can be added.) For example, if my data looks like this: <root> <thing1 a1="a" a2="b">one</thing1> <thing2 a1="a" a2="a">two</thing2> <thing2 ...

Fast way to search for particular string (or byte array) in another process memory in C#?

Please post a working source code example (or link) of how to search string in another process memory and getting offset of match if found. The similar way its done in game cheating utils which search for values in game memory using ReadProcessMemory. ...

Provider model in .net

When the .net 2.0 framework first came out, the provider model was all the rage. 2.0 even shipped with a bunch of default providers (Membership, sitemap, role). Since the release of 2.0, the hype has died down, and whilst I still use providers day to day, it seems to get far less press. I was wondering if this is because people are usin...

Safehandle in C#

What is SafeHandle? how does it differ from IntPtr? When should I use one? What are its advantages? ...

Rhino Mocks: How to mock ADO.NET's DataRow?

ADO.NET has the notorious DataRow class which you cannot instantiate using new. This is a problem now that I find a need to mock it using Rhino Mocks. Does anyone have any ideas how I could get around this problem? ...

Getting an error when filling a datatable from a data adapter

I am getting this error but only very occasionally. 99.9% of the time it works fine: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. Does anyone have any idea on what the cause could be? I only use that datatable for viewing and not updating so is it possible to ea...

Design time serialization in C#

I have created a non-visual component in C# which is designed as a placeholder for meta-data on a form. The component has a property which is a collection of custom objects, this object is marked as Serializable and implements the GetObjectData for serilizing and public constuctor for deserilizing. In the resx file for the form it will ...

How to throw a XmlSchemaException on XML Schema validation errors?

Calling Validate() on an XmlDocument requires passing in a ValidationEventHandler delegate. That event function gets a ValidationEventArgs parameter which in turn has an Exception property of the type XmlSchemaException. Whew! My current code looks like this: ValidationEventHandler onValidationError = delegate(object sender, Vali...

Business Entity Loading Pattern

The project I'm working is using n-tier architecture. Our layers are as follows: Data Access Business Logic Business Entities Presentation The Business Logic calls down into the data access layer, and the Presentation layer calls down into the Business Logic layer, and the Business entities are referenced by all of them. Our busine...

Show a Form without stealing focus (in C#)

Hi, i'm using a Form to show notifications (it appears at the bottom right of the screen) but the problem that i'm having is that when I show this form it steals the main form focus. Is there a way to show this "notification" form without stealing focus? Thanks for your time. Cheers. ...

Update viewstate after populating a list with ASP.NET AJAX

I've got a dropdown list that is being populated via a webservice using ASP>NET AJAX. On the success callback of the method in javascript, I'm populating the dropdown via a loop: function populateDropDown(dropdownId, list, enable, showCount) { var dropdown = $get(dropdownId); dropdown.options.length = 1; for (var i = 0; ...

Reorder PDF Page Order

Is it possible to reorder an already generated PDF file programmatically, and using as little resources as possible, as this will need to be ran on ~8000 PDFs every month or so? We are currently using iTextSharp to merge the PDF’s in to larger PDF’s, but iTextsharp’s Documentation does not really explain much. ...

C# Attributes On Fields

How do I set an attribute on a field anywhere in my assembly, then reflect on those field attributes in my entire assembly and get/set the field values that the attribute is attached too? ...

Does a (.net) COM+ assembly need to be installed in the GAC?

I have a .net assembly that has a COM+ ServicedCopmonent in it and at the moment I install it into the GAC to get everything working. This means that I need to have every assembly that it references in the GAC as well. During development it is quite painful to make changes to thes assemblies, re-install them to the GAC and then test. ...

Enumerate errors in an error provider

Is it possible to enumerate all the current errors being displayed through an "Error Provider" without having to access the controls? ...

How to write an Excel workbook to a MemoryStream in .NET?

How do I write an Excel workbook to a MemoryStream without first saving it to the file system? All options within the Microsoft.Office.Interop.Excel.WorkBook save options take a filename. ...

Does a Silverlight memory profiler exist?

CLR profiler does not seem to work with the Silverlight CLR. Does another memory profiler exist? ...

How do you manage asp.net SQL membership roles/users in production?

How do you setup an asp.net sql membership role/membership provider on a production machine? I'm trying to setup BlogEngine.NET and all the documentation says to use the ASP.NET Website Administration tool from Visual Studio but that isn't available on a production machine. Am I the first BlogEngine user to use it on a non-development bo...

What the best rollover log file tracelistener for .NET

I'm looking for a good TraceListener for .Net that supports rolling over the log file based on size limits. Constraints Uses .Net built in Trace logging Independent class or binary that's not part of some gigantic library Allows rolling over a log file based on size ...