.net

How to set RequestValidate in UserControl??

I am getting error "A potentially dangerous Request.Form value was detected from the client" when trying to insert html content in DB from usercontrol. Two ways to get rid of this error are 1) Set RequestValidate = false for the page itself. 2) Set RequestValidate = false in web config. Both solutions doesn't fit in my case. It is Some...

Silverlight 3 Merged Resources question

I have defined a custom resourceDictionary and I have added it to the app.xaml resources I have a style with key "MyStyle" in the Theme.xaml. How can I access the MyStyle style from the MainPage.xaml? ...

In WPF how do you access an object defined in Window.xaml from a nested user control ?

I have a situation where I need to access an object that has been defined in one user control from within a user control nested 2 levels deep. Take the following for example: public class MyClass { public MyClass() { MyData = new MyDataProvider(); } public MyDataProvider MyData; public string SelectedValue;...

Implementing your own LINQ & IEnumerable<T>

In a project I am working on, there are really huge collections (1M-1B elements), and things are modified as collections mostly. It's a real-time app, and so the performance is paramount. For some of the operations, like Reverse, BinarySearch (possible?), etc will suffer more than others like Select, etc. Is it feasible to implement o...

What does it take to prove this Contract.Requires?

I have an application that runs through the rounds in a tournament, and I am getting a contract warning on this simplified code structure: public static void LoadState(IList<Object> stuff) { for(int i = 0; i < stuff.Count; i++) { // Contract.Assert(i < stuff.Count); // Contract.Assume(i < ...

Upgrade website from ASP.Net 3.5 to 3.5 sp1

Is there anything special that needs to happen to a 3.5 web.config file to take advantage of new features in sp1? ...

Is it possible to release a variable in c#?

I'm just curious... Is it possible to release a variable in c#? What I mean is, can you do something like this: ... string x = "billy bob"; //release variable x somehow string x = "some other string"; //release variable x somehow int x = 329; ... ... so basically you are declaring the variable multiple times in the same scope. ...

FIPS-compliant HashAlgorithm on WinXP?

How can I use C# on a FIPS-compliant WinXP SP2 box to uniquely hash the contents of a given file? I'm not concerned about performance (yet?). Hopefully someone can point out an exception to the "rule", but it seems that the "*ServiceProvider" classes are FIPS-compliant and unavailable on WinXP, while the "*Managed" classes are availabl...

How can I recover a reference to a process that has been relaunched?

Using Process.Start, I am starting various IE8 and Firefox (3.5) processes which I keep a Process instance for. A little while later in the application, I'll use the Process instances' MainWindowHandle property to target the window for use with some platform API functions via P/Invoke. However, both IE8 and Firefox will kill the second...

Developing a new application with .NET?

I have to develop a basic "line of business" application with the usual functionality like orders, stock control, sales, reports, etc. I will use WPF to develop this application to run on Windows but I want to develop it "open" so I can do a Windows Forms application using the same structure (maybe to run over Mono) or even a Silverligh...

BitConverter.ToString() in reverse?

I have an array of bytes that I would like to store as a string. I can do this as follows: byte[] array = new byte[] { 0x01, 0x02, 0x03, 0x04 }; string s = System.BitConverter.ToString(array); // Result: s = "01-02-03-04" So far so good. Does anyone know how I get this back to an array? There is no overload of BitConverter.GetByte...

Does processModel memoryLimit apply to ASP.Net only? (System.OutOfMemoryException)

We are running a .Net 1.1 based Windows Service (not an ASP.Net application), and we are getting System.OutOfMemoryException errors under heavy load. The service basically hosts an in memory cache, consisting of an Asset hashtable, nested within that is an account hashtable, and within that is a class that stores values for a given time...

Reading Scanner input

I am very new to .NET. Can anybody please help me in writing C# Code to read the input read by barcode scanner...like the Scanner to read Flight tickets. Please provide a Step-by-step process. Thanks, Dileep ...

C#: Drawing a timestamp onto an image

Hi! I was just browsing some questions when I stumbled upon this one. I am not experienced in System.Drawing, so I'm just wondering, how would you draw a timestamp onto an image? Also, as I'm very interested in System.Drawing, what are the best resources for learning how to use it well, and its application in various situations? Thank yo...

Generic method overloading compilation error in VB

I have a problem with the VB.NET compiler failing to compile a class (in a separate C# assembly) which contains two overloads of a method with generic arguments. The equivalent code in C# compiles against the same assembly with no errors. Here are the two method signatures: protected void SetValue<T>(T newValue, ref T oldValue) protect...

Resize an image with .NET without losing EXIF data

Hello, What is the best way to resize images using .NET, without losing the EXIF data? I'm okay with using .NET 2 System.Drawing.* classes, WPF classes, or open-source libraries. The only easy way I found to handle this all for now is to use the Graphics.FromImage (.NET 2) to perform the resizing and to re-write the EXIF data with an ...

ASP.NET Session is not keeping stored across pages

First, I created a Login page that added a key value pair to the session and verified that on that page the session holds that pair. Next, I attempt to go to another page that looks for that pair in the session and it is not there. I've put the timeout for the session to 15000 so it won't timeout. I currently use a static class to look a...

Accessing main thread from a Timers.Timer in .NET

Hi there, I have a Timer that monitors certain conditions (like if a Process is running) and when those conditions are met I must create a hook (SetWinEventHook). The problem is that the hook must be created on the main thread, otherwise my callback doesn't return. How to do that? I've tried everything, and the only way that this worked...

Dot Net : Wrapper class to create image from SWF file

Is there any wrapper class available in DOT NET so that i can create an image from a flash movie(swf file). I know there is something called FFMPEG.But its an exe.Since i am not going to deploy my application on a dedicated server,I cant put an exe file in the server.Is there any classes available which embed the functionality of this F...

Reading uintvars (VLQs) into C# ints

Has anyone worked with .Net code to read/manage VLQs? There is a Java method readMultiByteInteger that accepts a stream of bytes and coverts them to ints according to VLQ spec but i cannot find a C# equivalent. From Wikipedia: A variable-length quantity (VLQ) is a universal code that uses an arbitrary number of binary octets (eight-bit ...