.net

Is it possible to know if .NET Framework is installed from a .NET application?

Here's the thing. My .NET application crashes with a pretty ugly general exception fault when I try to run it in a machine that doesn't have .NET framework installed. Is this normal? If it is... is there any way to check for .NET framework to be able to exit gracefully instead? ...

how to retrive values from 100 Textbox using loops

friens, I Have a grid of 100 or more text boxes (HTML OR ASP.NET) each will be containing a text value of fixed length, need ALL of these passed back to the back end form for mass updating of the database.. i can do this by simple going through each of the controls .text property in code behind however that makes the code to big and u...

What's the use of Invoke() in .net ?

I found this code: this.Invoke(new EventHandler(EventGetSum)); Is this not the same as writing: EventGetSum(); What's the use of this? ...

How to fail gracefully if .NET is not installed?

I've recently asked if you can detect from the application if .NET is installed (so that application will not crash with a general exception fault). The answer seems to be a plain "no". I still want to be able to exit gracefully if .NET is not installed, is there any way to do this? Keep in mind that I don't want to change the executab...

Lance Hunt's C# Coding Standards - enum confusion

My team has recently started using Lance Hunt's C# Coding Standards document as a starting point for consolidating our coding standards. There is one item that we just don't understand the point of, can anyone here shed any light on it? The item is number 77: Always validate an enumeration variable or parameter value before con...

How to clone an FrameworkElementFactory object and its links?

Hello, I would like to ask you some help in creating a code the is able to clone a FrameworkElementFactory object created at runtime with the code. Dim cellTemplateFactory As New FrameworkElementFactory(GetType(NumericTextBox)) cellTemplateFactory.SetValue(NumericTextBox.TypeCodeProperty, Type.GetTypeCode(GetType(Byte))) Dim b As New ...

CruiseControl.Net complaining about xml

I inherited an existing project with a failing build. I can see the exception in the ccnet.log file: Exception: System.Xml.XmlException: Name cannot begin with the '%' character, hexadecimal value 0x25. Line 17, position 100. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, Strin...

Which list/collection type is best to use in a WCF data contract?

When defining a WCF data contract, which type should one use for collections/lists? Should it be ICollection<T>, IList<T>, T[] or...? Should I use interface types or the concrete types? What trade offs are there to consider? ...

Pattern for Plugins - IoC/DI or not?

Just a very general question, that not only applies to this example. Let's say you have an Online Shop and you want to implement Vouchers/Gift Certificates, but with Constraints. Let's say you have a voucher for 20% off, but that applies only to products added within the last 3 weeks, but not to ones in a special promotion. I see two w...

Adding design-time support for a nested container in a custom/usercontrol (Winforms).

Hi I have something similar to a wizard control, in the middle is a Panel I would like to use to place any child controls. I have found using the ScrollableControlDesigner will allow dropped controls to be added to the custom/usercontrol, but this is not what I require. It needs to be added to the container, so layout can be applied wi...

Is Regex pattern a simple text or a rule?

Is there any relatively simple way to recognize Regex pattern as simple text or as a rule? Edit One example. @"[A-Z0-9]" - is a rule, and @"\[A-Z0-9\]" is a plain simple text (C# string syntax) ...

Return index value datetime.now.dayofweek but how?

is there any function of datetime return dayofweekindex? such as: int Todaywhat_is_Index= = DateTime.Now.IndexOfDayofThisWeek; if Today is friday, it must be return 5 ifToday is Saturday, it must be return 6 ifToday is Sunday, it must be return 0 ...

WinForms: How to custom draw using the selected RenderMode?

I have some custom controls that will require custom painting. I cannot use any of the drawing services available in Windows (e.g. ThemeAPI), since .NET applications ignore look-and-feel of the operating system they are on, and instead use their own look and feel. e.g. Toolbars are not the toolbar common control Status bars are not t...

.Net PropertyGrid DropDownList - return value different from show value

I want to be able to show in a propertygrid a dropdownlist that show some "string" value but return an "int" value. For example, let set I got this class : public class MyObjectOptions : StringConverter { public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } public ove...

Can I automatically wrap HierarchicalDataTemplate items inside of a TreeViewItem?

I have a 4-level tree structure, defined by: <HierarchicalDataTemplate DataType="{x:Type src:Level1}" ItemsSource="{Binding Path=Level2Items}"> <TextBlock Text="{Binding Path=Level1Name}"/> </HierarchicalDataTemplate> <HierarchicalDataTemplate DataType="{x:Type src:Level2}" ItemsSource="{Binding Path=Level3Items}"> <TextBlock T...

What is the best way to implement a 'Forgot your Password?' page?

I am using the Membership features in ASP .NET 2.0. I was wondering how I would implement a Forgot your password page when my application is configured to allow only authenticated users. Right now the only page that can be accessed is the login page. I want un-athenticated users to be also allowed to access the forgot your password pa...

How can I apply a filter to grandparents in nHibernate?

I have a question about nHibernate and filtering. I am using nHibernate 2.2 but I think this will apply to versions as early as 1.2. I have created a simple example to illustrate the problem. I have three domain objects: Country, State, and City (assume the DB tables match the domain and have the appropriate relations defined. I want to...

How do you specify to pass a Type that is of a specific interface?

I have a method where I want to have a parameter that is a Type, but of a certain interface. E.g.: public static ConvertFile(Type fileType) where I can specify fileType inherits IFileConvert. Is this possible? ...

Difference between generic argument constrained to an interface and just using the interface

What is the difference between this: void MyMethod(IMyInterface value) { //... } and this: void MyMethod<T>(T value) where T : IMyInterface { //... } ...

Is there ItemsPanelTemplate that will make the Items uniformly fill the control ?

I have a ItemsControl and I will like the items to uniformly fill the the control. Using a StackPanel as the ItemsPanelTemplate only stretches in one direction. ...