.net

ILockBytesOnHGlobal WriteAt performance decreases over time

I've created ILockBytesOnHGlobal and I write 64k of data repeatedly. What I've noticed is that WriteAt performance decreases over the time. What could be the reason for the performance slow down? Does it have to do with stream growth? Here is what I'm doing (in C#) public override void Write(byte[] buffer, int offset, int count) ...

Creating an IList<T> of Item<U>?

So I have an object, lets say Item<U>. I want to create a(n) (I)List<T> containing a collection of these items. The problem that I am running into is that the collection of Item<U> can have any number of different types for U in them. What I can not figure out is the signature to use for the IList. I tryed IList<Item<T>>, but because...

How do I actually replace a resources (.resx) file in a running application for a .Net DLL?

Here's my scenario: I have a .Net (3.5) DLL being referenced by an ASP.Net web application. One of the classes in the DLL has a .resx file containing an error message string that ultimately gets shown by the calling .aspx page. The DLL makes use of multiple namespaces, I've set the .resx file to the same namespace as the class that ca...

creating an ftp server

I am trying to create a ftp server in c#. This server should listen to any ftp requests, and if a file is sent from a remote location, then the server should write it to a specific folder. I am using VS2008. Do I need a tcp listener? FtpWebRequest? FtpWebResponse? ...

SQL Server Security Configuration Options for Windows Desktop Client/Server application

I am developing a windows desktop client/server application in .NET where the client application connects to SQL Server Express 2005 via the SQL native client and a connection string. The client then executes SQL over the connection on the database directly (no stored procedures). How can I configure SQL Server (or windows) security in...

How the JIT compiler decide when to initialize static constructors

Recently I have observed the following interesting scenario in one of the application I'm developing using .NET 3.5. In this particualr application I have a singletion object which I access as a static variable. I exepected that the .NET run time should initializes this singleton object at the very first time I access it, but it seems th...

C# Convert string from UTF-8 to ISO-8859-1 (Latin1) H

Hello, I know this has been asked before! I have googled on this topic and I have looked at every answer, but I still don't get it. Basically I need to convert UTF-8 string to ISO-8859-1 and I do it using following code: Encoding iso = Encoding.GetEncoding("ISO-8859-1"); Encoding utf8 = Encoding.UTF8; string msg = iso.GetString(utf8....

Setting a DatagridView row to have focus on Form Load

Hi, I have a dialog that containers a DataGridView, this dialog is opened from a parent Form. I would like the DataGridView to have focus as soon as the form is opened, so on pressing the down key would enable you to scroll down through the rows straight away. I have tried setting the tab index so that the DataGridView is the first s...

SOAP services calls from IIS 5.1 (XP) timing out.

We have an ASP.NET web application running in IIS that uses the SoapHttpClientProtocol class to make SOAP calls. In the last few days several XP machines have started to report timeout errors when making SOAP services calls. Stack Trace from a test app: System.Net.WebException: The operation has timed out at System.Web.Services.Prot...

How do I install .NET 2.0 SP2 without .NET 3.5 SP1 on Windows Vista?

We recently added a feature to our software that requires .NET 2.0 SP2. This is not a problem on Windows XP or Windows Server 2003 since we can just include the redistributable for .NET 2.0 SP2 in our installation. On Windows Vista and later, .NET is more tightly integrated into the OS (I'm not sure exactly how), and there doesn't appear...

using securestring for a sql connection

Hi, I want to use a SecureString to hold a connection string for a database. But as soon as I set the SqlConnection object's ConnectionString property to the value of the securestring surely it will become visible to any other application that is able to read my application's memory? I have made the following assumptions: a) I am not ...

Friend WithEvents in VB vs private in C#

Hello, friends Who knows, why in vb.net WinForm projects the designer by default use the Friend WithEvents attributes and in C# - private ones. By ex, in a form.designer. .cs private Label Label1; .vb Friend WithEvents Label1 as Label; For WithEvents is more or less clear(for using Handles, apparently). But why Friend in VB and ...

Transparent web browser in user control in .NET

Hi I have a rather tricky one (at least for me), which I have spent a lot of time trying to figure out. I have a C# winform application. In the application I need to present multiple web pages on top of each other with a transparent color allowing me to stack the web pages on top of each other. I can easily do that by letting the web p...

Can I detect whether I've been given a new object as a parameter?

Short Version For those who don't have the time to read my reasoning for this question below: Is there any way to enforce a policy of "new objects only" or "existing objects only" for a method's parameters? Long Version There are plenty of methods which take objects as parameters, and it doesn't matter whether the method has the obje...

Why do I have to pass an empty namespace to XPathNavigator.GetAttribute?

Given the following XML markup: <root xmlns="Demo"> <child name="foo"/> </root> and an XPathNavigator positioned on the <child> element, string withNs = navigator.GetAttribute("name", navigator.NamespaceURI); string withoutNs = navigator.GetAttribute("name", ""); produce strange results: withNs is empty, withoutNs contains foo....

.NET - how does IndexOf work if I don't implement IComparable in my class?

I have a collection of custom object, and I am doing IndexOf to find the index of a specific object. I would assume that the IndexOf would use IComparable implementation to check to see if the objects match, but I am not implementing it in my class. How does IndexOf determine that two objects are equal? Thanks! ...

Setting external application focus

Question: In VB.net, you can set focus to an external application using AppActivate("Windows Name") or AppActivate(processID as integer) Now this works fine if you do for example: Dim intNotePad As Integer = Shell("C:\WINNT\Notepad.exe", AppWinStyle.MinimizedNoFocus) AppActivate(intNotePad) But when I do For Each theproce...

Is this a bug in the static contract checker?

If I write this: public sealed class Foo { private int count; private object owner; private void Bar() { Contract.Requires(count > 0); Contract.Ensures(owner == null || count > 0); if (count == 1) owner = null; --count; } } The static contract checker can prove all asser...

SQL Query to calculate weight or distribute weight based on value/null

I have a table with columns - id, x1, x2, x3,x4 if i have values 1,y,y,y,y 2,y,null,n,null 3,y,null,null,null then say, i want to calculate (1)/(number of y's) and display rows as 1,.25,.25,.25,.25 2,1,0,0,0 3,1,0,0,0 Is it possible to do this using sql query? ...

Does Interlocked.CompareExchange(double,double,double) work in 32 bit OS?

I'm maintaining a high performance class that can be operated on by multiple threads. Many of the fields are volatile ints, and as it turns out I need to upgrade one of those to a double. I'm curious if there is a lock free way to do this, and was wondering if the Interlocked.CompareExchange(double, double, double) works as advertised ...