.net

Better way of searching through lists than using foreach

list vclAsset<FullAsset> list callsigns<string> foreach(FullAsset fa in vclAsset) { if (callsigns.contains(fa.asset.callsign)) { //do something } } Is there a more elegant way to do the above? A FullAsset object contains an Asset object which in turn has a string "Callsign." Each callsign will be unique, so my li...

Vista Minesweeper Gameover uncover algorithm

I'm trying to make a vista minesweeper clone. Right now my uncover algorithm is the cascade algorithm. It kind of looks like a square that gets bigger and bigger. I noticed in vista mnesweeper, when its gameover, it iterates through the game in a circular manner to uncover the mines. Does anyone know what this algorithm is called? Thank...

Getting list of currently active managed threads in C#/.NET?

For a "log information for support" type of function I'd like to enumerate and dump active thread information. I'm well aware of the fact that race conditions can make this information semi-inaccurate, but I'd like to try to get the best possible result, even if it isn't 100% accurate. I looked at Process.Threads, but it returns Proces...

Is there a way to autosize columns in DataGrid .NET Compact Framework

I want to autofit columns to the content in cells. Also i want to add my headers to columns. Is there a way to achieve autosize?(i saw that column headers can be set with DataGridTableStyle) ...

Creating a Wizard for Plugin project development

My DotNET application allows for plug-in dlls by 3rd party developers. I'd like to facilitate the process of making these plug-ins by offering a set of tools that create empty projects and new standard classes. Essentially, I need to create a typical ClassLibrary project with a bunch of dll references and some PostBuild Events. Also, it ...

How do I use KnownType to enable polymorphic return values in a WCF service contract?

I am converting a remoting interface to WCF, however I have a method that is declared to return "object" and can return a number of different types (mostly different enums) Where can I find an example of coping with this? (I am using a shared contract assembly that contains all the types rather than generating a client proxy if that m...

.NET for Windows 7

I want to take advantage of the new Windows 7 taskbar functionality in a .NET application and would like to know what people think is the best way to check for Windows 7 features in .NET. My aim is to have distinct code for Windows XP and Windows 7. I'm not overally keen on: just wrapping the Windows 7 code in a try catch if OS = ...

How to write a WCF service with in-memory persistent storage?

I wrote a WCF service, but the data stored in the Service implementation doesn't persists between calls, not even if stored in a static variable. What can I do? The service implementation is as follows: public class Storage : IStorage { protected static object[] _data; #region IStorage Members public void Insert(object[] ...

C# User Controls: access controls properties

I have created a control and added a TextBox inside that control, I am attaching that control to a .aspx page via <%@ Register Src="../UserControls/AccountSearchControl.ascx" TagName="SearchControl" TagPrefix="csr" %> and <csr:SearchControl ID="AccountSearchControlBox" runat="server" OnSearchButtonClick="RetreiveAccounts" /> On ....

Lambda syntax in linq to db4o?

I know the following is possible with linq2db4o from Apple a in db where a.Color.Equals(Colors.Green) select a What I need however is something that allows me to build my query conditionally (like I can in other linq variants) public IEnumerable<Apple> SearchApples (AppleSearchbag bag){ var q = db.Apples; if(bag.Color != null...

passing value from opener to popup and processing it server side, not client side. Cant use a GET

I have an aspx web page (opener) which opens a popup window In the popup window I need to retrieve the value of a hidden field which exists in the opener page. So this is all straight forward using Javascript. However, here’s the problem, I need the value of the hidden field to be processed SERVER side before the pop up page loads (B...

Get Current .NET CLR version at runtime ?

How can I get the current CLR Runtime version in a running .NET program ? ...

Any PostSharp alternative?

I have to abandon using PostSharp, because it won't work with obfuscated/merged assemblies. At least, I don't see any way to get it working (it crashes on app start, when assemblies are obfuscated) I need to intercept some methods in my app (call special code instead of original methods - OnMethodInvocationAspect) Any advice? ...

How to set long string(>260) in default FileName in SaveFileDialog?

I am using a SaveFileDialog and have to set long string(longFileName) in FileName. String longFileName is known at Runtime. If I set saveFileDialog.FileName = longFileName ; then I get System.IO.PathTooLongException. How can I do it? ...

Same code acts differently on different machines - what might be the cause ? (CLR version issue ?)

I just finished debugging a problem, where our program crashed on a production server, but never on development machines. I have made this small program, which I could reproduce the issue with: using System; using System.Collections.Generic; using System.Linq; namespace RunTimeBug { class Program { static void Main(st...

Why use FinalReleaseComObject instead of ReleaseComObject?

I know the basic difference as ReleaseComObject only decreases some counter by one and FinalReleaseComObject decreases it to zero. So what I usually hear is, call FinalReleaseComObject because then you are sure that the COM object is really released. But this makes me wonder, there is a point to this counter right? Aren't you breakin...

how to archive msmq messages?

I have a bunch of messages in one of the queues from an old date. I would like to take a backup before purging them. Any thoughts? Schar ...

GDI+: Limitations of Paths and Regions

Are there limits/differences when performing GDI operations on off-screen objects like paths/regions as compared to performing the same operations on the display? What limits can I expect when performing graphics operations on a region/path as opposed to performing them directly on the display? When performing GDI operations on GDI reg...

How can you redefine a property using in reflection in C#?

Let's assume we have the following class: public class tx_fct { int _ok; public int ok { get { return _ok; } set { _ok = value; } } } How can I override the getter using reflection? The getter doesn't seem to be in tx_fct1.ok.GetType().GetMeth...

How to create a Silverlight Screencast?

I would like to create a Screencast that can be played by a Silverlight player or embedded in a Silverlight application. What program can I use to create the screen cast and how do I use the output with Silverlight? ...