.net

Version numbers is 1.13 > 1.2?

I know from the .NET perspective that an assembly with a version of 1.13 is considered a newer release than version 1.2 because each number in the version is evaluated individually. However from a numerical point of view 1.13 is < than 1.2. The issue comes down to readability when publishing updates for customers. From .0 to .9 it's al...

How do I center controls without resizing them? (.net Winforms)

I have a fairly simple user control that represents a basic login control. So it has a couple labels, text boxes, and a button. I would like this user control to fill its container, so I have set its dock mode to fill. So far easy enough. Now, I would like all the controls in my user control to be centered based on whatever size my...

Instantiating a .Net object by classname

I have an abstract class Step, and many descendant Step classes that I would like to instantiate based on an XML document. As such I would like to create an instance of a particular step class based on the type in the XML document Step type="GenerateReport" .... Step type="PrintReport" .... How can I instantiate an object by spe...

Anyone has sample code that makes WMI queries to the CIM_DataFile class?

Something that does SELECT's to get info about a file or directory? Something that actually works? Language doesn't matter, I'm most interested in the query syntax. ...

OnValidate() and LINQ to Entities

I would like to implement some business rule validation like Scott Guthrie did in his MVC Nerddinner tutorial (http://nerddinnerbook.s3.amazonaws.com/Part3.htm), but I'm running into a problem trying to do so. Scott was using Linq to SQL in his tutorial. He creates partial classes for his data objects, and then he implements a partial ...

Why not have OnXXX event raiser methods return a value?

Say you have an event raiser method (OnXXX) that raises an event using the CancelEventArgs class is there anything wrong with having the OnXXX method return the value of e.Cancel? For example: Public Sub ProcessFiles(folder as DirectoryInfo) For each file in folder.GetFiles() If OnProcessingFile(New FileEventArgs(file)) Th...

How to get X509Certificate from an arbitrary HTTPS URL?

I'm using HttpWebRequest to pull a page from an arbitrary HTTPS URL. In addition to the actual page result, I want to get an X509Certificate2 instance for the remote server I just talked to. I'm sure the public certificate is on the computer somewhere because its chain had to be validated as part of the request. How can I get access t...

How to make a .NET windows service install without antivirus problems

Hey guys, I'm making my first windows service in C#, at the moment a pretty innocent looking thing that doesn't do anything yet. However I find when I try to install it, either using a standard Setup project in Visual Studio, or using the simple "self-installer" outlined here, our company's antivirus won't allow installation because it...

Does the Java URIResolver concept exist in C# and .NET?

In the Java XML transformation package, there is a concept known as a URIResolver, which is "An object that implements this interface that can be called by the processor to turn a URI used in document(), xsl:import, or xsl:include into a Source object." So, if your XSL has an import like this <xsl:import href="URI"/> This allows you...

Show message by iterating observable collection containing date and time.

I have a Observable collection which is bind to listview which contains date and time. When a time in the collection occurs a messagebox should be shown. I do as public class Reminder { public string Name { get; set; } public string Date { get; set; } public string Time { get; set; } } ObservableCollection<Reminder> remind...

Update elements within Nested Xml

I have Xml which looks like this: <DataMapper xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <SqlTable /> <Level_01s> <DataParameter> <SqlTable>MY-Table-Name</SqlTable> <Children> <DataParameter> <SqlTable>MY-Table-Name</SqlTable> <Ch...

.NET Winform - thumbnail of usercontrol

I have an app which uses some usercontrols. I want to take a thumbnail image of the usercontrols when they are loaded for use and add them to a flowlayout panel. Where can I find information on making a thumbnail image of a usercontrol when it's loaded? ...

Linq and comparing two date columns

I get a notsupportedexception when i run the following linq query. Any ideas how to resove it var declines = from d in _Db.DeclinedSettlementSet where d.STATUS == Status.REPORTED && d.ADD_DATE < d.EDIT_DATE.AddDays(-3) ...

Number of CLR and GC instances running on a machine?

I create 2 .NET applications and run them on a machine - how many CLR's and gc's will be there? In addition: I would like to have some background information on how Windows handles COM components and CLR in particular. Hope someone could detail down to how CLR loads in memory and what it means if I get multiple CLR instances listed on r...

How to convert .net collection type to VBA collection?

I am writing a VBA application which calls to C#.net method which returns collection object. When I assign the output to VBA.Collection I get a compile time error - Argument not optional. If I assign the output to Object I get run time error - Object variable or With block variable not set I think it is because of incompatible Collect...

How should I create a user preference attribute?

In my current asp.net mvc project a user should be able to log in. When logged in a set of preferences can optionally be set. Some of those preferences are general (e.g. prefered site language etc), but some are specific to this project only (pre-defined query filtering etc). Since these preferences are present in a lot of different pla...

C# arrays , Getting a sub-array from an existing array.

I Have an array X of 10 elements. I would like to create a new array containing all the elements from X that begin at index 3 and ends in index 7. Sure I can easily write a loop that will do it for me but I would like to keep my code cleaner as possible.I also think its stupid to write methods that already exists. Is there a method in C#...

How to send an HTTPS GET Request in C#

Related: how-do-i-use-webrequest-to-access-an-ssl-encrypted-site-using-https How to send an HTTPS GET Request in C#? ...

Exception handling around the rollback of a SqlTransaction

I have two stored procedures that I want execute wrapped in a transaction. For various reasons, I need to handle the transaction in my application code instead of within the database. At the moment, my code looks like this: try { using (SqlConnection conn = Connection()) { conn.Open(); using (SqlTransaction sq...

How can I get a list of built-in routed events in WPF

I'm just starting out with WPF and need some help with routed events. I have added a datagrid with some animation, but i can't seem to find anywhere that shows me a list of routed events to use on the datagrid, or any other control for that matter. Seems to be a guessing game so far. I thought the datagrid standard events, such as C...