.net

Disable DataGridView System ContextMenu

Does anyone know how I can disable the System Context Menu when a user right clicks in a DataGridViewTextBoxCell? I have tried to override the WndProc at the DataGridView level (as there is no WndProc to override on the Cell level), but nothing seems to work. Any help would be greatly appreciated. The following is what I use to achie...

Why doesn't MSBuild copy as I would expect

I'm needing to script my build. I'm using MSBUILD because of it's integration with VS.net. I am trying to copy some files from the build environment to the deployment folder. I'm using the copy task of MSBuild. But instead of copying the directory tree as I would expect. it copies all the contents into a single folder. I repeat all the ...

.NET Assembly References Compile Time Errors

I have assembly A with class Z that inherits from class X in assembly B. Now in a completely different solution, I have assembly C, which uses class Z. The compiler complains unless assembly C has a reference to both assembly A & B. Even though assembly C does not use class Z directly in anyway. Is this expected? It seems to me that i...

Would you go back to VB.NET after getting C#?

I'd spent several years in the day job with VB.net. Out of work I'd flick between it and C# for different projects/hobbies. Now that the day job is almost fully C#, VB.net is starting to look foreign and a little removed. Does any beg to differ? Should I keep my delve back to VB.net for any particular scenarios? I mean, does it win ...

Multiple screens/monitors with Silverlight

I'd like to write a Silverlight app that has 2 or more browser windows that "interact". An example would be a parent/details display where selecting an item in the "Parent" list (in one browser window) will display the details of the item in another window. The main point is so that on a multiple-monitor setup the user could have t...

ASP.NET aspxerrorpath in URL

I have a site where I use CustomErrors in the web.config to specify a custom error page, and that's working just fine. The custom 404 page is also specified in the IIS configuration (because if it's not, I don't get my custom 404 page). But I have some logic that kicks in if a user gets a 404 that looks at their requested URL and make ...

Write Files to WPD device via MTP C#/VB.net

I would like to write an application that will copy MP3 files to a SanDisk Sansa M240. The SanDisk doesn't have a drive letter and uses MTP for file transfer. I stumbled through the sample of connecting to the device at : http://blogs.msdn.com/dimeby8/archive/2006/09/27/774259.aspx but once connected, I can't figure out how to actuall...

How is the .net Entity Framework overkill versus LinqToSql?

I've heard it said that the Entity Framework is overkill or that it's difficult to learn compared to LinqToSql. I am wondering in what way? I used LinqToSql and like it. So, I am trying the EF and for the things I'm doing they seem almost exactly the same. Namespaces and method names are different but so far I don't see anything that...

WPF: Eliminate transparency between grid cells.

I have a Grid in WPF. The Grid has a transparent background (necessary) and each of the cells potentially has a different colored solid background, or maybe no background. When I put arbitrary content in these cells, when two adjacent cells both have colored backgrounds (same or different color, it doesn't matter) there is often (and unp...

How do you bind data to multiple columns in a list view?

I have a datasource that I want to bind to a listview that has multiple columns. How do I bind my datasource to that listview Here is some pseudo code that doesn't work to help illustrate what I am trying to do: MyDataTable dt = GetDataSource(); ListView1.DataBindings.Add("Column1.Text", dt, "MyDBCol1"); ListView1.DataBindings.Add("Col...

How do I read/write an Encrypted XML file using LINQ to XML?

I would like to read/write encrypted XML files using LINQ to XML. Does anyone know how to use encryption algorithms built into the .NET Framework to encrypt the Stream used by the XDocument object? I did try it, but you can't set the CryptoStream to Read/Write access. It only support Read or Write, which causes LINQ to XML to throw an e...

How can I force .NET to use a local copy of an assembly that's in the GAC

I have a .NET assembly that (for reasons outside my control) must be in the GAC. However, the same assembly is used by another program, which has a its own copy of an older version of the same assembly. It must use its own copy and not whatever is in the GAC. Proper versioning is probably more hassle than it's worth in this case, for rea...

Why XML-Serializable class need a parameterless constructor

I'm writing code to do Xml serialization. With below function. public static string SerializeToXml(object obj) { XmlSerializer serializer = new XmlSerializer(obj.GetType()); using (StringWriter writer = new StringWriter()) { serializer.Serialize(writer, obj); return writer.ToString(); } } If the argumen...

parameterizedThreadstart

What is the difference between parameterizedThreadstart, Threadstart and Thread? ...

Java still relevant for web programming?

These days it seems to be all about .NET. I want to start getting into "enterprisey" development and I thought Java would be a good route to go. But looking at job sites there seems to be 2-3x more .NET jobs as there are Java. Do you think investing my time into .NET would be better than going after Java? Is Java losing ground to .NET? ...

C#: How can Dictionary<K,V> implement ICollection<KeyValuePair<K,V>> without having Add(KeyValuePair<K,V>)?

Looking at System.Collections.Generic.Dictionary<TKey, TValue>, it clearly implements ICollection<KeyValuePair<TKey, TValue>>, but doesn't have the required "void Add(KeyValuePair<TKey, TValue> item)" function. This can also be seen when trying to initialize a Dictionary like this: private const Dictionary<string, int> PropertyIDs = ne...

Creating a constant Dictionary in C#

What is the most efficient way to create a constant (never changes at runtime) mapping of strings to ints? I've tried using a const Dictionary, but that didn't work out. I could implement a immutable wrapper with appropriate semantics, but that still doesn't seem totally right. For those who have asked, I'm implementing IDataError...

How to create a numeric textbox in Silverlight?

As the title says really. I've had a look at inheriting from TextBox, but the only sensible override was "OnKeyDown", but that just gives me a key from the Key enum (with no way to use Char.IsNumeric()). ...

Dependencies and references - What exactly should I reference?

I am wondering what to include when building my project. I have a library I need to reference for my project to build but that library has 10 dependencies itself. Should I reference those dependencies as well or should I copy them to the output directory using a post build event? What is the best practice? I find it confusing to includ...

Why seal a class?

I'd like to hear what is the motivation behind the bulk of sealed classes in the .Net framework. What is the benefit of sealing a class? I cannot fathom how not allowing inheritance can be useful and most likely not the only one fighting these classes. So, why is the framework designed this way and wouldn't it be unbreaking change to u...