.net

DLL Protection - Hide methods and variables from other people.

Possible Duplicate: How to protect dlls? I am wondering how I may protect my DLL files from being used by other people. By "used" I mean, referenced/imported or whatever into projects and the functions and variables inside used. I only wish it to be used by my applications... is there a way to protect it? ...

How do I retrieve a list of logon/logoff/lock/unlock times in Windows?

Is there any way to get a list of times that a user logged on, logged off, locked, or unlocked their computer for the past week or so without adding a service to track it as it happens? Does Windows even keep that information for that long? ...

Email on Error Implementation

Hi all, I've been working on a .Net Windows Service and i was wondering how to implement sending out an email on an error from within the service. I entertained myself with the idea of sending the email from within a catch block, but then i remembered that there could be an error within sending an email as well and an unhandled exceptio...

Why would adding an **appSettings** section to App.config cause an error in WPF application?

In my WPF application (Composite Application) I want to store a variable in the App.config file, but as soon as I add an appSettings section in App.config, it gives me this error: The type initializer for System.Windows.Application threw an exception. App.Config: <?xml version="1.0" encoding="utf-8" ?> <configuration> ...

Completely embedding a Silverlight Application in an HTML Page?

I am still trying to solve the issue of displaying an image on a website without having the image external. As the data: scheme does not work on older browsers or big images, I'm currently experimenting with Silverlight. I managed to solve the embedding by Base64 Encoding the Image and passing it in using the InitParams, but actually I ...

regex help for validators

I need a regular expression validator to validate that text fields contain only numbers between 00 - 31 (note that it should allow both 05 and 5), another regex for numbers 01 -12 (again, it should allow both 05 and 5), and another regex for numbers between 1920 - 2009. How can i do this? ...

Build an installer for .NET app that can run on Windows and OS X?

I am surprised I could not find this question already asked, so if I simply missed it please notify promptly. I need to write a very small, fairly simple application in .NET that will be downloaded by end-consumers and installed on their system. Silverlight's sandbox model will not work - it has to be a full-on downloaded, installed exe...

Wix - Dynamically Register Assemblies to GAC

I am writing a Wix installer to install .NET assemblies to the GAC. Easy... My question is: is it possible to future proof this scenario so that I can pull ANY assemblies found in an existing network folder and register each of them - without having to hardcode the exact assembly names? This would allow me to create a single MSI that co...

Is it possible to read from a url into a System.IO.Stream object?

I am attempting to read from a url into a System.IO.Stream object. I tried to use Dim stream as Stream = New FileStream(msgURL, FileMode.Open) but I get an error that URI formats are not supported with FileStream objects. Is there some method I can use that inherits from System.IO.Stream that is able to read from a URL? ...

Equivalent of a Windows Service on OSX with Mono

What do I need to do to have my .NET-Mono application run as a background process on OSX and start when the OS starts up? (Assuming the application is otherwise ready to go on OSX) Related Build an installer for .NET app that can run on Windows and OS X? ...

Easiest way to make a single statement async in C#?

I've got a single statement running on a ASP.NET page that takes a long time (by long I mean 100ms, which is too long if I want this page to be lightning fast) , and I don't care when it executes as long as executes. What is the best (and hopefully easiest) way to accomplish this? ...

TimeZoneInfo and country codes

I'm looking to implement a function with a signature something like the following: bool IsTimeZoneValid(string countryCode, DateTime localTime); The intention is to determine whether the country has a time zone in which the local time would be valid, given that we know the current UTC time. Let's say, for the sake of argument, that "v...

Is it really necessary to include a text description when throwing a exception?

As when using any other class or third party libraries, one would expect exceptions to be documented as well, so I've always found somewhat redundant to add text descriptions to them. Are they really necessary? What are your thoughts? Thanks in advance. ...

Namespace only class visibility in C#/.NET ?

In C# can you make a class visible only within it's own namespace without living in a different assembly ? This seems useful for typical helper classes that shouldn't be used elsewhere. (i.e. what java calls package private classes) ...

Visual Studio 2008 - Deploy two projects to device.

I have a solution with two mobile projects. When I hit deploy only one of the app gets deployed to the device. The output of the second project is a dll. ...

Is it bad practice to put a lot of code in the get function of a property which wraps PInvoke stuff?

A confusing title I know. Let me explain. I have to marshal an array of structs, which then get converted to an array of classes (legacy compatibility). For instance public class InnerClass {} public class OuterClass { private InnerClass[] innerClasses; } public struct InnerStruct { // Data } private static buildInnerClass( Inne...

How to String.Format the day of the month in c#?

DateTime's formatting has some overlap between it'a standard date and time formatting strings and some of it's custom format specifier by them selves. As a result, when I evalate this expression: string.Format(">{0:d}< >{0: d}<", DateTime.Now) and get this result: >8/3/2009< > 3< My question is: How do I get String.Format to out...

calling javascript function on selected index change of select input type in ASP.NET

Is there a way to call a javascript function when the selectedIndex of a select input has been changed? Using this code in the c# code behind file riskSeverityDropDown.SelectedValue = Convert.ToString(planRisk.Severity); riskSeverityDropDown.SelectedIndexChanged += new EventHandler(riskSeverityDropDown_SelectedIndexChanged); riskSeveri...

.NET HTML whitelisting (anti-xss/Cross Site Scripting)

Hello, I've got the common situation where I've got user input that uses a subset of HTML (input with tinyMCE). I need to have some server-side protection against XSS attacks and am looking for a well-tested tool that people are using to do this. On the PHP side I'm seeing lots of libraries like HTMLPurifier that do the job, but I can'...

Undoing All Changes Since BindingSource's last EndEdit call

Here's the scenario (which uses a BindingSource bound to a DataTable within a DataSet): A user creates a new address book contact, fills in the First and Last name in data-bound controls. He presses Apply, whose event handler calls BindingSource.EndEdit(). He then realizes there was a mistake, and adds an email address. But when he pre...