.net

How can i get the DomainName\AccountName with the .NET Framework?

How can i get the DomainName\AccountName as string with the .NET Framework? ...

Find height of ContextMenuStrip before showing it

I have a ContextMenuStrip (ctMenuMassEdit) that I want to display when left-clicking a button (btnMassEdit). I want the ContextMenuStrip to be displayed above the button, i.e. position (0,-ContextMenuStrip.Height) relative to the button: private void btnMassEdit_Click(object sender, EventArgs e) { ctMenuMassEdit.Show(btnMassEdit, ne...

C#: cannot find assembly file

I am getting an error back from a DLL saying it cannot create an instance of one of classes in my solution because it cannot find the assembly file. If I am debugging a solution, do I need to put a copy of certain assembly files in other locations? EDIT: In my compiled solution all the DLLs (including the proprietary ones) all go in t...

When should use Readonly and Get only properties

In a .NET application when should I use "ReadOnly" properties and when should I use just "Get". What is the difference between these two. private readonly double Fuel= 0; public double FuelConsumption { get { return Fuel; } } or private double Fuel= 0; public doub...

Find window with specific text for a Process

Hello, I'm trying to find if a window with specific has been open by a Process. That process spawns multiple windows, and I need to check them all. I have no trouble finding the process, with foreach (Process p in Process.GetProcesses()) { if (p.MainModule.FileName.ToLower().EndsWith("foo.exe")) FindChildWindowWithText(p); //do ...

Setting the cursor position in a NumericUpDown Control

Hi, I have created a user control tha inherits from the NumericUpDown Control. Is it possible to set the cursor position within the control? I am validating the text OnKeyUp, and formatting it when it meets certain criteria. To do this i have to do me.text = Fomatted(Me.Text), which sets the cursor back to the position 0, i want to set...

C#: proprietary DLLs requiring access to my assemblies

My solution uses a proprietary assembly, which when debugging the solution throws an Exception saying it can't find an assembly that is meant to be one of the projects in my solution. I cannot add a reference to the proprietary assembly because all I have is the DLL. When I compile everything into a single application directory and run...

List method creation

I'm creating a list of my defined objects like so List<clock> cclocks = new List<clocks>(); for each object in the list i'm calling a method moveTime, like so foreach(clock c in cclocks) { c.moveTime(); } is the a way i can write some cleaver thing so i can call cclocks.moveTime(); it would then go though the list doing tha...

int.Parse of "8" fails. int.Parse always requires CultureInfo.InvariantCulture?

We develop an established software which works fine on all known computers except one. The problem is to parse strings that begin with "8". It seems like "8" in the beginning of a string is a reserved character. Parsing: int.Parse("8") -> Exception message: Input string was not in a correct format. int.Parse("80") -> 0 int.Parse("88") ...

Linq To Text Files

Hi All I have a Text File (Sorry, I'm not allowed to work on XML files :(), and it includes customer records. Each text file looks like: Account_ID: 98734BLAH9873 User Name: something_85 First Name: ILove Last Name: XML Age: 209 etc... And I need to be able to use LINQ to get the data from these text files and just store them in memo...

OpenGL Wrapper in .Net

This question is similar to the one here. But I feel that the answers recommended ( such as Tao and OpenTK) are not good enough because they are just a direct port from OpenGL, with no OOP design, and hard to use. What I'm looking for is a .Net OpenGL wrapper that is written in clear OOP principles, easy to use ( easy to apply textual a...

Is passing a Command object/Reader to a function a good idea?

I've been getting some inexplicable errors (running out of connections from the connection pool) with MySql database with .Net 4 (C#). Till now all my attempts at finding a reason for this have been in vain. Now I also have a situation in which a lock on a table is not cleared for a long time even though all I have been doing is read ope...

Add webservice reference, the classes in different file

Hi, When I add webservice as service reference in my .Net project, it creates a service folder within "Service References". All the interfaces and classes are contained within that service folder. I wanted to know how to split the interface's method and classes. Actually I wanted the web service reference to import classes defined in dif...

Efficiently remove points with same slope

Hi, In one of mine applications I am dealing with graphics objects. I am using open source GPC library to clip/merge two shapes. To improve accuracy I am sampling (adding multiple points between two edges) existing shapes. But before displaying back the merged shape I need to remove all the points between two edges. But I am not ab...

WPF/Silverlight AutoCompleteBox with ability to add new values to list.

Hi, I would like to use autocompletebox with a list of values, but also add new values to the list if a user enters one that isn't present. I currently have a string property in my view model called 'Comment'. Currently this is bound to a textbox in the view - user types a comment and the view model is updated. Simple. To save time, m...

Strategy for converting a VB6 app to .NET

Would it be a good idea to start converting forms into .NET one at a time which you would then invoke from the VB6 app via COM-interop. This way, by the end of the process you would just convert the 'shell' of the VB6 application into a new .NET app, and all your forms are ready to go in .NET. Is there a better strategy? ...

BindingFlags.DeclaredOnly alternative to avoid ambiguous properties of derived classes (AmbiguousMatchException)

I'am looking for a solution to access 'flatten' (lowest) properties values of a class and its derived via reflection by property names. ie access either Property1 or Property2 from the ClassB or ClassC type : public class ClassA { public virtual object Property1 { get; set; } public object Property2 { get; set; ...

How to get all methods from WCF service?

How to get list of all methods from WCF silverlight enabled service from code. I already have added service reference to Silverlight application. Can I get all methods using Reflection? If can please provide me example. ...

Communication between two apps, is SSIS the way to go?

Hi, working with a team of more traditional developers we came across this situation: We have a growing number (two right now) of apps that will be accessing some common data inserted via the ui of one of the apps, which could be called the main administrative app. Since the other apps just need some of the data or needed formatted with...

How to add a new row into datagridview using grid only. i.e by showing textboxes and add button in WinForm

I want to add a new row to a datagridview such that when a user clicks on new button , a new is is generated with few textboxes and combo boxes and after filling up all the details he save the info by clicking on save button. EDIT I want to do it like it is seen in gridview(Template Fields) in asp.net I am looking for same kind of fun...