I'm reading data out of a binary file into structs in C#. What's the best way to populate a DataGridView with these records? I've only ever used the Binding with actual databases and in fact all the examples I can find cover using flat text files or databases. Should I not be using the DataGridView at all? Should I be creating a Data...
I would like to invoke XmlSerializer.Deserialize passing it an XDocument. It can take a Stream, an XmlReader or a TextReader.
Can I generate one of the above from XDocument without actually dumping the XDocument into some intermediate store, such as a MemoryStream?
It seems that what I'm after is an implementation of XmlReader that wor...
I have the following XAML that displays a cover image for a book using a URI:
<Rectangle.Fill>
<ImageBrush ImageSource="{Binding CoverUrl}" />
</Rectangle.Fill>
However, the image I would like to use is not on disk anywhere or accessible via a URI; it comes from inside a binary file that I parse out into a BitmapImage object.
Whe...
I have been asked to integrate StyleCop in our CI build process in such a way that:
Individual project file in our
(large) solution are not affected
I don't have to use any 3rd party
tool
The first requirement (and I don't fully understand this yet) is due to the fact that we don't want to run StyleCop on our entire solution straight...
Forgive me if this question has already been asked and answered.
Given a class of type T, what is the difference between the following?
T myObj = Activator.CreateInstance<T>();
T myObj = typeof(T).InvokeMember(null, BindingFlags.CreateInstance, null, null, null);
Is one solution preferred over the other?
...
Everything I'm told says that WCF should be at least as fast as remoting. I have a specific scenario here, however, where it isn't even close, and I'm wondering if someone can spot something obvious that I'm doing wrong. I'm looking into the possibility of replacing remoting with wcf for the in-process intra-appdomain communication heavy...
Possible Duplicates:
Delegate Usage : Business Applications
Where do I use delegates?
Hi,
I'm new to the concept of a delegate in .NET - I haven't really used them yet and think they are probably there for a good reason - when should I be using a delegate?
Examples are very welcome.
...
I'm running into a really weird issue with Silverlight 3. I've defined an extension method to create a storyboard around a given DoubleAnimation and play that animation. I know the default duration for storyboards in Silverlight is 1s, but I would like to change that for my animations. However, when I set a different duration, instead of...
I have downloaded the official office 2007 UI ribbon .dll, but now what? I am coding in VB.net. I do not know where to place this .dll, and I do not see any additional controls anywhere at all. The readme explains how to license your copy, which I have done.
Now what? I am hoping to magically see the ribbon control in the list of compon...
Hello,
I get an xml from the 3rd party and I need to deserialize it into C# object. This xml may contain attributes with value of integer type or empty value: attr=”11” or attr=””. I want to deserialize this attribute value into the property with type of nullable integer. But XmlSerializer does not support deserialization into nullable ...
How do I get a 5 random records from a LINQ to SQL Table[T]?
All the examples I've found via google use uniqueidentifier as the primary key
http://www.davidmuto.com/Blog.muto/View/random-records-with-linq-to-sql
Is there a way to do this when the primary key is an auto-incrementing integer?
Some records can be deleted too, so the min...
I'm in a very performance-sensitive portion of my code (C#/WPF), and I need to perform a modulus operation between two System.TimeSpan values in the quickest way possible.
This code will be running thousands of times per second, and I would very much prefer to avoid using a manual loop calculation - at all costs.
The idea of a modu...
Hi, I've got a VS 2008 SP1 solution with multiple projects. Two of the projects appear in the list, but they have a folder icon instead of the normal project icon. The folder is grayed out and I can't expand the folder. The files are definitely available and security is fine.
I edited the SLN file and removed the projects, then re-...
When I have to implement equality comparers for
public class SampleClass
{
public int Prop { get; set; }
}
Should I make
null == new SampleClass()
and
new SampleClass() == null
and
new SampleClass().Equals(null)
false?
And what about
new SampleClass() != null
Should it be also false?
UPDATE People are questioning th...
In WCF land, you can specify a Namespace prefix for anything that has a [DataContract] like so:
[DataContract(Namespace="MyApp")] public class whatever...
However if you wanted to apply a common namespace to ALL data contracts assembly-wide, you can use the ContractNamespaceAttribute:
/* in AssemblyInfo.cs */
[assembly: ContractNames...
I've been running some background processes using the Worker role in Azure to test out Azure to see if it something I can consider for one of my projects. When I click on the Analytics tab, I get a message saying "Coming soon.". Is there any way for me to determine some metrics?
I'm mostly interested in trying to calculate a potential ...
While converting a Java application to C# I came through a strange and very annoying piece of code, which is crucial and works in the original version.
byte[] buf = new byte[length];
byte[] buf2 = bout.toByteArray();
System.arraycopy(buf2, 0, buf, 0, buf2.length);;
for (int i = (int) offset; i < (int) length; ++i) {
buf[i] = (byte) 25...
I have some methods that need to run as a certain service account, so I do the normal thing:
public DoSomeWorkAsServiceAccount() {
...
// assume I am given tokenHandle
WindowsIdentity newId = new WindowsIdentity(tokenHandle);
WindowsImpersonationContext impersonatedUser = newId.Impersonate();
...
// do the work...
Is there any way to get TeamCity's build numbering to match the publish version (ApplicationRevision) number generated by MSBuild's publish task?
...
I am looking to compare two exe files. I should ensure that the existing exe on the server is a product of the code I have now.
I am using
>dumpbin /rawdata oldfile.exe > oldfile.txt
>dumpbin /rawdata newfile.exe > newfile.txt
>fc /b oldfile.txt newfile.txt //compare them like this
>windiff oldfile.txt newfile.txt // or this
I gue...