.net

Unmanaged/native alternative for managed System::Diagnostics::Debugger::Launch function?

I have a mixed-mode application in which I want to fire up the debugger if an error is found in the internal datastructures. Strange enough, the DebugBreak and __debugbreak functions don't seem to work as expected (the .Net framework seems to intercept the breakpoint exception, leading to all kinds of nasty side effects). The solution o...

Are Generic lists stored on the stack or the heap in C#?

Are Generic lists stored on the stack Or the heap? example //List of Ints List<int> myInts = new List<int>(); myInts.Add(5); myInts.Add(10); myInts.Add(20); Is myInts stored on the stack or the heap? If I add an int to the list, does boxing or unboxing occur? ...

How to Implement Exchange like availability monitoring of internal SQL Server

We have an internal app(Thick Client) that relies on our central SQL server. The app is a Desktop app that allows the users to work in "Offline" mode (e.g. Outlook). What I need to accomplish is a way to accurately tell if SQL is available or not. What I have so far: I currently use the following method --> internal static void Che...

Regular expression library for .Net that supports lazy evaluation

I'm looking for a regular expression library in .Net that supports lazy evaluation. Note: I'm specifically looking for lazy evaluation (i.e., the library, instead of immediately returning all matches in a document, only consumes as much of the document as necessary to determine the next match per request), NOT support for lazy quantifie...

Where to put business rules for querying when using NHibernate?

Still new to NHibernate. I'm using NHibernate 2.1.2 and the Linq provider. I am wondering where I should put my business rule logic. For example, I have an entity called Service with DateTime property. In my web app, I only ever want to display/work with services whose DataTime is less than 4 weeks away. Where should I put that rule? I...

Listing all service instances in WCF

I have here what would appear to be a simple task; listing all the instances of a service object actively managed by a WCF ServiceHost at any particular time. For example, my service contract interface is IFooService and the implementation is FooService (with a per-session behaviour). On the service side I simply instantiate the service...

Outlook API: namespace.GetItemFromID() throws up "Could not open the item. Try again."

Hi, I'm trying to retrieve an outlook (2007) folder using something like this: Outlook.NameSpace MAPINameSpace = Application.GetNamespace("MAPI"); string storeID = MAPINameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).StoreID; Outlook.MAPIFolder folder = MAPINameSpace.GetItemFromID(folderID, storeID); I get an except...

Convert HTML to Microsoft Word .doc in .NET

What is the best way to convert HTML into MS Word .doc in .NET? Third party components? ...

Registration free COM, VBScript chokes on C# dll

I'm trying to get a third party app (hMailServer) to consume my C# library. They support 3rd party libraries using VBScript hooks. I got everything working fine using registration-full COM, but now want to use registration free. I've modified the hMailServer.exe manifest and added a manifest to my C# library. Now the hMailServer serv...

use RegEx to extract text between html tags

Hello, I have to extract from a string in visual basic some text, like this: <div id="div"> <h2 id="id-date">09.09.2010</h2> , here to extract the date <h3 id="nr">000</h3> , here a number </div> I need to extract the date from the div and the number all this from within the div... Also and this will be in loop, meaning there are mo...

.NET detect user activity system-wide

Hey all, I have a Windows Service that runs a CPU-intensive job. I have it installed on several computers. The problem is, when it runs the machine is wicked slow. So I'd like to have the service only run during periods of inactivity....just like a screensaver. I know I can use low-level keyboard/mouse hooks like in http://www.codepr...

GetCustomAttributes

<AttributeUsage(AttributeTargets.Property)> _ Private Class CustomAttrib Inherits Attribute Public Property DataTypeLength As Integer End Class Private Class TestClass <CustomAttrib(DataTypeLength:=75)> _ Public Property MyProp As String End Class Dim properties = GetType(TestClass).GetFields(Reflection.BindingFla...

Is there a simple .NET code generator for a Event-driven finite state machine?

Is there a simple .NET code generator for a Event-driven finite state machine? I am tired of doing this by hand for user-interface objects. I just need the enum definition, the switch statement, and each function call. I do not need a "library". See Event-driven finite state machine at http://en.wikipedia.org/wiki/Event_driven_finite_s...

Accessing Items in an IList with C# Reflection

I have a class with a Items property, which is an IList: class Stuff { IList<OtherStuff> Items; } I want to be able to receive a string within a method (I thought of this format originally: Items[0]) and be able to retrieve the first item of the Items list. I tried this: object MyMethod(string s, object obj) { return obj.Get...

Bind Data to Repeater using Ajax

Hi, I want to Bind data to a Repeater on click of a particular Button. I can do an ajax request via jQuery and call the method to bind the data, but on the page nothing is displayed. This is the method I use to bind the data to the Repeater: public void BindJobs() { if (RptClientDetails.Items.Count != 0) return; RptClientDeta...

C# P/Invoke: Pointer to string as error message

I am attempting to use llvmc as a C# library using P/Invokes(because I can't find any .NET bindings). However, I've a problem. llvmc uses char** for error passing. An example would be this: char* error = NULL; LLVMVerifyModule(PointerToSomeModule, LLVMAbortProcessAction, &error); What should I do to allow this function to be used in...

Error adding connection in Server Explorer: "Unable to add data connection. ExecuteScalar requires an open and available connection."

I'm using Visual Studio 2008, and my database is SQL Server 2000. I want to add a connection to the Server Explorer in VS. The Data source is Microsoft SQL Server (SqlClient). After entering in all my information and I click Test Connection, it is successful. But when I click OK, I get the error: Unable to add data connection. Execute...

Common Linq / Standard Query Operator mistakes/mis-steps?

For programmers that do not come from a functional programming background, are there an mistakes to avoid? ...

WP7: Save a contact with predefined details

I am doing a Windows Phone 7 project, and is retrieving personal details for a person based on his phone number via a webservice. I'd like to allow the user to save this data as a contact; Ideally I would like to show the Edit Contact dialog with all the fields pre-filled based on the data I retrieve. I know I can do this: var...

Dynamically modifying .NET DataSet DataTable

I’ve got a predefined Dataset with DataTables and DataAdapters in my applications. However, I now want to be able to modify the SP in SQL Server to add fields as needed, and have that reflected in the DataSet’s DataTable dynamically. This goes from a WebService into XML then goes to the client and gets converted back to the DataSet and...