.net

Styling multiple types of WPF controls

I have a stack panel with a few (different) items: <StackPanel ...> <TextBlock ... /> <CheckBox ... /> <CheckBox ... /> <Button ... /> </StackPanel> I would like to apply VerticalAlignment="Center" to all children of the StackPanel without having to add VerticalAlignent="Center" or Style=... to every single child. So, ...

Marking all classes in a project CLS Compliant

Hi If I have a project and I mark it as <Assembly: CLSCompliant(True)> Do I need to put CLSCompliant(True) before every class in the project, or are they all defaulted to CLSCompliant? ...

XmlSerializer Utf-8 encoding

Consider the code below XmlSerializer serializer = new XmlSerializer(typeof(Invoice)); using (TextWriter writer = new StreamWriter(fileName)) { // Serialize the object, and close the TextWriter. serializer.Serialize(writer, invoice); writer.Close(); } No encoding is set on the stream writer by default. Does it def...

D3D Performance comparison, shaders vs built in shading

Hi there. I have a running 3D engine built in D3D (via SlimDX). To avoid interupting the rendering pipeline I have batched together many objects with the same material into bigger meshes (to reduce state switching). This have worked well and gives a good performance level for my need. The issue I am running into is that I, during runti...

How to share constant values in .net namespaces?

I'm trying to port some code into .net which has a load of #define'd values e.g. #define MY_CONSTANT (512) #define MY_VERSION_STRING "v42.2" When I import a cli library the #define's are lost. Is there a way of defining constants in the scope of a namespace. I was thinking something like this: namespace MyNamespace { const ...

javascripting in custom web part

Hi I am writing javascript in my custom webpart's .cs file but it is giving me illegal XML character exception in browser. PageJavaScript.Append(@"function closeLoadedDiv(){ <%=Page.ClientScript.GetPostBackEventReference(btnLinkButton, "", false)%> }") I have used escape sequence for < but it is still not working ...

Entity Framework duplicating every insert

I'm trying to perform an import from Excel into an EF container, but every time I attempt this, every new record gets inserted twice. The 'AddToEntitySet' call only ever happens once, as does the SaveChanges, but immediately afterward, there are two of each record. What am I doing wrong? int rowNum = 1; foreach...

reading TraceListener initializedata property from config .NET 1.1

I have the following config file: <system.diagnostics> <trace autoflush="true" indentsize="1" > <listeners> <add name="dbgTrace" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\MyLogs\MyApp\Logs\LogFile.log" /> </listeners> </trace> </system.diagnostics> So I can read the traceliste...

changing button text in OpenFileDialog in C#.net

Does anyone knows how to change text on button in OpenFileDialog in Windows.Forms in C#.NET? ...

How to code a truly generic tree using Generics

Lets say I have a Node class as follows: class Node<T> { T data; List<Node<T>> children; internal Node(T data) { this.data = data; } List<Node<T>> Children { get { if (children == null) children = new ...

.NET C# Email: using Email Template

I want to send a HTML email using HTML template. I would like to just replace some value's from that HTML template. Any idea how to achieve this? ...

Marshaling Delphi 5 OleVariant to C#

I'm trying to use some legacy Delphi 5 DLLs from C# (2.0/3.5). Some of the exported functions are declared as such: function SimpleExport: OleVariant; stdcall; function BiDirectionalExport(X: OleVariant; var Y: OleVariant): OleVariant; stdcall; I wish to set these up as delegates using Marshal.GetDelegateForFunctionPointer, but I'm ha...

Determine if reflected property can be assigned null

I wish to automagically discover some information on a provided class to do something akin to form entry. Specifically I am using reflection to return a PropertyInfo value for each property. I can read or write values to each property from my "form", but if the property is defined as "int", I would not be able to, and my program should n...

Homemade .net stress tool only creates stress when Fiddler is on -- why?

When trying to apply some heavy stress on a new web app, we were having trouble with our usual array of free tools (WAS, some other free ms tool (wcat?)), so i created a v. quick and dirty tool that would use a .net webrequest object, open up new threads, and continually hit a list urls from a file. On a single thread it produced a littl...

Using different versions of MSHTML in C#

Is there any way to force a C# application to use a specific version of the MSHTML DLL? I'm trying to write an application that uses the different versions of the IE rendering engine to help web designers test their creations for backwards compatibility with IE6, IE7 etc... As far as I understand so far, the SHDOCVW DLL 'hosts' or 'run...

WMI Poor Performace

Hi I wrote a code in C# that maps logical drives to their physical disks, using WMI (System.Management). The code working perfectly, but slow like hell. In my machine (Windows 7 x64, Dual-Core with 3 GB RAM) it runs as least 1 second. 1 second is too slow for me, even 0.1 is more than enough to accomplish. I more than sore that this fun...

is there a difference between [Serializable] and [Serializable()] in c#?

Hi, I've bumped into examples using either of both notations. I can't find anything about it what tells which one is the common one, why 2 notations are allowed, and if there is actually any subtle difference between the two. anyone an idea? ...

problem with System.Web.Extension after installing .net 3.5 sp1

I have a solution that includes several class library's and a website. The solution was built in .net 2.0 Visual Studio 2005, and later converted to .net 3.5 (all class library's and website are targeting 3.5 framework). Before installing the update, the website functioned perfectly. After, a build fails on using System.Web.Extensions; ...

C# Define begin of day of a date in another timezone

Hi, I want to define the begin of a day in another timezone with .NET/C#. Example: My current timezone = GMT+1 so DateTime.Today returns 19/11/2009 23:00 UTC but actually I want to get the DateTime.Today for timezone GMT+2 which would be 19/11/2009 22:00 UTC. How do I do this without juggling with offsets & daylightsaving calcu...

What is __argvalue?

Also, there is one other thing that is an lvalue in VC#, though it's a language extension - __argvalue(). Source That was the only Google result for __argvalue. I tried it in LINQPad and it doesn't seem to exist. ...