.net

Method for Application Version on a Console Utility App

What is the best method for displaying major/minor versions in a C# console application? The System.Windows.Forms namespace includes a ProductVersion class that can be used to display the name/version information set via the Visual Studio project properties (Assembly Information). As such, here is my current mechanism: Console.Write...

'Run As...' doesn't correctly create user environment

My C# application crashes under some circumstances when run with a non-admin user. I'm experiencing a problem with Windows Server 2003 and I'm trying to find more information about it. It may be a problem on other Windows OS's. It seems that if I create a non-admin user, and then run my application under this user with the 'Run as...' ...

What is the C# Using block and why should I use it?

What is the purpose of the Using block in C#? How is it different from a local variable? ...

Unable to cast object of type 'System.Object[]' to 'MyObject[]', what gives?

Scenario: I'm currently writing a layer to abstract 3 similar webservices into one useable class. Each webservice exposes a set of objects that share commonality. I have created a set of intermediary objects which exploit the commonality. However in my layer I need to convert between the web service objects and my objects. I've used re...

What is the best reference for architecting Silverlight applications?

I'm curious if there are any texts that can be recommended that actually discuss application architecture best practices with respect to the use of Silverlight in web applications. ASP.Net would be preferable, but I'm open to consideration of other technologies also. ...

Has anyone used "DotNetRemoting" (the third-party product, not .NET Remoting) ?

DotNetRemoting They claim to have all the power of WCF but a lot simpler to implement and use. Does anyone here have any experience with using their product, and if so, have there been any problems with it? To clarify, this is a company's product called DotNetRemoting, not doing Remoting in .NET ...

How to automatically start your service after install?

How do you automatically start a service after running an install from a Visual Studio Setup Project? I just figured this one out and thought I would share the answer for the general good. Answer to follow. I am open to other and better ways of doing this. ...

Password hashing in a C# Windows app, absent ASP.NET's FormsAuthentication?

My Win form app doesn't seem to like FormsAuthentication, I'm totally new to hashing so any help to convert this would be very welcome. Thanks. //Write hash protected TextBox tbPassword; protected Literal liHashedPassword; { string strHashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(tbPassword.Text, "sha1"); ...

How to make a DataGridViewComboBoxColumn expand the dropdown to the left?

I've got a DataGridViewCobmoboxColumn that has to be on the far right side of the screen. The items in the cell are wider that the cell width, so the dropdown list is also wider than the cell, so the user can see what top select. When the list drops down, the right side of the dropdown is not visible, and thus the scroll bar is also not ...

How do the .NET Framework, CLR and Visual Studio version numbers relate to each other?

With the recent announcement of .NET 4.0 and Visual Studio 2010, it is becoming ever more difficult to keep track of what .NET Framework versions build on what version of the CLR and belong with which version(s) of Visual Studio. Is there a definative table that shows these relationships? ...

Lookng for a way to programmatically convert G729 audio to WAV PCM

I have G729 encoded audio files. I need to programmatically convert them to WAV PCM (16bit 8kHz mono) in the flow of a tool that is doing other thing too. I have an executable that will do that for me. But spawning that external process every time I convert is too heavy on resources. Especially if I need many of them being done in parall...

How to determine whether a Windows application is offscreen?

I am trying to debug a strange issue with users that have LogMeIn installed. After a few days, some of my dialogs that my app opens can end up offscreen. If I could reliable detect that, I could programmatically move the dialogs back where they are visible again. Note: this has to work for multiple monitors and use the win32 API. Howeve...

Manipulating the HTTP header in WCF before HTTP authentication in HttpBinding

This is in relation to this question I am hosting this WCF service in a custom service host. IIS is not an option. Is there a way to inject an HTTP "Authenticate" header in the server stack (if it's missing) early on in the request process - such that a default user can be passed into the authentication/authorization process that I ha...

ASP.NET 2.0 callbacks not working correctly in Firefox

I've implemented a .NET Web control that uses the callback structure implemented in ASP.Net 2.0. It's an autodropdown control, and it works correctly in IE 6.0/7.0 and Google Chrome. Here's the relevant callback function: function ReceiveServerData(args, context) { document.getElementById(context).style.zIndex = 300; document.getEleme...

Problem using the C# params keyword in a constructor using generic types.

I have a generic class in C# with 2 constructors: public Houses(params T[] InitialiseElements) {} public Houses(int Num, T DefaultValue) {} Constructing an object using int as the generic type and passing in two ints as arguments causes the 'incorrect' constructor to be called (from my point of view). E.g. Houses houses = new Houses(...

How do you pass an array of string through an event in an Interop User Control to vb6

I have a VB.net control that has an event: Public Event PassNames(ByVal names() as String) When the event triggered in VB6, I get the following error: "Function or interface marked as restriced, or the function uses an Automation type not supported in Visual Basic" Here is the event in VB6: Private Sub IteropControl1_PassNames(ByV...

How can I convert a SSL certificate from PEM to DER and keep the private key?

Backstory: I have a PKCS#12 (p12) certificate with a symmetric cipher (password) that I used OpenSSL to convert to a PEM; opening that as text I see it contains both a BEGIN/END CERTIFICATE section as well as BEGIN/END RSA PRIVATE KEY. The .NET Framework X509Certificate class only supports the "ASN.1 DER" format, so I used OpenSSL to co...

Can the working set of a managed app be reduced by unloading unmanaged libraries with AfxFreeLibrary?

I have a managed Windows application that loads a managed C++ component that uses AfxLoadLibrary to load a third party component if present on the client machine. Once detected, I'm unloading the component using AfxFreeLibrary in an attempt to lower the working set of the managed parent application. The call to AfxFreeLibrary is succ...

Cannot access a disposed object named "ParkingWindow"

I intermittently get this in error in my .NET 1.1 C# Windows Forms application. Someone indicated that this is due to a bug in the 1.1 framework and suggests putting the following code into any custom controls. protected override void OnParentChanged(EventArgs e) { if (this.Parent != null) { this.CreateParams.Parent = this.Pare...

WCF Security error with VS 2008 Unit Test

I am in my rookie season with WCF Services... I was running my first Visual Studio 2008 Unit Test with a WCF Service and I received the following error: Test method UnitTest.ServiceUnitTest.TestMyService threw exception: System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client au...