.net

How do I disable ALL .NET security policies?

I'm trying to replace a old homebrewed single threaded web server with a ASP.NET solution that will run on IIS. The old server does alot of weird stuff like access files outside it's path, do com calls, write to c: and much more. It does all of this from library writen in C++. In the new application we want to use the same library so we...

LINQ to SQL inserting large object from .NET

What is the fastest way to get a list object with a count of 100,000 records into SQL using LINQ to SQL? ...

Loading assemblies at run-time

My project is an application in which we load various assemblies and perform operations on them. We are stuck at a situation where we need to add a reference to the assembly we load (which will be selected by user). So I need to add a reference to the DLL at run time. I tried this site but here they support only microsoft DLLs like Sys...

WPF lost Databinding

Hello there, I'm new to WPF and its Databinding, but I stumbled upon a strange behaviour I could not resolve for myself. In a Dialog I've got a Listbox with Users and a TextBox for a username. Both are bound to a UserLogonLogic-which publishes among others a CurrentUser property. I want the TextBox to update its text when I click on a...

How to deny shutdown when pressing the power button for a while?

On most newer computers you can shutdown the hard way by pressing the power button for a couple of seconds. But I want to prevent this completely. You're able to prevent some soft events like the sleep, suspend, hibernate and "Press power button" events in Windows control panel; you can also use some Win32 and WDI programming to catch a...

Why doesn't my Windows Form get redrawn when the window is resized?

I have a simple Form such as the following: using System; using System.Drawing; using System.Windows.Forms; namespace PaintTest { class PaintTest : Form { int _counter = 0; [STAThread] static void Main() { Application.Run(new PaintTest()); } protected override void OnPaint(PaintEvent...

How do I prevent a keypress from updating a MaskedTextBox's text?

I need to validate characters entered by the user in a MaskedTextBox. Which characters are valid depends on those already entered. I've tried using IsInputChar and OnKeyPress, but whether I return false in IsInputChar or set e.Handled to true in OnKeyPress, the box's text is still set to the invalid value. How do I prevent a keypress ...

How can I force csc / mcs to use a specific version of an assembly reference?

I need to reference a specific version of a signed assembly. Because it is present in GAC, compiler picks up the 'vendor' version instead of the one I provide (the GAC version number is higher, even though it's an older API). Is there some kind of extension to the basic /reference=Library.dll compiler option that allows specyfing a stron...

.NET MVC - Global Settings Class - which of these methods is best:

OK so im trying to create a settings class to store certain strings that i need to access throughout the system. I have created a globalSettings.cs with the code below: public class GlobalSettings { private readonly Hashtable myHT; public GlobalSettings() { //Hashtable used to store global strings myHT = new...

How do you convert hex to decimal using VB.NET?

Need to convert Hex to a Decimal in VB.Net. Found several examples in C#, but when I tried to convert to VB.Net I was not successful. Here is an example of a hexidecimal number that I am trying to convert "A14152464C203230304232323020572F544947455234352E". Thanks, Dave ...

Is there a 3rd party .NET library/assembly that will parse & import files using a metadata-driven approach?

Hi, I need to parse a bunch of delimited flat files and import them into a database. I could build my own simple metadata-driven parser and importer but figure there must be something like this out there already? Thanks, Dave. ...

How to get next( previous) Enum Value in C#

I have got an enum which is defined like this: public enum eRat { A = 0, B=3, C=5, D=8 }; So given value eRat.B, I want to get the next one which is eRat.C The solution I see is (without range checking) Array a = Enum.GetValues(typeof(eRat)); int i=0 ; for (i = 0; i < a.GetLength(); i++) { if (a.GetValue(i) == eRat.B) ...

How do I reference configuration information from within multiple class libraries?

I've got a bunch of DLL projects that I'm pulling into my application, each contains their own Settings.settings/app.config. When I compile the app and run for debugging, everything works just fine, but come deployment time I can't get my DLLs to read their own settings files. I've been doing some reading and it has become apparent tha...

What should I consider when choosing a mocking framework for .Net

There are lots of mocking frameworks out there for .Net some of them have been superseded by others that are better in everyway. However that still leaves many mocking frameworks that have different styles of usage. The time it takes to learn all of them well enough to decide witch to use is unreasonable. I don’t believe that we have ...

Naming convention for controls

Microsoft has naming guidelines on their website (here). Also I have the Framework Design Guidelines book. What I could not find was a guideline about naming controls. For example a button, when dropped to a form, it gets the typename + number, camel-cased as default name, such as "button1". This is what I do: I delete the number and...

How do I create a logging HttpModule/Decorator for a .net web service?

I created a web service in .net 3.5, and now I would like to log all incoming calls to the service. The log should contain the name of the called method and the parameters passed to it. I have been looking into creating a hhtpmodule for this, but I am not sure how to extract the method name and parameter values from HttpApplication. An...

Session item comes back after being removed.

I remove an item from the session using Session.Remove(), then redirect to another page. If I click back, then reload, the item is suddenly back in the session. Shouldn't Session.Remove() take it out of the session for good? ...

Forms Authentication...

I've been programming for a long time now, but I'm not the world's most experienced.Net developer. I recently picked up a project that is using Forms authentication for their website. I first looked at forms authentication in .Net 1.1 and at that time it had some limitations that made me decide not to use it as my primary form of authe...

When publishing an ASP.NET application, should I change the build type to Release in the Visual Studio Configuration Manager?

For my production sites I usually change the "debug" flag in the Web.Config to "false". But I always publish my sites with the Configuration Manager set to "Debug". Should I change this setting too? ...

Which form controls to use for a chatbox (.net)

Hi, as I am doing a small chat application in vb.net (windows form), I'm having problem for the design of my chatbox. I would like text messages to be selectable so user can copy(ctrl+v) it but not usernames which displays who sent the message. What form controls should I use in order to accomplish this and what properties to change from...