.net

Converting JPEG colorspace (Adobe RGB to sRGB) on Windows (.Net)

I need to generate thumbnail and medium sized images from large photos. These smaller photos are for display in an online gallery. Many of the photographers are submitting JPEG images using Adobe RGB. I would like to use sRGB for all thumbnails and medium size images I am using dotnet (asp.net) and need a way to convert from Adobe RG...

C# Datetime formatting

Hi, I want to know if there is already a build-in C# method that enables me quickly formate a US-culture date (07/22/2009) to '20090722' string. I am using .NET framework 2.0; Thanks!!! ...

Int32.TryParse() or (int?)command.ExecuteScalar()

I have a SQL query which returns only one field - an ID of type INT. And I have to use it as integer in C# code. Which way is faster and uses less memory? int id; if(Int32.TryParse(command.ExecuteScalar().ToString(), out id)) { // use id } or int? id = (int?)command.ExecuteScalar(); if(id.HasValue) { // use id.Value } or int...

Windows Forms WebBrowser Control and AJAX

Right now i am calling my function on webBrowser1_DocumentCompleted. It doesn't run correctly. However when i press button2 and call the very same func it does. It seems like my code needs some time for JavaScript and Ajax to run. When event should i call my code from? i dont want to click a button every time? ...

Is there a way to paint semi transparently on a PictureBox?

I use a transparent background for the PictureBox control. But I also want to be able to paint with a %50 opacity blue FillRectangle. How to do this? ...

How do I hide the username/password prompt that appears when a [WebMethod] gets called on an invalid session?

I have a .aspx with a static method decorated with the [WebMethod] attribute and a ScriptManager on the page, so that the WebMethod can be called with PageMethods.MethodName(). Forms authentication is enabled. This works well in all scenarios except where the WebMethod is invoked on an expired session. When that happens, the service re...

Regex that matches a newline (\n) in C#

OK, this one is driving me nuts.... I have a string that is formed thus: var newContent = string.Format("({0})\n{1}", stripped_content, reply) newContent will display like: (old text) new text I need a regular expression that strips away the text between parentheses with the parenthesis included AND the newline character. Th...

Setting the initial directory of an SaveFileDialog?

I'd like a SaveFileDialog with the following behavior: The first time you open it, it goes to "My Documents". Afterwards, it goes to the last selected folder. What's the best way to accomplish this? If I don't set the InitialDirectory, it goes to the exe's directory - which is not what I want. It rememebers the last selected director...

Was anyone thinking of 'CLR Server' instead 'SQL Server'?

I was thinking many times, now days that we have Linq and other CLR language-specific built-in search, sort and other capabilities over tables, collections and object, why not have the 'SQL Server' or rather call it 'CLR Server' (not only OOP Server but CLR 3.5) which will be a CLR (or COM) DLL that exposes the data allowing users linqin...

WPF Shell Drag Drop Sample - Unsafe Code

I have been considering using the code example shown at Shell Style Drag and Drop in .NET - Part 3 within a WPF project. The sample project works fine, it is a great article so check it out! However when moving the code to my project I receive an error when compiling "Unsafe code may only appear if compiling with /unsafe" I understa...

Determine if a type is static

Let's say I have a Type called type. I want to determine if I can do this with my type (without actually doing this to each type): If type is System.Windows.Point then I could do this: Point point1 = new Point(); However if type is System.Environment then this will not fly: Environment environment1 = new Environment(); //wrong So...

Getting mediafire directlink without using WebBrowser .NET control ?

I'm looking for the way to get the direct link from mediafire. By default, when a user visits a download link, he will be presented with a download page where he has to wait for the download to be processed and then a link will appear. I googled and found a VB.NET 2008 solution to this using WebBrowser WB http://www.vbforums.com/showth...

Npgsql reader type cast error (was: mono does not serialize complex types well)

Hi, Am I right that serializing complex types is not implemented in Mono 2.4.2 yet, or have I made a mistake? When I call my remote function, I get an error message: Cannot cast from source type to destination type. at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (System.Runtime.Remoting.Proxies.RealProxy rp, IMessa...

Enterprise library for .NET

Hello, what enterprise library are you using for your enterprise projects? beside Microsoft Enterprise Library? Thanks ...

C#: Check if a file is not locked and writable

Hi I want to check if a list of files is in use or not writable before I start replacing files. Sure I know that the time from the file-check and the file-copy there is a chance that one or more files is gonna to be locked by someone else but i handle those exceptions. I want to run this test before file copy because the complete list o...

How to inject an object into a WCF validator class

Following up on using dependency injection for WCF services, is there any way of using DI for WCF validators, so that one could do this: public class DIValidator : UserNamePasswordValidator { private readonly IService service; [Inject] public DIValidator(IService service) { this.service = service; } pub...

Best alternative for .NET nullable value type for Java-consumable service

We are creating some WCF services that will initially be consumed by .NET clients but in the future will be consumed to Java clients. As such we want to avoid using any data types in the interface that Java does not support. The specific one we know of is nullable value types. One suggestion is that we can support these by using a str...

How do I tell the designer that my custom winforms control has a fixed height?

I've made a custom control and overridden SetBoundsCore such that the height of the control is fixed. I'd like the designer to show the same sort of resize boxes as the NumericUpDown has - just one at each end - so that it's clear that the control has a fixed height. How do I tell the designer that my control has a fixed height? ...

How to insert programmatically a new line in an Excel cell in C#?

I'm using the Aspose library to create an Excel document. Somewhere in some cell I need to insert a new line between two parts of the text. I tried "\r\n" but it doesn't work, just displays two square symbols in cell. I can however press Alt+Enter to create a new line in that same cell. How do I insert a new line programmatically? ...

How to define custom TraceListener in app.config

I have implemented a custom trace listener (derived from TextWriteTraceListener) and now I would like to set my application to use it instead of standard TextWriteTraceListener. First I added default TextWriteTraceListener in order to make sure it works ok and it does. Here's my app.config: <configuration> <system.diagnostics> ...