.net

Extension methods overloading in C#, does it work?

Having a class that has a method, like this: class Window { public void Display(Button button) { // ... } } is it possible to overload the method with another one that is more broad, like this: class WindowExtensions { public void Display(this Window window, object o) { Button button = BlahBlah(o); ...

Is there a way to retrieve the last character of a file without reading line by line?

I need to retrieve the last character of a file. It may be a line break, or one of many special characters. Can I retrieve this character without parsing through the entire file? Or is there a way that I can read an entire file into a string without worry about line breaks? I will essentially need to split the contents of the file, b...

DataBinding feedback in .NET2

I have a object myObject.Name in a Form1 with a textBox1 In the Form1_Load I do: this.TextBox1.DataBindings.Add("Text", myObject, "Name"); When validating the textBox I have myObject.Name changed. This is OK. Now I modify internally in myObject _name = "changed value", but myTextBox text will not change. so... how to do it on both di...

COM Callable Wrapper and .NET object lifetime

I have a c# .NET assembly that gets called from a C++ COM client. When the client process explicitely release the COM object, the CCW release it'sinternal reference, thus making the .NET object eligible for garbage collection. What if the .NET object has a static constructor that open a log file ? Is there an elegant solution to close t...

How to set baud rate to 10400

Is it possible to set the baud rate to 10400? (Using .Net) ...

is System.DirectoryServices.AccountManagement.GroupPrincipal thread safe?

I am writing a program that will create users in bulk, I have a operation that is part of the creation that is blocks for about 5 seconds, to get around this I was going to make it threaded and have everything sitting in a thread pool. My question is if I create the principle outside the thread and pass the group principle to the thread...

Split a string on a string not a character

I want split a gridview row on an html tag. How can i do this preferably in C#?? e.row.cells[1].Text.Split("htmltag") Thanks in advance ...

How can I add a line break or html inside of a Panel?

I am trying to create a menu with the following code. But I cannot figure out how to get each LinkButton to appear on seperate lines. MenuPanel.Controls.Clear(); foreach (FormList f in forms) { if (f.IsActive == "y") { FormUserControl fc = (FormUserControl)LoadControl(f.StartControl); LinkButton lb = new LinkButton(); ...

How does Opera 10.50's custom UI work?

For the past two days i have been looking around the net to find how Opera made their pre-alpha build with that UI. I mean its like built with windows shell here are some screenshots any tutorials , books or videos would be helpful P.S. I also saw the win 7 SDK but its all C++ samples and i learn C# ...

Transactional objects in .NET

Hi! In user interfaces there is often a need to implement a cancel button when editing some entities. In WPF it would be nice if you could make your view model transactional. I will try to explain a little bit more in detail what I mean: The view model is connected to the model and exposes data in a way that's easier to handle for the ...

Self Tracking Entities (STE)'s and partial updates with EF4 and mVC2

I have an MVC2 app where I am starting to use the STE's. I am looking for some clarification on how updates should work. Background: If I have a Blog entity with related category entities and Related post/comment entities. In MVC I am rendering a view with the main Blog entity and the categories but not the related posts. When I pos...

Possible to capture POST request output to debug? (POST works from .NET tool, doesn't from perl/apache or curl)

Hi, need help with this. Basically, our web server A (apache/perl) has to send an XML to some external server B (IIS/.NET) using POST with xml as its body. The company which owns server B provided us with their own .NET tool that takes XML file and POSTs it to B and then displays B's response. The problem is that their tool works. But ...

Detect when users log out of an application in C#

If the application I'm working on, is there any way to tell when users press the Logout button? ...

Dynamically setting a log4net property using common.logging

Does anyone know if there is an equivalent in Common.Logging (for .Net) to set properties for the log4net factory adapter? I have had great success when just using log4net by doing: <appender name="FileAppender" type="log4net.Appender.RollingFileAppender"> <file type="log4net.Util.PatternString" value="logs\Log_%property{BrokerID}....

VS2008 targeting .NET 2.0 doesn't stop me from using C# 3 features

I had a VS2005 solution and wanted to get off VS2005 for the new year. I was mostly happy with the upgrade process and pleasantly surprised to see that my build scripts mostly still worked. My question is around the multi-targeting feature - I don't have .NET 3.5 installed on my servers, so I have to continue to target .NET 2.0. That ...

Linq Query not returning IEnumerable.

I have the follow Linq query that is in a web application that was converted from .NET 1.1 to 3.5: dim objListOfFilteredDataRows = from datarows as datarow in objDataSet.tables(0).rows _ where datarows("SomeColumn") = SomeValue I have the exact same query in an application that was created using .NET 3....

LINQ method for adding items to a dictionary

I'm trying to learn a bit more about LINQ by implementing Peter Norvig's spelling corrector in C#. The first part involves taking a large file of words (about 1 million) and putting it into a dictionary where the key is the word and the value is the number of occurrences. I'd normally do this like so: foreach (var word in allWords) ...

How to remove null DataMember properties from the response in wcf

I am returning the xml output to the browser with a wcf webservice, if a property of a DataContract is null, it still comes through in the response as <Id i:nil="true" /> Is there a way to have it not return in the response at all? ...

.NET Remoting - HttpChannel vs TcpChannel

I'm new to .NET Remoting and not very familiar with the different communication channels which can be used. I know there is HttpChannel and TcpChannel out of the box. I understand that one is Http while the other is Tcp, but I don't understand why Tcp is faster. ...

Item groups in msbuild

Hi, I have the following item group: <ItemGroup> <ReleaseFiles Include="MyApp\*.ashx"/> <ReleaseFiles Include="MyApp\*.config"/> <ReleaseFiles Include="MyApp\bin\*.dll"/> <ReleaseFiles Include="MyApp\bin\*.exe"/> <ReleaseFiles Include="MyApp\bin\*.pdb"/> <ReleaseFiles Include="MyApp\bin\*.config"/> </Item...