.net

Error in creating windows handle

Hi , I have created a .net 2.0 windows application. This application creates form controls dynamically. Now when I am trying to run the application, it is throwing an exception "Error in creating windows handle". After this, application gets hang and nothing happens. At the first time, form gets displayed properly. On a particular event ...

Issue in resizeing an image to thumbnail size

hi. i have an image where i am resizing the image into thumbnail size it works fine if i am using an image size[700(width)* 600(height)] orignal size lets say i have 10 images of theis size but if i use an image around size[1100*1200] orignal size it resize the image into thumbnail but doesnot match the size of...

.net 3.5: To read connectionstring from app.config?

How to read connection string info from app.config file using .net api? Platform is .net 3.5 <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add connectionString="" providerName="" name=""/> </connectionStrings> </configuration> ...

The speed of .NET in numerical computing

In my experience, .net is 2 to 3 times slower than native code. (I implemented L-BFGS for multivariate optimization). I have traced the ads on stackoverflow to http://www.centerspace.net/products/ the speed is really amazing, the speed is close to native code. How can they do that? They said that: Q. Is NMath "pure" .NET? A. The ans...

Parsing SAP IDOC files

Hi, We are currently planning on communicating with a partner that is running SAP. The problem is that our ERP offers no way of communicating with SAP and we will need to extract the necessary info out of the IDOC files ourselves. Is there an easy way of doing this in .NET? Like a library (free/commercial) that does all the grunt work?...

How to get namespace of executing STATIC function ?

Hi All, In an instance method, I can easily find the executing namespace: public void PrintNamespace() { Console.WriteLine(this.GetType().Namespace); } Q: How do I do the same in a static function (no this available) without explicitely mentioning the class name? (no typeof(MyClass) ) ...

Corrupt files when debugging into .NET framework

When debugging into the .NET framework using Visual Studio 2008 Professional, the source files appear corrupted somehow, and the yellow debug line doens't hit the correct lines in the source. For example, a source file might start like this: // Copyright (c) Microsoft Corporation. All rights reserved. namespace System.Web.Mvc { ...

What strategy should be used for converting real world measurements to WPF units?

We have an application that will be reading real world dimensions from the DB in milimetres, these values will then be presented to the user in WPF. Currently I'm using the following strategy when reading objects from the data store by multiplying MilimetresPrWpfUnit in the following example. public const double MilimetresPerInch = 25.4...

How to simulate a "Func<(Of <(TResult>)>) Delegate" in .NET Framework 2.0?

I try to use the class from this CodeProject article in VB.NET and with .NET Framework 2.0. Everything seem to compile except this line Private _workerFunction As Func(Of TResult) and the method header Public Sub New(ByVal worker As Func(Of TResult)). I can find on MSDN that these new delegates (Func(Of ...) are supported from .NET 3.5...

Is there a better way to implment Equals for object with lots of fields?

see also Hows to quick check if data transfer two objects have equal properties in C#? I have lot of Data Transfer Objects (DTO) that each contains lots of simple fields. I need to implement Equals on all of them (so I can write some unit tests off transporting them var WCF). The code I am using is: public override bool Equal...

Increase the session timeout of my web form ?

I need to increase session timeout of my web use form ... could anyone please help ? ...

PowerShell: an elegant way to create closures

Keith Hill explained me that blocks in PowerShell are not closures and that to create closures from blocks I have to call method .GetNewClosure(). Is there any elegant way to create closures from blocks? (e.g. create a wrapping function, an alias?, ...) Example: { block } ${ closure } # ??? ...

Copy/Paste in windows forms with custom controls

I am writing a small app in C# using windows forms. I want to let my users copy and paste data around the app and there are some custom controls, for example one is a colour picker. Some of the default controls (well at least the TextBox) have a copy and paste functionality already. I want to have the same thing with my colour picker, a...

Replace System.Net.Mail.MailMessage with manually created message and send it

I am trying to send emails that will bounce to a known mailbox. I plan to use VERP. Unfortunately the System.Net.Mail.MailMessage object does not allow me to precisely set the From: and Sender: headers within my email - it forces the values so that the resulting email contains the phrase 'on behalf of', and does not allow me fine contr...

Generate several megabytes of of random data in C#

I'd like to know a good way to generate several megabytes of random data using C# on Windows (using .NET 2.0 for deployment, but other approaches using other options such as .NET 3.0 and Mono libraries would also be of some interest). The purpose of the data is to transmit over a network connection, to evaluate real world network throug...

How structure whole applications in Visual Studio?

Example I work on project, which have 3 separate parts (ASP.NET MVC, WinForms, Silverlight) and 15 project (Common, Api, Services, Repository and WinForm's CABs). Resolutions 1) All this project in one solution 2) For each part have solution What is the best way to deal with Solutions and Projects in Visual Studio? First is great if...

Managed (.NET) Subversion Server

I'm perfectly aware that there are lots of client libraries to connect to an SVN repo, manage working copies, etc. What I'm looking for, though, is an implementation of Subversion server for .NET (or a wrapper around some low-level code). Are there any or I'm asking for something unreasonable (well, sure I do, since I understand how muc...

creating a dropdown with customized options

Situation: There is a page with 2 dropdowns. On clicking the first drop down, you get a list of companies. After selecting a company, the second dropdown, labelled Comapany's Project, should automatically customise its list to the list of projects associated with the selected company. How can the second drop down be achieved? ...

ejecting cdrom in .net

hi all. using this code: public class DvdRomUtility { [DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi)] protected static extern int mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, IntPtr hwndCallback); public static void Open(string driveNa...

Does Math.Round(double, decimal) always return consistent results.

Of course one should never compare floating point values that result from a calculation for equality, but always use a small tolerance, e.g.: double value1 = ... double value2 = ... if (Math.Abs(value1 - value2) < tolerance * Math.Abs(value1)) { ... values are close enough } But if I use Math.Round can I always be sure that the r...