.net

How can I calculate the checksum of code at runtime?

I have a C#.NET application running on a machine. How do I calculate the checksum of the entire code at runtime? Note: I do not want to calculate the checksum of the image in use but the actual code part. ...

When do Extension Methods break?

We are currently discussing whether Extension methods in .NET are bad or not. Or under what circumstances Extension methods can introduce hard to find bugs or in any other way behave unexpectedly. We came up with: Writing an extension method for types that are not under your control (e.g. extending DirectoryInfo with GetTotalSize(), e...

Storing User Settings

Environment.SpecialFolder.CommonApplicationData *returns "C:\Documents and Settings\All Users\Application Data" under XP that is writeable for all users *returns "C:\ProgramData[MyApp]\" under Vista and this is not writeable for regular users Now why i want CommonFolder ? Because, an admin will install my software database on XP (or ...

What's better in performance - clone() or instantiation with new keyword?

When we want to have new objects for some class, and if we already have one, should we use clone() or instantiate using new keyword? Yes, clone() will have all the members copied as well, but I am curious for a case when this won't matter. ClassType foo = new ClassType(); ClassType bar = new ClassType(); // here, will foo.clone() be ...

How Do You Add a ServiceReference When the Service Does not expose Meta Data?

This is a follow up to this post on passing messages between two programs running on the same machine. I am trying to use Named Pipes but when I try and expose the Meta data I get a rights issue error saying HTTP could not register URL http://+:/8011/Local/Mex. I do not need to expose MetaData as this is a very simple service that is ...

Async process start and wait for it to finish

I am new to the thread model in .net. What would you use to: start a process that handles a file (process.StartInfo.FileName = fileName;) wait for the user to close the process OR abandon the thread after some time if the user closed the process, delete the file Starting the process and waiting should be done on a different thread t...

What should go in an MSBuild Script except compilation?

I'm currently trying to set up CruiseControl.net, and so I wonder how to split up my Tasks. Generally, I want to run Unit Tests (xUnit.net), Help File Generation (Sandcastle) and FxCop. Now I just wonder if I should specify a new Target in the msbuild config ("Documentation") and use that to run SandCastle, or if that belongs in a sepa...

Highlighting two child controls simultaneously

I have a windows form with two child controls. I need to highlight both the controls at the same time using c#. Please suggest me how to solve this problem. ...

What's Page __EVENTARGUMENT?

I saw code like this: if (this.Request["__EVENTARGUMENT"] == "Flag") //DoSomthing... Whats __EVENTARGUMENT means and is there some parameters like it to access? ...

How to create a WPF Window without a border that can be resized via a grip only?

If you set ResizeMode="CanResizeWithGrip" on a WPF Window then a resize grip is shown in the lower right corner, as below: If you set WindowStyle="None" as well the title bar disappears but the grey bevelled edge remains until you set ResizeMode="NoResize". Unfortunately, with this combination of properties set, the resize grip also ...

What causes the ProcessorArchitecture to lock to x86 or MSIL?

I have a .Net 2.0 application that uses COM to call a LabVIEW application (built as an .exe). The LabVIEW application calls various .Net assemblies we've written. Normally this all works fine. I have an app.config that redirects the LabVIEW app to the right versions of the right files, and everything is happy. Yesterday the LabVIEW app...

Why am I having a weird issue comparing object instances on IIS 7?

I have a really weird issue that I can't figure out with comparing objects on IIS 7. We are in the process of deploying our old IIS 6 based ASP.NET application on IIS 7, however we have this equality comparison issue that we can't seem to figure out. Let me start out by saying that I have the same assemblies and code running both on I...

Setting/Removing event handlers in .Net

So I am stuck with fixing/maintaining another programmers code (blech) I am a firm professor of the rule "If it ain't broke dont fix it!" so depsite wanting to change something every time I come across horrendous code, I am keeping myself limited to only changing the absolute minimum amount of code possible to make the required fixes. ...

Providing a feature only once to each unique visitor

I have written a message board as my first ASP.NET project. It seems to work well so far. However, one of the features I have is that each message has a spam rating. It is simply the number of times that viewers have marked the message as spam divided by the total number of times the message has been viewed. The idea is to allow users to...

Linq to SQL using multiple DataContexts in a single query.

I have this Linq to SQL query sequence that is basically returning a search on a table called PROJECTS. and I'm taking advantage of the deferred execution to slowly build it up. var query = from p in objDBContext.PROJECTs where (p.PROVIDER_ID == cwForm.productForm) select p; query = from p in query where p.SubmittedDate >= cwForm.beg...

.net Regular Expression involving html tags

I'm looking for a regular expression that detects whether or not a string is anything more than a bunch of HTML tags. So, desired functionality is: Input -> Output "<html></html>" -> False "<html>Hi</html>" -> True "<a href='google.com'>Click Me</a>" -> True "hello" -> True "<bold><italics></bold></italics>" -> False "" -> Don't ...

How do I handle child lists and get new object lists in C# using LINQ?

I have a LINQ query which gives me a list with a number of child lists all with double values. I want to get a queryResult from this. How can I get the first, the last, the highest and the lowest double value? Should it be a new object and should the new return values be a list? ...

SqlTransaction has completed

I have an application which potentially does thousands of inserts to a SQL Server 2005 database. If an insert fails for any reason (foreign key constraint, field length, etc.) the application is designed to log the insert error and continue. Each insert is independent of the others so transactions aren't needed for database integrity. H...

Keep VS2005 in sync with filesytem?

Is there an easy way to keep VS2005 project in sync with changes made directly on filesystem? In eclipse I can simply "refresh" the project and any changes show up. Does something similar exist in VS? ...

NHibernate filters don't work with Session.Get

I'm trying to implement a Soft-deletable repository. Usually this can be easily done with a Delete Event listener. To filter out the deleted entities, I can add a Where attribute to my class mapping. However, I also need to implement two more methods in the repository for this entity: Restore and Purge. Restore will "undelete" entities a...