.net

Logging to TextFile from SharePoint

I'm trying to debug a webpart installed on a client's SharePoint instance. I wanted a quick and easy logging feature, so I thought of writing messages to a text file in the temp directory. SharePoint doesn't seem to like it, so what are my options? ...

.NET threading solution for long queries

Senerio We have a C# .Net Web Application that records incidents. An external database needs to be queried when an incident is approved by a supervisor. The queries to this external database are sometimes taking a while to run. This lag is experienced through the browser. Possible Solution I want to use threading to eliminate the simu...

How would I go about licensing a WPF windows application

I have developed a small application that I would like to try and sell but I am unfamiliar with how best to go about this. How would I go about locking the program down for trial use1. How would I go about dealing with accepting payments? Bearing in mind that I am a one man band with not a lot of money, I was hoping for a solution ...

Alternative to COM blind aggregation in .NET for class with private interface

When extending a COM class in unmanaged C++ where the original class has private interfaces, one way to do this is through the concept of blind aggregation. The idea is that any interface not explicitly implemented on the outer aggregating class is 'blindly' forwarded to the inner aggregated class. Now .NET as far as I can figure out do...

Solving Naked Triples in Sudoku

Hello, I wished I paid more attention to the math classes back in Uni. :) How do I implement this math formula for naked triples? Naked Triples Take three cells C = {c1, c2, c3} that share a unit U. Take three numbers N = {n1, n2, n3}. If each cell in C has as its candidates ci ⊆ N then we can remove all ni ∈ N from the other cells in...

Can managed and unmanaged C++/MFC be mixed in one dll?

Previously we had software in MFC (VC6), VB6 and C# applications that needed to call the same engine written in C++ (and MFC). The engine required C++ for speed. At the time we decided to use COM as the interface because all three could use it with the least issues in marshalling, etc. Our MFC application is now deprecated and we have...

Clearing ColorConvertedBitmap in C#

Hi guys, the problem is: I want to use the same ColorConvertedBitmap object for two purposes, firstly I set everyting: ColorConvertedBitmap conv = new ColorConvertedBitmap(); conv.BeginInit(); conv.SourceColorContext = new ColorContext(PixelFormats.Bgra32); conv.Source = myImage; conv.DestinationFormat = PixelFormats.Pbgra32; conv.Dest...

Why the current working directory changes when use the Open file dialog in Windows XP ?

I have found an strange behavior when use the open file dialog in c#. If use this code in Windows XP the current working directory changes to the path of the selected file, however if you run this code in Windows 7 the current working directory does not change. private void button1_Click(object sender, EventArgs e) { ...

Is there a comprehensive list of the NHibernate event listeners and when they actually fire?

So I am looking for a nice list of NHibernate events that actually describes when they are fired, in a typical scenario (not just a list). IE something like PreUpdateEventListener - Fires when an object that is already persistent is changing I currently just rifle through the source and try to figure it out, but it's kinda pai...

Get all window handles for a process

Using Microsoft Spy++, I can see that the following windows that belong to a process: Process XYZ window handles, displayed in tree form just like Spy++ gives me: A B C D E F G H I J K I can get the process, and the MainWindowHandle property points to the handle for window F. If I enumerate the child windows us...

Delegates with explicit "this" pointer?

Is it possible to adapt a method like this function "F" class C { public void F(int i); } to a delegate like Action<C,int>? I have this vague recollection that Microsoft was working on supporting this kind of adaptation. But maybe I misremembered! Edit: I know that this doesn't compile in VS2008: class C { public void F(int...

Can this be improved? Scrubbing of dangerous html tags.

I been finding that for something that I consider pretty import there is very little information or libraries on how to deal with this problem. I found this while searching. I really don't know all the million ways that a hacker could try to insert the dangerous tags. I have a rich html editor so I need to keep non dangerous tags but s...

Accessing empty Linq result is very slow

Getting my feet wet with Linq. I am trying to determine the distinct values contained across four DataColumns. So, I start with var c1types = (from DataRow row in dtSource.Select("hasreq") where row["m"].ToInt() > 0 select new { col = row["m"] }).Distinct(); var c2types = (from DataRow row in dtSource.Sel...

FxCop CA2000 Warning in UserControls

Running FxCop on a WebProject that contains a UserControl will result in a CA2000 Warning (Call System.IDisposable.Dispose on object) for every ServerControl (Label, TextBox,...) in that UserControl. I understand why this would happen. Replacing the 'offending' ServerControls with a PlaceHolder and then adding the Controls in code (Usin...

.NET 4 SpinLock

The following test code (F#) is not returning the result I'd expect: let safeCount() = let n = 1000000 let counter = ref 0 let spinlock = ref <| SpinLock(false) let run i0 i1 () = for i=i0 to i1-1 do let locked = ref false try (!spinlock).Enter locked if !locked then counter := !counter ...

WCF custom certificate validation with BasicHttpBinding

I have a WCF application hosted on IIS 6 that needs to Have 2-way SSL authentication Validate client certificate content with some client host information Validate client certificate is issued by the valid subCA. I was able to do 1) successfully. I am trying to achieve 2) and 3) by following this - basically creating a class that in...

How can I have a serializable struct that wraps it's self as an int32 implicitly? in C#?

Long story short, I have a struct (see below) that contains exactly one field: private int value; I've also implemented implicit conversion operators: public static implicit operator int(Outlet val) { return val.value; } public static implicit operator Outlet(int val) { return new Outlet(val); ...

What is the difference between System.Linq and System.Data.Linq?

I was having troubles earlier while trying to declare a ChangeAction parameter in a method, with the IDE saying I might be missing a Namespace. So I right click it and Resolve it and find that System.Data.Linq has been added and now everything is fine. What is the difference between these two namespaces? ...

"The provider is not compatible with the version of Oracle client"

I just put my asp .net web service on a remote host. The service accesses an oracle db on my local machine. The service worked fine when it was running on localhost but since moving to a remote hos, I get The provider is not compatible with the version of Oracle client at Oracle.DataAccess.Client.OracleInit.Initialize() at Oracl...

Sharepoint SSRS: Unexpected Error Encountered

We are running an intranet website hosted on Sharepoint 2007, serving reports to users via SSRS. Recently, our users are experiencing error when trying to access certain reports with the error message "An unexpected error has occurred". After trying many things, to cut a long story short we manage to temporarily solve the problem by man...