.net

Are global static classes and methods bad?

It's generally agreed upon that relying heavily on global stuff is to be avoided. Wouldn't using static classes and methods be the same thing? ...

Framework user interface for running tests and reporting results

I often have to create software to run tests (on hardware or other software), but I don't know of a good user interface control in .NET for displaying test results. (Just to clarify, I am not looking for a testing solution for .NET code. I am looking for a way to provide a system similar to those used for testing code to a user so that ...

Albacore: including only certain files/folders in a zip

Hi everyone, I'm trying to zip up the artifacts of a rake build, using Albacore's ZipTask. The solution I'm building has three projects that have artifacts that need to be zipped up individually, but only the ASP.NET MVC project will be mentioned here. Here's the directory structure of the solution: rakefile.rb solution.sln src/ (...

How to permute a list of objects in C#?

I have a list of objects. I need all possible permutations of those objects. In C++, there's std::next_permutation(). I have been trying to find something in the .NET Framework, but came up dry. What am I missing? ...

Drawbacks, advantages, etc. between ILMerge or ResolveAssembly for embedding assemblies?

Currently I know of two methods of embedding assemblies into one application file: ILMerge and using the ResolveAssembly event. I would like to know if anyone have had more success with one over the other. Is there any drawbacks from using either one of those (performance, security, ...)? From my point of view, it looks like we should...

Convert character to virtual key code

I have a string of values, and I want to simulate key press events in a window for each character. I plan on sending WM_KEYDOWN, WM_CHAR, and WM_KEYUP events to the window (as that is what seems to happen whan a key is manually pressed). Those messages require an int be sent in the wParam based on a table of virtual key codes. I can l...

Accessing DataContractJsonSerializer<T> properties via re-factored foreach loop

I have the code below. The line string content = twitterMsg.text; is creating the error 'Use of unassigned local variable' for twitterMsg. I don't seem able to access my TwitterSearchResponse.results.text fields in my DataContractJsonSerializer<TwitterMain> collection. TwitterSearchResponse.results is an array (set of object propertie...

system.io.exception access to the path is denied when running using Directory class in multiple programs

I have two programs which are accessing a directory using the .NET Directory class static methods. The first program is only reading a directory, while the second is attempting to rename a directory. The directory being renamed by the second program may not be the same directory that is being read by the first program. When the second...

How to do a compressed differential archive in .NET?

I have byte arrays that can be a few dozen megabytes in size. Such large arrays are not happy creatures, especially when you have a many of them. So I would like to compress them, so they're easier to deal with. They compress well, generally a 3:1 ratio with DotNetZip set to BestSpeed. The data in the arrays can be nearly identical. ...

What is a good mapping of .NET decimal to SQL Server decimal?

I am having to interface some C# code with SQL Server and I want to have exactly as much precision when storing a value in the database as I do with my C# code. I use one of .NET's decimal type for a value. What datatype/precision would I use for this value in SQL Server? I am aware that the SQL Server decimal type is the type that mo...

How can I make a class in C# that I can initialize just like a string?

I want to be able to initialize a class just like I initialize a string: string str = "hello"; MyClass class = "hello"; I really don't know what exactly string str = "hello"; does. I assume "hello" gets translated by the compiler into new System.String("hello"); but I'm not sure. Maybe is just not possible or maybe I'm missing somethi...

How to connect a iPhone to a .Net Web Service and get 1000's XML files efficiently?

I need to get 1000's of XML files stored in a sql server database through a .Net web service for a call from iPhone? Please suggest a better way to handle it in .net web service? ...

What happens if a .NET 1.1 and .NET 2.0 COM object are used in the same process?

If a process loads both a .NET 1.1 COM object and a .NET 2.0 COM object, both using an in-process server, what happens? Does anything break with this configuration? Or would it be safer to make one of the objects an out-of-process server? ...

Type of values in .Net - Is string a separate type?

We have Object and ValueType.... And String.... String is derived from object, but it is immutable. Is it considered a type of it's own as it doesn't behave like other objects? Is it the only object that has this immutable behaviour? Is it the runtime, compiler or library that defines this? And are there other cases like this in .Net? ...

Regex to split text containing tokens

If I have a string such as "abcdef{123}ghi{456}kl", I want to create a regex that will give me all the parts separated as follows: abcdef {123} ghi {456} kl I am using this code, but can't figure out what the expression should be: System.Text.RegularExpressions.Regex rex = new System.Text.RegularExpressions.Regex("expression"); fore...

A couple of errors I am getting, both related to SQL Server, when trying to run an app on my local machine.. please help..!

Hey, I am in the following situation: I have been requested to write an application for managing where we have customers - this must flag up when we try to add a customer too close to another one, so must be able to calculate distances based on post codes. I have chosen to use ASP.Net VB because I am fairly good at that and I like tha...

Animating a databound progressbar in Silverlight declaratively (no code-behind)

How does one animate a ProgressBar whose Value property is databound? <ProgressBar Height="25" Margin="5" Maximum="100" Value="{Binding CurrentProgress}"> My data source would probably "jump" from value to value, usually from user input; for example - user performs action, and the progress bar jumps 20 points. I would want to be able ...

Alternative to XML Serialization for Configuration

Currently, we use a giant configuration object that is serialized to/from XML. This has worked fine for the most part, but we are finding that in the case of power loss and application crashes, that the file could be left in a state that renders it unable to deserialize properly, effectively corrupting the configuration information. I w...

send "spacebar key" using SendKeys.sendwait()

i was wondering how to send spacebar key using SendKeys.send() ; it works with the other keys but onley the spacebar !! here is the link where i found the other keys http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx ...

.NET and Configuration Files With DLLS

Hi All, I am somewhat familiar with using configuration in .NET, but I am a little bit confused about something. You create an App.Config file to go with your exe, and any dlls you create use the same configuration file. So how do you access the config in the configuration file from within your DLL? If you create a settings.settings in...