.net

C#, how to restrict to one method call at a time?

I'd like to know how to implement the following restriction: One method in my Windows Service should not be called again before the earlier call has been finished. The method in question goes thru couple of database tables and it's very important that this process won't be called again before it's finished. I have a setting that defines...

Change Properties.settings for a .net deployed application

Hi All, I have two .net applications, these applications want to talk to each other, I made a setting in the first project as follows [CompilerGeneratedAttribute()] [GeneratedCodeAttribute("SettingsSingleFileGenerator", "9.0.0.0")] public sealed partial class Settings :ApplicationSettingsBase { [UserScopedSettingAttribute()]...

How would you force the System.Net.Socket.Connect() method to use a socks proxy (code injection vs external custom proxy)

I'm using WCF's netTcpBinding, which connects directly to an endpoint and doesn't seems to know anything about socks proxies. I need to use a proxy because most of my clients won't allow direct outbound connections, and enforce the use of socks proxies at all times. My first idea was to configure the .net framework to do that, so I ed...

In NAnt, can I create a fileset of the files listed in a VS project?

I'm rewriting our NAnt build scripts to make them cleaner and simpler, as well as more general purpose. One of the steps in our build process is to package certain files into a zip file. Before we had created a fileset with lots of included file types, trying to catch everything that might be in the project. This occasionally caused...

Visual Xml to .net object mapper

Hi guys: I have to export my data, practically the entire domain model structure into a formal xml file. Does anyone know a visual tool that I can use to map an xml schema to my .NET object model? ...

Is there a function that returns the root letter for special chars?

Hi guys, in .NET is there a function that returns the root letter (the letter without special attributes like cedilla), kinda: Select Case c Case "á", "à", "ã", "â", "ä", "ª" : x = "a" Case "é", "è", "ê", "ë" : x = "e" Case "í", "ì", "î", "ï" : x = "i" Case "ó", "ò", "õ", "ô", "ö", "º" : x = "o" Case "ú", "ù", "û", "ü" : x = ...

WCF UserName Authentication: Can I get the Username in a custom ServiceAuthorizationManager?

I have a WCF service that is using a custom ServiceAuthorizationManager. The custom auth manager is already set up to handle Windows and Forms authentication. However, if I connect with a client that is set to UserName auth, I can't seem to find the username anywhere. The client code looks like this: this.ClientCredentials.UserName.Us...

How can i remove item from querystring in asp.net using c# ?

Hi, I want remove "Language" querystring from my url. How can i do this ? (using Asp.net 3.5 , c#) Default.aspx?Agent=10&Language=2 I want to remove "Language=2", but language would be the first,middle or last. so i will have this Default.aspx?Agent=20 ...

.NET WinForms and the enterprise library validation application block

I have a TextBox whose value is passed to an int property in an object after being parsed to an int. When I use a ValidationProvider this conversion step is ignored when validating and I get an error telling me that I cannot save the string to an int32. I can fix this by creating a string property in my object that acts as a bridge bet...

Load CSS In Excel

Hi, in .net I have created an excel report which takes a datagrid's render output and puts it into the excel. The problem I am having is that the CSS classes that are used in the datagrid are not properly displayed because the CSS file is not loaded on the excel document. Can someone recommend a good way to go around this other than in...

Linq + NHibernate: is it production ready?

Is Linq + NHibernate production ready? I hear many folks using it in production code but it is still officialy 'Alpha'. It has been a long time, however, so what's your experience? ...

How do I redirect with a Drop Down List, and not a Button?

I am looking into using only a ddl to run my query, not a ddl and a Button_Click function. I am yet to find what to do. How do I do this? ...

Choosing the default value of an Enum type without having to change values

In C#, is it possible to decorate an Enum type with an attribute or do something else to specify what the default value should be, without having the change the values? The numbers required might be set in stone for whatever reason, and it'd be handy to still have control over the default. enum Orientation { None = -1, North = 0...

Is there a good "RichString" class out there?

I'm looking for a class/API that allows you to create and manipulate RichText strings (rtf format) for use with the RichTextbox -like controls. I'm thinking of something like StringBuilder, but that also allows you to specify formatting as you append to it and also go back and edit previously appended segments, as well as doing string...

Using Bitwise operators on flags

I have four flags Current = 0x1 Past = 0x2 Future = 0x4 All = 0x7 Say I receive the two flags Past and Future (setFlags(PAST | FUTURE)). How can I tell if Past is in it? Likewise how can I tell that Current is not in it? That way I don't have to test for every possible combination. ...

How to avoid System.IO.PathTooLongException?

We constantly run into this problem... Example: if I have a file that I want to copy it into an another directory or UNC share and if the length of the path exceeds 248 (if I am not mistaken), then it throws PathTooLongException. Is there any workaround to this problem? PS: Is there any registry setting to set this path to a longer c...

Can .NET PInvoke dynamically load a native dll from a user specified directory?

I have a .NET application and need to load a native library whose location is specified by the user. PInvoke looks like it'll only load from the global search paths (or a path specified at compile time?). Would the best method be to create a C++/CLI assembly which calls LoadLibrary at runtime? Would C++/CLI be simpler than C# PInvokin...

Version number in .net compact framework application

I need to display the version number on the screen. I am using .net CF 2.0 with WinCE 4.0 So far, I have been ignoring the version number completely. Do I need to add anything to the assembly? how do I retrieve it programmatically? Thanks! ...

How do you prevent the Visual Studio designer auto-generating columns in a DataGridView?

I generate all my columns in a subclassed DataGridView programmatically. However Visual Studio 2008 keeps reading my constructor class (which populates a DataTable with empty content and binds it to the DataGridView) and generates code for the columns in the InitializeComponent method - in the process setting AutoGenerateColumns to false...

Creating a blocking Queue<T> in .NET?

I have a scenario where I have multiple threads adding to a queue and multiple threads reading from the same queue. If the queue reaches a specific size all threads that are filling the queue will be blocked on add until an item is removed from the queue. The solution below is what I am using right now and my question is: How can this b...