.net

How to check password before decrypting data

I am creating a program that needs to store the user's data in encrypted form. The user enters a password before encryption and is required to supply the password again to retrieve the data. Decryption takes a while if there is a lot of data. Now, I want to check that the user has entered the correct password before doing the decryption...

Can I start with a string and instantiate an object of that string?

I am currently working with LINQ and C#. I have a DropDownList of the tables in my LINQ to SQL model. I want the user to be able to select a LINQ table name from the DropDown. In code I want to create an instance of that LINQ class and then run a Select or it or anything else I want. How would I accomplish creating the object based on...

.NET: Why aren't Enum's Range/Value Checked?

This has always bugged me. Perhaps someone with some hardcore knowledge of .NET internals can explain it to me. Suppose I define an enum as follows: public enum Foo { Eenie = 1, Meenie = 2, Miney = 3, Moe = 4 } Now, also suppose that somewhere in my code, I have the following code: int bar = (Foo)5; This will compile j...

Silverlight: Make DeepZoom to load tiles from local source?

I am trying to make a map application using DeepZoom. It already works by loading tile images from the server. The problem is, the loading speed is not good enough, there is always a small lag when new tiles are being downloaded. My idea is to download the whole tiles package at once and then load them from local source. I know that thi...

Adding a Business Layer to ADO .NET Entity Framework

I'm working on my first .NET project (.NET 3.5, ADO.NET and C#). We've built our entity models and are trying to build a clean business objects layer. We've got our basic entity model and we want to add certain business-level semantics to the default data accessors (navigation properties, etc). For example, let's assume that we have a...

.NET winforms application controls turn to red x's

I've deployed a C#.net 2.0 application to a Windows XP SP2 machine and during certain events a lot of the form controls turn to red X's. (Buttons, labels, etc...). I've pasted one of the procedures below that causes the problem. Since I can't reproduce it on the development machine, I can only guess that the problem is either with the th...

Mocking ConfigurationCollection

Hi, How can I Mock ConfigurationCollection with Rhino Mocks. I need to create an Expected ConfigurationCollection which contains 1 element in order to test if me Configuration contains that element. Thanks. Note : My ConfigurationCollection inherits from IEnumerable. public interface ICapalConfiguration { ICapalRepositoryConfigu...

How to embed a text file in a .NET assembly?

I would like to embed a text file in an assembly so that I can load the text without having to read it from disk, and so that everything I need is contained within the exe. (So that it's more portable) Is there a way to do this? I assume something with the resource files? And if you can, how do you do it and how do you programaticaly ...

Silverlight: How to unload (dispose) an image from memory?

I have an image control that displays a large jpg file and takes around 50mb of memory. How do I dispose of this control when it is no longer needed? I tried removing it from the parent container, setting it to null and chaning its Source property to null, but the memory usage still stays the same... Any suggestions will be highly apprec...

How do you distribute a .NET application?

Before I start developing a desktop application, I was wondering how large the installer will turn out to be if I build it in .NET? Now .NET probably is 5 years old. Do we still have to include the run time with the application? Or can we assume that most user will have it installed on their system? Does Vista ships with .NET pre instal...

Is WPF production ready?

Hi, I'm wondering if there are people out there with experience of WPF application development - and maybe more interesting - running WPF in production. Is it mature enough to use in larger projects? What are the obvious pitfalls? Any best practices? (Databinding in WPF seems pretty nifty but does it work in 'real' projects?) Thanks ...

Reading files in C#, differences in methods

Studying C#, my books are showing me classes for readin files. I've found 2 that are very similar and the Visual Studio debugger doesn't show an obvious difference between the two. code: FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); FileStream fs = File.Open(path, FileMode.Open, FileAccess.Read); Now I wond...

Free C# Grid/Graph component

Can anyone recommend a free grid/graphing component for C#/.NET? I'm having a look at NPlot right now, but so far I'm finding it quite troublesome. EDIT: I particularly need something that plugs into Windows Forms - I'm not doing ASP.NET, and don't really fancy reproducing my graph using Google's API every time I get a new data point (...

Port of current call in Remoting.

There can be several instances of my service on the same computer, each of them on a different port. How can I retrieve the port number from which the current request came through to differentiate them? To clarify, if client is calling the following method: class OrdersService : MarshalByRefObject { public void EnqueueOrder(Order ...

Is there a good way of getting MethodInfo of open generic method?

Consider type like this one public interface IHaveGenericMethod { T1 Method<T1>(T1 parm); T2 Method<T1,T2>(T1 parm); int Method2(int parm); } How do I get a methodInfo for its methods? for a regular non-generic method, like method2, I can go with typeof(IHaveGenericMethod).GetMethod("methodName",new Type[]{typeof(itsParamete...

Does the .NET framework provide any built in classes for performing geometric calculations?

What does the .NET framework provide, if anything, in the way of classes for performing geometric calculations? For example, calculating the distance between two points (represented as (x,y)) or solving a right triangle's unknown sides or internal angles? (I know that both of those are pretty easily solved; I'm just using those as exampl...

Extension method not updating object passed in

I recently started to learn about LINQ and came across the OrderBy extension method. This initially excited me because the syntax seemed much nicer than the Sort method that we use all over the place for Generic Lists. For example, when sorting a list of languages, we normally do something like: neutralCultures.Sort((x, y) => x.English...

Implement sticky overlays in .NET

I'm looking for a nice way to render overlays over a native Windows form not owned by myself preferably using a library available for .NET (WinForms, GTK#, ...). Precisely, I'd like to display a few labels or text boxes at a given location on the window. Device Context & System.Drawing: What I'm currently doing is drawing directly onto ...

Using generics and methodinfo

I am building a basic profiler for an open source project. One requirement is to measure execution time of a method. While this is easy enough, I have to do it without knowing the method or its containing class until runtime. The way to invoke the profiler will be when the user will invoke the profiler from the IDE in an active document....

Interoperating between Matlab and C#

After peeking around the internet it looks like it is possible to interop between C# and Matlab. I am wondering if anyone has had success with it and what they did to do so. If possible somehow pulling it off without the use of COM. Thanks for your time. ...