.net

Generic class used as constraint to generic method in C#?

Am I doing something wrong or is it not possible to specify a generic class as a constraint to a generic method? I have been playing around with generics and db4o (open source object database) and am writing a test program (see code below) to store and retrieve some user defined generic collections. I am attempting to write a generic m...

Documentation for the Dynamic Language Runtime?

Google has failed me. I want to read actual documentation for the DLR, not news articles, as I'd like to attempt to create my own language upon the DLR's framework. Is there any downloadable, online, or even paper-based documentation for the DLR that I'd be able to use, instead of having to go code spelunking to understand what everythin...

How to get the parent control from an assigned context menu using C#?

I have a few listview controls on a windows form and i've assigned a common contextmenustrip to them all using the properties grid in VS2005. Now when a selection is made from the contextmenu in any listview, is there a way i can get the correct hosting control of the raised menu? ...

Providing a common interface to SVN and CVS

SVN and CVS are two very different systems that aim to address the same basic issue - source control. They both work in distinct ways, so it's probably difficult to deal with them exactly the same. What I'm wondering is, would it be conceivable to develop a programming library or API that exposes the same interface, but under the hood,...

.net and multicores

From the .net 4.0 previews I have read until now there has been lots of talk on how the next .net version will handle and use cpus with multiple cores. We will have additions like plinq that will help us make use of multiple cores. My question is why should I have to bother my mind with handling multiple cores when all I want is to make ...

Declare a Dictionary inside a static class

How to declare a static dictionary object inside a static class? I tried public static class ErrorCode { public const IDictionary<string , string > ErrorCodeDic =new Dictionary<string, string>() { {"1","User name or password problem"} }; } But the compiler complains that "A const field of a re...

Get the Node value from XML

How do I use XPathNavigator.Evaluate ( or other methods in XPathNavigator) to obtain the ISBN value for the following xml input? <?xml version="1.0"?> <!-- a fragment of a book store inventory database --> <bookstore xmlns:bk="urn:samples"> <book genre="novel" publicationdate="1997" bk:ISBN="1-861001-57-8"> <title>Pride And Prejud...

Web reference in WCF

In WCF if we use webreference in the client project additional argument called "IsSpecified of bool" is automatically added for each of the argument that written in the Service. Why it was happening? ...

RayTracer project in C#

When I was at university, I took a subject in raytracing (graphics synthesis) and we got a chance to write a 3D ray tracer in C++. That was heaps of fun, except I long ago lost my code in the great hard drive crash of '04'....many files were lost... Is there a RayTracer I can play with in C# that isn't written in one line? Something tha...

Printing an OOXML document without MS Word installed

Is there any way to print an OOXML document (.docx file) without having MS Word installed? It works nicely via the MS Word interface but I need to find a way to use it on servers where MS Word is not installed. I've been digging through the API and haven't found anything obvious so I'm inclined to believe there isn't a way. Is this the...

Wcf Client

"The client was unable to retrieve service metadata. Make sure the service is running and exposing metadata" this error is occuring in .net 2008 while executing the wcf application. I used wcf service library template?What is the reason for the error? Is it IIS must for this? ...

How to calculate/save memory useage of .NET app on terminal servers?

I do some C# fat application on Citrix/Terminal Server. How to measure actual memory usage per-session? What can I do to reduce the memory usage in total? We still working on .NET 1.1. Does it have a difference if we upgrade our .NET runtime? ...

How to implement and extend Joshua's builder pattern in .net?

How can we implement the Builder pattern of Joshua's Effective Java in C#? Below is the code I have tried, is there a better way to do this? public class NutritionFacts { public static NutritionFacts.Builder Build(string name, int servingSize, int servingsPerContainer) { return new NutritionFacts.B...

Char array to a class

I have a incoming stream of bytes (unsigned char) from either a file or network. I need this data placed in a class, and is looking for a NET-way of doing this. I bet some does this all the time, so I guess there is a better method to do this than using BitConverter. I realize I supplied too litle information. Let me try with an exam...

Anyone encountered a INT 3 debugger break in mscorwks.dll?

We host the .NET runtime as part of a Win32 program, and lately it has begun to consistently break at a specific address, in mscorwks.dll. At the specified address, there is a 0xCC byte, which is a INT 3 instruction, which fires the debugger. Has anyone else seen this? I can't see enough information in the dll to know specifically whe...

How to modify PropertyGrid at runtime (add/remove property and dynamic types/enums)

How do you modify a propertygrid at runtime in every way? I want to be able to add and remove properties and add "dynamic types", what I mean with that is a type that result in a runtime generated dropdown in the propertygrid using a TypeConverter. I have actually been able to do both those things (add/remove properties and add dynamic ...

What is the best way to write event log entries?

I recently had a problem during the deployment of a windows service. Four computers did not cause any problems, but on the fifth any attempt to start the service failed due to an exception. The exception stack trace is written to the event log, so I though it should be easy to identify the cause: protected override void OnStart(string[]...

De Serializing a list of strings without creating a new class?

I have an XML configuration file with a collection of strings like so: <SomeSetting>value</SomeSetting> <SomeOtherSetting>value</SomeOtherSetting> <TypesOfThings> <Thing>Type 1</Thing> <Thing>Type 2</Thing> <Thing>Type 3</Thing> </TypesOfThings> These 'Things' become options in the front end of the app for the user to choose fro...

Is converting my Apps to .Net a really good idea?

All my applications are developed in Native Code. I am hesitant to move to .Net because of all the negatives that I hear, such as: Slow response time Lock-In into Windows Dependance on huge .Net run-time that makes installation a pain and slow as well. etc. etc. Your advice will be much appreciated. ...

WindowsForms designer and GenericForm

Why doesn't the designer work if you inherit from an own written genericform? Suppose I've got the following genericform public class GenericForm<T> : System.Windows.Forms.Form { public T Test { get; set; } } When I go to the designer I get errors. The only workaround I made up is using compiler directive...