.net

What are the Finalizer Queue and Control+ThreadMethodEntry?

I have a WindowsForms app that appears to leak memory, so I used Redgate's ANTS Memory Profiler to look at the objects I suspect and find that they are only held by objects already on the Finalizer Queue. Great, exactly what is a the Finalizer Queue? Can you point me to the best definition? Can you share any anecdotal advice? Also, all ...

Comparing expressions of type object

Okay, this is probably very simple but, I have the below "checks" (not at the same time) and the First ALWAYS evaluates to TRUE while the Second SEEMS to work. This actually happens in each place that the row value is a number or bool(Date seems fine...). If I walk through the code in Debug it shows the value of row["PersonID"] as 16...

Architecture: Maintaining order history

I am working on a new domain model for an application that will have order processing for items built in (well, too keep it simple for this question anyway). I have a class "VendorItem" that represents items that can be ordered. Originally the "Order" class was going to have a list of VendorItems associated with it, but I have come acr...

How do I put code examples in .NET XML comments?

What tags can I use for putting code examples in .NET /// XML comments? Is this the best place to put them? ...

ASP.NET MVC - Find Absolute Path to the App_Data folder from Controller

What is the correct way to find the absolute path to the App_Data folder from a Controller in an ASP.NET MVC project? I'd like to be able to temporarily work with an .xml file and I don't want to hardcode the path. This does not work: [HandleError] public class HomeController : Controller { public ActionResult Index() { ...

Finding out whether a pathspec is a directory or file (or something else) through WMI?

I have some C# code to get information about a file through WMI, which used to make the following query: SELECT * FROM CIM_DataFile WHERE Drive = 'C:' AND Path = '\\temp\\' AND FileName = 'testemef' AND Extension = 'txt' I found out I can query both directories and files if I use the CIM_LogicalFile class instead: SELECT * FROM CIM_L...

ClickOnce Questions

Hi, I have a VS2008 Solution that contains a Client project, WindowsService project, and ServiceConsole project. When I deploy, I would like the WindowsService and ServiceConsole to be in the same folder since ServiceConsole needs access to WindowsService's app.config (i.e. Settings.settings) file to configure it. Is this possible wit...

How to update with Linq-To-SQL?

I need to update values but I am looping all the tables values to do it: public static void Update(IEnumerable<Sample> samples , DataClassesDataContext db) { foreach (var sample in db.Samples) { var matches = samples.Where(a => a.Id == sample.Id); if(matches.Any()) { var match = matches.Fi...

Select Rows from a DataSet using LINQ, where the list of RowsID's are in a List<T>

First I have to say, that I am a newby using LINQ. Actually I never used before, but I am having a task where I need to filter a DataTable, using values that will come from a List. So I will like to know if it's possible in LINQ to query on a Datatable using values in the List as Filter values. Some one can give me some hint's Thank you...

.NET: System.ComponentModel.DataAnnotations

Can someone point me to a web-/screencast or tutorial--video preferrably--that explains this new namespace and how I can use it to help validate data like user input? Pretty please. ...

Inside Info on Dynamic Data

This is a sister question to my other one here, not linked to because I'm not posting this to pull views of that. I'm busy with my first dynamic data project and loving it, and, of course, I have a few challenges that I'd like to resolve and also maybe debug myself. However, the framework is quite dense in terms of how what gets done o...

Order of constructors for a C# class: parameterized, default, and static?

Suppose I have a class with 3 constructors, a default (no argument) constructor, a parameterized constructor, and a static constructor. like this: public MyClass() { ... } public MyClass(string arg) : this() { ... } static MyClass() { ... } Supposing I invoke the parameterized constructor, in what order do these constructors ex...

Method unexpectedly stopping short of completion, c# 2008 .net 3.5

Ok so this is some code im writing to help me out on a game, anyway this stumped me... ok so this calls my method: private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e) { if (webBrowser1.Document.Url.OriginalString.Contains(@"page=logs")) { AttatchProcess Test = new Attatc...

3.5 SP1 Application Compatability Update (GDR) - Is there a list of known incompatabilities?

3.5 SP1 was released, which also included 3.0 SP2 and 2.0 SP2. All three of these service packs potentially introduced a number of incompatibilities if you were using these versions of any of the frameworks and installed the update. There was a lot of bad press regarding the SP1 update and the number of issues it introduced. e.g. http://...

Is using delegates excessively a bad idea for performance?

Consider the following code: if (IsDebuggingEnabled) { instance.Log(GetDetailedDebugInfo()); } GetDetailedDebugInfo() may be an expensive method, so we only want to call it if we're running in debug mode. Now, the cleaner alternative is to code something like this: instance.Log(() => GetDetailedDebugInfo()); Where .Log() is d...

Is it possible to programmatically debug one's own .NET process

.NET provides an API to debug programs: http://msdn.microsoft.com/en-us/library/bb397953.aspx Is it possible to debug a thread in the same process? In other words, is it possible to have the debugger and debugee in different threads in the same process? ...

Brightness/exposure function with vb .net

Hello, I'm making a simple image editor in vb .net, and one of the functions is brightness/ exposure. this is how I'm doing it: For i = 0 To img.Width - 1 For j = 0 To img.Height - 1 Dim s As Color = img.GetPixel(i, j) Dim r As Integer = s.R * 2 Dim g As Integer = s.G * 2 Dim b ...

Question about Immutability and object initialization from C# in depth 2nd. ed( MEAP)

So I started reading Jon Skeet's 2nd edition of C# in depth and kind of confused about the following code in terms what it does and what is wrong with it (ch 13, section: Immutability and object initialization) Message message = new Message( "[email protected]", "[email protected]", "I hope you like the second edit...

How to index your Silverlight application in search engine?

Well, I have a Silverlight application with many internal pages, and I want search engine to index my Silverlight content. Besides I want to manage my Silverlight content for search engine and reader effectively. How can I do Search Engine Optimization “SEO” for Silverlight? Thanks ...

Should One Always Call EndInvoke a Delegate inside AsyncCallback?

I read the Use AsyncCallback, there is this code snippet: using System; using System.Threading; using System.Runtime.Remoting.Messaging; class MainClass { delegate int MyDelegate(string s); static void Main(string[] args) { MyDelegate X = new MyDelegate(DoSomething); AsyncCallback cb = new AsyncCallback(DoSomething2); ...