.net

Why does .NET warn for 'Unused Variables' but not 'unused parameter'?

Why does .NET warn for 'Unused Variables' but not 'unused parameter'? (I believe Java warns in both cases.) Why doesn't .NET care about 'unused parameters'? ...

Can I send / receive window messages without a window?

I'm writing a .NET wrapper around an old MFC-based library we have. It's based around a class that sends notifications using window messages; it has a function that lets the user pass in a handle to a window, and that window will receive the messages. I could just require the users of my wrapper to subclass Control and pass their contr...

Using StackPanel as ContentControl (WPF)

So I have a StackPanel that I am using as a ContentControl. I have a place where I want buttons to be generated based on data that I am binding to, and that is all working good, but I want the buttons to be laid out horizontally, not vertically as is what is currently happening. Here's a screenshot: And here is the code from my Cont...

.Net Console Application that Doesn't Bring up a Console

I have a console application I'm using to run scheduled jobs through windows scheduler. All the communication to/from the application is in email, event logging, database logs. Is there any way I can suppress the console window from coming up? ...

WCF throws FileNotFound exception for "System.ServiceModel" when creating ServiceHost.

I'm running into a really strange problem with WCF. I have 2 projects in a solution, each of them starts up some self-hosted WCF services. Project 1: myService = new ServiceHost(typeof(MyService1)); Which runs fine. However, when I try to run my 2nd project, which contains: meService = new ServiceHost(typeof(MyOtherService)); I g...

ASP.NET Membership passwordStrengthRegularExpression and GeneratePassword

The generatePassword method in the asp.net membership provider allows only length and alphanumeric characters to be set. However there is also the property passwordStrengthRegularExpression Does GeneratePassword makes use of the property above. It would be great if it did but I assume it dosn't? ...

Forwarding/relaying .NET events

My class has an event which external objects will subscribe to: public event EventHandler<MessageReceivedEventArgs> MessageReceived; However, an internal Listener object, running on it's own thread, will actually be originating the event. private class Listener { public void Run() { // events raised here which should...

how do I display a custom form windows workflow custom activity

Is it possible to show a windows form when implementing a custom activity? For instance, how do I show a custom form, when a user double-clicks on my activity in the designer? Or perhaps a custom form could be displayed when a user clicks the ... in the properties selection. ...

UpdateCellValue() in a Datagridview

I'm using the following code to update a DataGridView's cell value. This is called inside the 'CellDoubleClick' event handler for the DataGridView. The problem is the cell only updates after I click onto another cell. Is there a better way of doing this? string value = ""; if (_dataGrid1.CurrentRow.Cells[e.ColumnIndex].Value != null) ...

How to emulate a windows mobile device that use Scanner (Symbol.Barcode) ?

Hi Is there any way to emulate a Barcode scaning? My application runs on a Motorola MC9090 Windows mobile device that have Scanner. I'm using Symbol.Barcode class to create my application in .net c#. thank's in advance ...

NHibernate Reflection Optimizer - what does it do?

I've found initializing my session factory is massively quicker whenever I disable the nhibernate reflection optimizer. This is great for testing purposes. <add key="hibernate.use_reflection_optimizer" value="false" /> My question is what is the knock-on effect of doing this, and why isn't it the default setting? Everything seems to...

Convert User Controls to Server Controls.

I'm wondering if anyone has any experience converting User controls to Web controls? Ideally, I'd like to offload some of the design work to others, who would give me nicely laid out User Controls. Then, I could go through the process of converting, compiling, testing and deploying. Until MS comes up with the magic "Convert to Serve...

Dropdown list and gridview row-index/selectedvalue issue.

I have a gridview with a dropdown list that was created programmatcially. I want to have access to the selected value and to that row's Id. I have the dropdownlist created in *Gridview_RowDataBound* and I am able to use the text in the cell but my addHandler is never fired. Where do I give it the Add handler. I believe I can assign it ...

.NET enumerations of symbolic constants for string values

I have a list of rather meaningless codes that I'm processing with a VB.NET Windows application. For the business logic I'm writing to process those codes, I'd like to use meaningful constants (like ServiceNotCovered or MemberNotEligible) instead of the original codes (like "SNCV" and "MNEL"). As far as I can tell, Enums can only map to...

How do I create a message-only window from windows forms?

I'm trying to create a message-only window to receive window messages from an MFC library class, within a winforms application. I've tried subclassing NativeWindow, and in the constructor requesting a window handle like this: CreateParams cp = new CreateParams(); cp.Parent = (IntPtr)HWND_MESSAGE; this.CreateHandle(cp); but I get a Wi...

What's the difference between SortedList and SortedDictionary?

Maybe a silly question, but is there any real practical difference between a SortedList and a SortedDictionary? Are there any circumstances where you would specifically use one and not the other? ...

How to have all .Net dlls loaded via Wow64 on a 64 bit machine

I have a 64-bit machine and a bunch of .Net binaries compiled as Any CPU. By default they all get loaded as 64-bit. I thought I remembered a way to set a machine level flag so that all the Any CPU .Net dlls would be treated as 32-bit and not 64-bit by deafult, but I can't seem to find it again. Can someone please point me in the right...

Possible to call C++ code from C#?

Hi, is it possible to call C++ code, possibly compiled as a code library file (.dll), from within a .NET language such as C#? Specifically, C++ code such as the RakNet networking library Would really appreciate it if anyone could give me some pointers on how to do this/point me in the general direction to get started doing this and I ...

Hash codes for immutable types

Are there any considerations for immutable types regarding hash codes? Should I generate it once, in the constructor? How would you make it clear that the hash code is fixed? Should I? If so, is it better to use a property called HashCode, instead of GetHashCode method? Would there be any drawback to it? (Considering both would work, b...

How to emit bare XML for a [WebGet] method in WCF?

How can I define a [OperationContract] [WebGet] method to return XML that is stored in a string, without HTML encoding the string? The application is using WCF service to return XML/XHTML content which has been stored as a string. The XML does not correspond to any specific class via [DataContract]. It is meant to be consumed by an XSL...