.net

What is Code Access Security in .NET

What is CAS(Code Access Security) in .NET, and how to achieve it. What are the benefits of using it. ...

Which free unit testing framework for C#?

I'm rather beginner in C# world (and .Net as well), so I decided to get some advices from more experienced developers. Which free unit testing framework for C# would you advise? I came across NUnit, which seemed to look interestingly, but in it's documentation I found out, that there were versions for .Net 1.1 and .Net 2.0. I need to use...

.NET file system wrapper library

For some reason I can't find one, but someone must have already created a .NET IO library wrapper. I want to be able to mock calls to File.Exists etc, and the static methods builtin don't lend well to this. ...

Dynamically reconfigure Log4Net

I'm looking for tips on the best way to reconfigure the Log4Net logging level dynamically in my ASP.NET apps. I generally use a simple configuration where the root logger defines the default logging level, e.g. <log4net> <root> <level value="INFO" /> <appender-ref ref="..." /> <appender-ref ref="..." /> ... etc ... ...

What is a fault clause in the CLR exception system?

I was reading this article on handling corrupted state exceptions and I came across something that puzzled me. What is a fault clause? See quote from article below: An error condition can only pass from the function containing the unexpected condition to that function's caller. Exceptions have the power to pass the result...

What should I display in my About box?

I've built a small .NET winforms utility for internal use at my company, and as the primary interface is a tab control, I've decided to add a tab for the "about box" instead of a separate form. So, I have some space to fill in my about box. Thus far I have: the program's icon & name version the author's name (me) the year of creation ...

How-to draw a circle on a changing background

There is a timer on the form and in its Tick event there is this line of code: this.BackColor = ColorTranslator.FromHtml("#" + ColorCodesBack[_index]); CurrentColor = ColorTranslator.FromHtml("#" + ColorCodesFore[_index]); SolidBrush sb = new SolidBrush(CurrentColor); g.FillEllipse(sb, this.Width/2 -200...

Zoom in on a web page using WebBrowser .NET control

In IE7 there's a "zoom" feature built-in (show in the status bar), allowing you to zoom in up to 400%. I'm using the WebBrowser .NET control in a demo/simulation app, and need to zoom in on a web page. Is this at all possible? (I don't want to simply take a picture of the page and enlarge it, as I need to use the links and buttons on th...

Can an async I/O throw an uncatchable exception?

I have a multi threaded .NET app that uses async I/O and AsyncCallbacks to handle the I/O completions. Rarely, the app will fail with an exception like: Arithmetic operation resulted in an overflow. at MyApp.ReadComplete(IAsyncResult ar) in c:\MyApp.cs:line 123 at System.Net.LazyAsyncResult.Complete(IntPtr userToken) at System...

.NET Reflection - How to get "real" type from out ParameterInfo

Hi. I'm trying to validate that a parameter is both an out parameter and extends an interface (ICollection). The reflection api doesn't seem to want to give me the "real" type of the parameter, only the one with an "&" at the end which will not evaluate correctly in an IsAssignableFrom statement. I've written some c# code that works but ...

C# app runs with debugging, but not without

I'm running a (mostly) single threaded program (there's a main thread that does everything, the others only read stuff). I can get the application to run fine in VS2008 after a minor change (I changed the text of a form, and tab order of another form), but I can no longer get it to work outside of the debugger. Does anyone know what woul...

How do I get the next item in a subset of an ordered table using linq?

I have two tables: Topic ( TopicID: int, (primary key) TopicName: varchar ); Example ( ExampleID: int, (primary key) TopicID: int, (foreign key to Topic table) ExampleOrder: int, ExampleName: varchar ); Using Linq, given an ExampleID, I want to get the next example in the same topic (with the same TopicID). Here's how it ...

What is the purpose of a Paint() method vs the _Paint() event in a Win Form?

I am working with a WinForm application that was designed by the previous, now unreachable, develeper. In this app farms are embedded in TabControls through some custom code. My question is, Can anyone help to try and explain why there is a custom _Paint() function in each form that is called from the Load event for that form. This ...

How to decode wav, mp3, and/or ogg in .Net/Mono?

I am looking for a cross-platform (.Net and Mono on Windows, MacOSX, and Linux) way to decode wav, mp3, or ogg files such that I can then play the decoded streams through DirectSound or OpenAL as desired. A solution that can decode either mp3 or ogg would be sufficient -- decoding both is not necessary. If it (or another solution) can d...

How to extract a substring from a .NET RegEx?

I have an XML file containing one (or more) key/value pairs. For each of these pairs I want to extract the value which is a two-byte hex value. So the XML contains this snippet: <key>LibID</key><val>A67A</val> Which I can match using the following expression, with the ID in parenthesis. Match match = Regex.Match(content, @"<key>LibI...

Call function from DLL with non-static path

I have a DLL that I need to access methods from. In most cases like this I just use [DllImport] to access methods from unmanaged assemblies, but the problem with that in this situation is that it requires the path to the DLL at instantiation time, so a constant string. This particular DLL is one that gets installed with my application ...

Asp.net, Linq Error: 'int' is a 'type' but is used like a 'variable'

hi everyone i am using asp.net and link to display a set of books from the db. n it gives me an error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0118: 'int'...

Visual studio 2005: List<T>.First() List<T>.Last() methods in C#?

Hello, I used List<T>.First() as well as List<T>.Last() in my VS 2008 C# project, but when I've downgraded to 2005 I got errors like this: 'System.Collections.Generic.List' does not contain a definition for 'First' As far as I understand, if still there are Find() and FindLast() methods there MUST be a very very simple way to get iter...

Problem with partial method C# 3.0

Do you know the answer to following question? Let us say, it MyMethod() is declared as partial method in MyPartialClass in MyPartialClass.cs. I have also provided body of MyMethod() in MyPartialClass in MyPartialClass2.cs. I use a problem without answer“Magic” code generator which has actually generated MyPartialClass.c...

What is the Windows Forms equivalent of the WPF's Keyboard class?

Question says it all - is there a class somewhere in Windows Forms that has the same functionality as the WPF System.Windows.Input.Keyboard? Or am I stuck always having to handle the keyboard events and keep my own state? (I'm specifically interested in a Forms analogue to IsKeyDown). Alternatively, is there a no-fuss way to use this ...