.net

Create an int column in ListView (Winforms)

Hi, Is it possible to create an integer (or DataTime, etc) column in ListView? It is quite important, because I would like to properly sort the list according to this column. The only way to add subItems to a ListViewItem I found are: listviewitem.SubItems.Add("1"); I would like to avoid parsing these strings to get the int represen...

What is the best way to compare XML files for equality?

I'm using .NET 2.0, and a recent code change has invalidated my previous Assert.AreEqual call (which compared two strings of XML). Only one element of the XML is actually different in the new codebase, so my hope is that a comparison of all the other elements will give me the result I want. The comparison needs to be done programmatica...

In .NET, What is the Runtime Equivalent of my app.config Setting?

If I have the following setting in my app.config file. It is a setting I need to make sure my WCF client can negotiate the default proxy server. <system.net> <defaultProxy enabled="true" useDefaultCredentials="true"></defaultProxy> </system.net> Unfortunately, I can't add to the app.config file in my environment. How do I ensure...

What should go in a robust error message for debugging?

In addition to informing the user, we want to collect information for our debugging purposes. Our system is a niche system for only about 1400 customers, and therefore we are not as well-financed as we would hope, so bugs are more common than we would like. We currently have a window that shows the first line of the error message in la...

What's the most efficient way to locate and set element values in an XDocument?

Given the following XML 'template': <Request module="CRM" call="list_service_features" id="{ID}"> <block name="auth"> <a name="username" format="text">{USERNAME}</a> <a name="password" format="password">{PASSWORD}</a> <a name="client-id" format="counting">{CLIENT-ID}</a> </block> <a name="service-id" format="countin...

Is there a prevailing unit testing framework for the .NET Compact Framework?

I have plenty of experience with NUnit and MBUnit, but I'm new to .NET Compact Framework development and I'd like to get off on the right foot. Is there a prevailing unit testing framework for the .NET Compact Framework, and if so, what is it? ...

Getting name of file copied to clipboard from email attachment in VB.NET

If a user copies a file to the clipboard in Windows from an Outlook email attachment, is there any way I can get the name of that file in VB.NET? If the file is copied from Windows Explorer, Clipboard.GetFileDropList has data that I can use to get this, but that list is empty when the file is copied from an email attachment (there are ...

How should I set the default proxy to use default credentials?

The following code works for me: var webProxy = WebProxy.GetDefaultProxy(); webProxy.UseDefaultCredentials = true; WebRequest.DefaultWebProxy = webProxy; Unfortunately, WebProxy.GetDefaultProxy() is deprecated. What else should I be doing? (using app.config to set the defaultProxy settings is not allowed in my deployment) ...

How do I create a Generic Linked List?

I am trying to use a Generic Linked List to hold some WorkFlow steps in my application. Here is how I'm persisting it to my database. OrderID  WorkFlowStepID  ParentWorkFlowStepID 178373    1                         NULL 178373    2                         1 178373    3                         2 I get this dataset back in a datareader...

C# Generic and method

How can I select the good method (I have in the example below show 2 differents way that doesn't work). I was using instead of a variable of type Object with a IF and IS to do the job but I am trying to avoid using Object and boxing/unboxing. So I thought that Generic could do the job but I am stuck here. Here is a small snippet of cod...

Different answer when converting a Double to an Int - Java vs .Net

In C# if I want to convert a double (1.71472) to an int then I get the answer 2. If I do this in Java using intValue() method, I get 1 as the answer. Does Java round down on conversions? Why do the Java API docs have such scant information about their classes i.e. Returns the value of the specified number as an int. This may in...

Why do I need a mocking framework for my unittests?

Recently there has been quite some hype around all the different mocking frameworks in the .NET world. I still haven't quite grasped what is so great about them. It doesn't seem to be to hard to write the mocking objects I need myself. Especially with the help of Visual Studio I quickly can write a class that implements the interface I w...

.net 2.0 security configuration

Are there some help resources, or can anyone give me a brief Idea how I would configure the .net 2 runtime security policies for the following scenario: I have a windows forms control hosted in IE. The control tries to read from a serial port and write to the event log. Both of these operations fail due to security restrictions in the...

Constructor injection and default overloads

Let's say we have public interface ITimestampProvider { DateTime GetTimestamp(); } and a class which consumes it public class Timestamped { private ITimestampProvider _timestampProvider public Timestamped(ITimestampProvider timestampProvider) { // arg null check _timestampProvider = timestampProvider...

Initiate script in embedded browser from the container application

If I have an embedded browser in a windows form, is it possible to initiate a javascript method from the container application? ...

How to Include Multiple Javascript Files in .NET (Like they do in rails)

I'm jealous of the rails guys. They can do this: <%= javascript_include_tag "all_min" %> ... and I'm stuck doing this: <script src="/public/javascript/jquery/jquery.js" type="text/javascript"></script> <script src="/public/javascript/jquery/jquery.tablesorter.js" type="text/javascript"></script> <script src="/public/javascript/jquery...

On which Page life cycle are the Client IDs generated?

i am programatically adding Webcontrols in to a User Control i am also adding a javascript event passing the controlID as a parameter but the clientID is the one i assigned a it does not contain the one that asp.net generates var txt = new TextBox(); txt.ID = "MyID"+Number; chkBox.Attributes.Add("onClick", "EnableTxtBox('" +tx...

How do I build deployment project without un-signing my assemblies?

I'm not very experienced with builds - this may be really easy! I have a simple application with a simple deployment project. I went to the directory where the release-compiled versions of the DLLs are, signed all of them (verisign), and then went to the deployment project, chose Build (not REbuild), and it recompiled all my assemblies...

How do you get the UserName of the owner of a process?

I'm trying to get a list of processes currently owned by the current user (Environment.UserName). Unfortunately, the Process class doesn't have any way of getting the UserName of the user owning a process. How do you get the UserName of the user which is the owner of a process using the Process class so I can compare it to Environment.U...

Downsides to merging DLLs and EXE into single EXE file

I am developing a .NET application which uses a few projects that I've pieced together from other internal projects. I was thinking about merging the .exe and the DLLS into a single executable file with a tool called ILMerge. I may be sending the executable outside the company, so merging everything into a single file would be easier t...