.net

SQL Server Database Restore Hourly

Hi I run a software platform and am thinking of setting up a demo site so that people can login into a pretend site and edit the data, etc... However I want then the database to 'reset' every 'x hours / days' is there a way sql server can do this itself? Otherwise I will have to code an application to restore all the table data and th...

C#.NET - Determine if PPT is in Slideshow

I am trying to create a PowerPoint add-in using C# and a 3rd-party SDK/API to enable wireless voting/message retrieval during a PowerPoint presentation. Is there any way that I can determine whether or not the user has hit 'F5' or selected 'Start Slideshow', because I obviously do not want the program executing while the user is editing...

Best practices: throwing exceptions from properties

When is it appropriate to throw an exception from within a property getter or setter? When is it not appropriate? Why? Links to external documents on the subject would be helpful... Google turned up surprisingly little. ...

Why does BinaryWriter prepend gibberish to the start of a stream? How do you avoid it?

I'm debugging some issues with writing pieces of an object to a file and I've gotten down to the base case of just opening the file and writing "TEST" in it. I'm doing this by something like: static FileStream fs; static BinaryWriter w; fs = new FileStream(filename, FileMode.Create); w = new BinaryWriter(fs); w.Write("test"); w.Close...

How do I make a windows service installer from visual studio 2008?

How do I make a windows service installer from visual studio 2008? ...

Add extra items to a cookie and grab them? Asp.net MVC C#

Hi When checking for a users role in my custom authorize tag I am going to need a 3rd value. Like the built in stuff allows for this "filterContext.HttpContext.User.Identity.Name;" But this won't work for me since I will have many users with the same name. So I don't think this will help me when I have 10 with the same name and I hav...

.Net WinForm System Beep on a 64 Bit OS

My application needs to beep when validation fails so the user (who may be several feet away) may hear it. I'd like to use the Console.Beep() but this is unavailable in a x64 environment (see the remarks). There may or may not be speakers in/at the computer, so I can't use System.Media.SystemSounds.Beep.Play(). The current target platf...

DataTrigger on Enums as the trigger value on a WPF Style

So here's what I'm trying to do in a little nutshell, I'm just gonna start with code and it will most likely make sense. <bl:InnerGlowBorder x:Name="glow" InnerGlowColor="Teal"> <bl:InnerGlowBorder.Style> <Style TargetType="bl:InnerGlowBorder"> <Style.Triggers> <Da...

Why do ListBox.ObjectCollection and ListView.ListViewItemCollection have AddRange but not InsertRange or RemoveRange?

So, both ListBox.ObjectCollection and ListView.ListViewItemCollection implement the IList class, which provides Add and Remove methods but no AddRange, InsertRange, or RemoveRange. However, ListBox.ObjectCollection and ListView.ListViewItemCollection also provide an AddRange method -- just no InsertRange or RemoveRange. Look at the Arra...

How small do methods have to be for them to be inlined in the main method?

If I create a dll called xaisoft.dll like this: Using System; Using System.Reflection; [assembly:AssemblyVersion("1.0.0.0")] public class XaiSoft { public string PrintName() { return "XaiSoft"; } } and then compile it with csc /t:library lib.cs and then create a process assembly to use my library like so: Usin...

Is it safe to read and write to a serial port at the same time via different threads?

Is it safe to read and write to a serial port at the same time via different threads (one read thread and one write thread)? Would it be necessary to add locking around reading/writing in each thread? ...

App hangs instead of throwing exception...

I have a Winform App that I deploy with ClickOnce that installs and works for me(my UserLogin) on any system in our Domain but will not start up for a regular Domain User. It doesn't produce any errors of any kind just sits there indefinitely. It used to work and I am at a loss as to what changed that it doesn't work now. I am at a ...

WPF - bind a listbox to a list<string> - what am I doing wrong?

I'm trying to do something very basic here, something I wouldn't have expected to give me this many problems. I have a public property on my main Window class called ItemList which is of type List<string>. I add to this list throughout the life of the program, and would like the ListBox control I have on my form to automatically update w...

How easy is it to reverse engineer .net obfuscated code?

There are a few programs on the market that you can use to obfuscate your .net code, my question is, how easy is it for someone to get at your IP if your code is "so called" obfuscated. Is obfuscating .net code merely rubber chicken security? Or is it good enough to really protect your intellectual property rights? ...

Why multiply by a prime before xoring in many GetHashCode Implementations?

I understand that multiplication by a large number before xoring should help with badly distributed operands but why should the multiplier be a prime? Related: Why should hash functions use a prime number modulus? Close, but not quite a Duplicate: Why does Javas hashCode() in String use 31 as a multiplier? ...

C# Generics - Determine generic type from consuming generic method

Long story: I'm working on a system that will have Tasks and Handlers. Tasks will be sent from disparate parts of the system to the Handlers, where they will eventually return a value. We've got a system in-place that is loosely-typed and has turned into something of a gnarled mess (the problem is significantly amplified by the fact ...

Method Profiling Using Attributes

Is it possible to profile individual methods via attributes in .NET? I am currently trying to locate some of the bottle necks in a large legacy application that makes heavy use of static methods. Integrating a framework is simply not an option at the moment. Since most of the calls use static methods, interfaces and dependency injec...

What am I doing wrong with my FormsAuthenticationTicket?

Hi I am trying to recreate my cookie what would be normally generated by FormsAuthentication.SetAuthCookie() and what is in the webconfig. <authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" protection="All" timeout="20160" name=".ASPXAUTH" path="/" requireSSL="false" slidingExpiration="false" defaultUrl="default.aspx...

.NET Regular Expression to create STRONG password

Here is the .NET Regular Expression that I am using to create a strong password (which is not correct for my project password requirements): (?=^.{15,25}$)(\d{2,}[a-z]{2,}[A-Z]{2,}[!@#$%&+~?]{2,}) Password requirements: Minimum 15 Character (up to 25) Two Numbers Two Uppercase Letters Two Lowercase Letters Two Special Characters ! ...

Load Data and show a splash screen during that

I got to load some data out of a db4o database which takes 1 or 2 seconds at the startup of my app, the rest has to wait because first of all the data has to be loaded. doing this in an own thread would mean that the rest has to wait for the thread-finishing. I'd like to do a splash screen or something during the data is loaded for what ...