.net

Marshal.AllocHGlobal VS Marshal.AllocCoTaskMem, Marshal.SizeOf VS sizeof()

Hi. I have the following struct: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct WAVEHDR { internal IntPtr lpData; // pointer to locked data buffer internal uint dwBufferLength; // length of data buffer internal uint dwBytesRecorded; // used for input only internal IntPtr dwUser; // for c...

disable the default Enter/Return key behavior in a datagridview

In vb.net datagridview the default Enter/Return key behavior is to move to the next row is there a quick and easy way to avoid that. Any suggestions are welcome ...

How to properly dispose of a WebResponse instance?

Normally, one writes code something like this to download some data using a WebRequest. using(WebResponse resp = request.GetResponse()) // WebRequest request... using(Stream str = resp.GetResponseStream()) ; // do something with the stream str Now if a WebException is thrown, the WebException has a reference to the WebResp...

Is there any way to decorate a class with attributes through the configuration file?

In WCF some of the settings are written as class attributes. I would like to set them in the configuration file instead. Examples [OperationContract(IsOneWay = true)] [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)] Is there any way to do this? Maybe with MicroKernel/...

Why is string.Empty more efficient than "" in .Net

I am certain that string.Empty is more efficient than using "" in .Net languages. What I would like to know is WHY is it more efficient? ...

Reading binary data using MarshalAs and StructLayout

Hi all, I'm stuck on this one. I'm reading a binary file which has te following format: Field name Size in bytes Example ------------------------------------- Date 19 1998_12_22 PM 20:15 Serial 4 0001 Using the following struct and using the answers to this question I'm trying to read ...

get CheckedItems from checkedlistbox

hi i have checkedlistbox which is bounded to a datasource as foloowing : chListBox.DataSource = dsContacts.Tables["Contacts"]; chListBox.DisplayMember = "FullName"; chListBox.ValueMember = "ContactNumber"; i want to get checkeditems collection by following code , but 'Unable to cast object of type 'System.Data.DataRowVi...

WCF client calling a Java webservice

I have a small issue logging in with a webservice being hosted using HTML with basic authentication. I have tried the following but it does not work. Are there any restrictions or gotchas on this? var client = new WSClient(); client.ClientCredentials.UserName.UserName = "xxx"; client.ClientCredentials.U...

QuickWatch-like control for .NET WinForms?

Visual Studio QuickWatch window has a hierarchical property grid control. Is a control like that available somewhere? The default property grid control doesn't seem to work for me as it requires the objects to have an ExpandableConverter attribute to work the way I want. Although, if any of you know a way to turn the property grid into ...

Application structure using WCF

I have a WPF application which so far has been client only, but now I'm working on splitting it into a client and server side. In this work I'm introducing WCF for the client-server communication. My application has several projects, and service references are needed from more than one of these. Initial effort in doing the separation i...

C# error1:The name 'DateTimeStyles' does not exist in the current context ..... error2:The type or namespace name 'CultureInfo' could not be found (are you missing a using directive or an assembly reference?)

Hi I have searched google my best but couldn't recover from these errors .. can you please help me out with, if something I have missed .. Here is my code .. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Globalization; using System.Security.Permissions; using System.Threading; names...

Detecting browsers installed so Process.Start("chrome") won't error

I'm trying to let the user choose the browser my application uses to launch urls. Currently it uses the default browser, but some people want to specify a different browser. I'd like to show only installed browsers in the list, and I'm launching them like this: Process.Start("chrome", url); The problem is, if Chrome isn't installed (a...

How call .NET command prompt

How to call .NET command prompt from Aspx to Build/Publish another windows application. I have a windows application, that I want to build via my web application (aspx). How can I do that? ...

Why the toolbar button icon is grey at runtime?

I"m setting the icon of a toolbar button (using Infragistics component library for the toolbar), The problem is that on design time the icon is showing normally. But at runtime the icon become greyed, though the drawing of the icon is still apparent, but its colors are all lost and the shape of the icon image is grey. So i'm wondering if...

PostSharp: OnMethodBoundaryAspect on derived class's constructor

Hi I have an aspect that writes something to the console on exception. I have a base class that throws an exception on its constructor, and a derived class that have the aspect on its constructor. I would expect that the derived class aspect on constructor will catch the base class exception, but it dont. Is this by design? Is this a ...

if session expires whether the viewstate remains ?

i have set the session timeout to 20 minutes in IIS level and there is no session entries in the web.config. How can i know whether my session exprired in my website? does the state will maintain ? do i can see the values in the text-boxes after the timeout? ...

.NET Equivalant for INET_NTOA and INET_ATON

Any C#/.Net equivalent methods, or managed code examples for INET_NTOA and INET_ATON? ...

How can a code identify if it is being called by windows application or web application.

I am developing a .net component. Is there any foolproof way of identifying whether a web application or a windows application is calling it? ...

encode string to utf8

Hi, How can easily encode a string to utf8 using .NET (VB or C#)? For instance I need to encode a string like "This (is) my string" the result should be a string "This+%28is%29+my+string". TIA JP ...

HashTable Insert Failed. Load Factor Too High. .NET 2.0 SP2

We've just encountered this error on our web app, and immediately found the article here http://stackoverflow.com/questions/505322/hashtable-insert-failed-load-factor-too-high-asp-net-2-0. However, the hotfix that this points to (http://support.microsoft.com/?id=927579) was already included in .NET 2.0 SP1 (http://support.microsoft.com/...