.net

Security Exception Calling Shared Class Library from Windows Service

I know this is probably easy but I just don't know that much about .NET security so here goes: I have a VS2008 VB solution that contains 4 projects. Windows Service, Forms Application a Class Library and an install. The service installs fine and runs under the system account. However, as the service starts I call a method in the librar...

Custom scope for .NET application settings

I can define my custom scope: [AttributeUsage(AttributeTargets.Property)] public sealed class SiteScopedSettingAttribute : SettingAttribute { } How do I use it in the Visual Studio Settings editor (make it available in the "Scope" combobox)? ...

System.Net.WebClient vs. Proxy Authentication 407 error

I'm trying to figure out how to robustly handle proxy authentication errors (HTTP 407 status code) when using the System.Net.WebClient class. In the field, we see many users receiving a 407 proxy authentication WebException, but I'm not sure what a good default strategy is. In .Net 2.0/3.5, the proxy authentication settings are supp...

Is it possible to change the version format of a C# project?

Instead of the major.minor.build.revision format, I'd like to use date and time for version numbers. Something more like day.month.year.time. Is there a way to change the format of the AssemblyVersion attribute in AssemblyInfo.cs? ...

[.net] Floating point equivalence?

I want to be able to compare two doubles disregarding a possible precision loss. Is there a method already that handles this case? If not, is there a threshold/guideline to know how much is an adequate equivalence between two doubles? ...

How to avoid CommunicationObjectFaultedException when hosting a WCF service in IIS?

After creating a WCF Web Service for IIS and sucessfully testing it in my ASP.NET development server, when I deploy the service to another machine's IIS it always fire the following exception on consumption: Test method PoolingServiceTest.ProgramTest.MainTaskTest threw exception: System.ServiceModel.CommunicationObjectFaultedExcepti...

Select Multiple Fields from List in Linq

In ASP.NET C# I have a struct: public struct Data { public int item1; public int item2; public int category_id; public string category_name; } and I have a List of those. I want to select category_id and category_name, running a DISTINCT and finally an ORDERBY on category_name. Here's what I have now: List<Data> lis...

How can I get the shortcuts of a given WPF command?

Given a WPF Button with a Command, how can I get the assigned shortcut (ex Copy -> Ctrl + C) ...

"Chunked" MemoryStream

I'm looking for the implementation of MemoryStream which does not allocate memory as one big block, but rather a collection of chunks. I want to store a few GB of data in memory (64 bit) and avoid limitation of memory fragmentation. ...

The same GroupName for few instances of a UserControl

I have a number of own UserControls on a page. Each has the same type and a radio button inside. How can I force only one RadioButton to be checked? I did next: class myControl : UserControl { [Category("Settings")] public string GroupName { set { radio.GroupName = value; } } } but it doesn't helped. O...

How do I control dataGridViewColumn order for custom business objects?

Creating a custom business object to slide into a dataGridView works wonders... except I can't think of a programmatic way to set the column order. Do I have to add them one by one by hand manually again just to get a nicer sort or is there some cryptic hidden attribute I can use? ...

Targeting .NET 2.0 for a tiny app

I have a really small app that I put together in VS 2008 Express to try out .NET development for the first time. I want to send it to a couple of friends, however when I installed this on a second computer it went and downloaded the whole .NET 3.5 runtime, and I don't wish to force anyone to do this. My mistake as the default setting ta...

Importing csv file to datatable returns no results

This method does not throw an exception, neither does it return the rows from the csv file it reads into the DataTable. I am at a loss for what I am doing incorrectly. Any help is much appreciated. public string ImportCsvFile(string filePath) { FileInfo file = new FileInfo(filePath); //string connString = "Provider...

Oracle Error using c#

The error is : System.Data.OracleClient requires Oracle client software version 8.1.7 or greater. I'M using 8.1.7 Any help will be appreciated. ...

question on a simple indexer (c#)

in the following indexer code block, why do we need: public string this[int pos] { get { return myData[pos]; } set { myData[pos] = value; } } what exactly does "this" in this[int pos] do? Thanks /// Indexer Code Block starts here using System; /// <summary> /// A simple indexer example. //...

.Net - Read out current network interface throughput

Good evening, does anyone know a native/elegant way to read out the available network interfaces and their current througput (e.g. bytes/sec) in .net? Cheers & thanks, -Jörg ...

.NET app taking long time to show pages

I have a .NET web app that is taking a long time to load each page. I think there is network activity that is going on or calls to other sites. How can I track what network / internet activity is going on when the page is loading? Is there some utility that would allow me to trace activity? ...

How to copy a System.Drawing.Image value?

I am trying to copy an Image value to draw on it and on second draw ignore the last one and start over on top of the preserved Image value. I.e.: Image with 4 rectangle (ImageA) -> draw a circle return to ImageA -> draw a rectangle now there are 5 rectangles I don't know if it's the optimal way to draw too? ...

How to get assembly version of another project from app.config ?

I have two projects in a Visual Studio solution. I need an application setting in one of them to be the version number of the other project's assembly. I thought of adding to my project1's app.config something like: <setting name="currentVersion" serializeAs="String"> <value> !(bind.project2.Assembly.FileVersion) </value> </set...

Registering file type and custom document icon in .NET

I have application that produces files. I would like to connect those files with application so that double-click on file launches my application. Everything works properly except for annoyance that icon looks same like icon of my application. I would like to have one icon for application and one icon for it's documents. DefaultIcon va...