.net

HttpModule Init method is called several times - why?

I was creating a http module and while debugging I noticed something which at first (at least) seemed like weird behaviour. When i set a breakpoint in the init method of the httpmodule i can see that the http module init method is being called several times even though i have only started up the website for debugging and made one single...

[.Net Service-Access Control Service] cannot get issuetoken by using REST

In the white paper, it said that we can use REST to ask for the token then use the token to attache to the request we are going to fire, then can invoke the service in the service bus, how ever, i cannot get the token Bellow are the codes i use to make REST call, i can get the result, but which was a html error page.. i didn`t get any t...

Does MEF (Managed Extensibility Framework) do "duck" typing?

I have 2 assemblies: Assembly 1: interface IWeapon { int Might { get; } } [Export("sword")] public class Sword : IWeapon { public int Might { get { return 10; } } } Assembly 2: interface IWeapon { int Might { get; } } var catalog = new AssemblyCatalog(typeof(Ninja.Sword).Assembly); var container = new C...

C# component events?

I am attempting to write a C# component which will expose events. The component is to be imported by an unmanaged C++ application. According to a few tutorials I have come up with this code (for the C# side): namespace COMTest { [ComVisible(true), Guid("02271CDF-BDB9-4cfe-B65B-2FA58FF1F64B"), InterfaceType(ComInterfaceType.InterfaceIsID...

Is it good form to expose derived values as properties?

I need to derive an important value given 7 potential inputs. Uncle Bob urges me to avoid functions with that many parameters, so I've extracted the class. All parameters now being properties, I'm left with a calculation method with no arguments. “That”, I think, “could be a property, but I'm not sure if that's idiomatic C#.” Should I...

How to get the assembly (System.Reflection.Assembly) for a given type in .Net?

In .Net, given a type name, is there a method that tells me in which assembly (instance of System.Reflection.Assembly) that type is defined? I assume that my project already has a reference to that assembly, just need to know which one it is. ...

Simple video editing application - should I use WPF or MFC?

I am about to start making a simple little video editing application, and I was trying to decide what system to create the GUI in. I know a lot about the Windows API, and actually, all of my programs thus far have been written in it. I would really like to use the new WPF framework though; however, I am a bit concerned about the fact t...

Most efficient LINQ to SQL query for objects and children?

In straight SQL, I'd probably wrap some logic over a simple join, but how would I do this efficiently in LINQ to SQL? Imagine I have two tables: Parent ID Child ParentID ID Name Ideally I'd like a graph of Parent objects with a "Childs" property that is actually a Dictionary<int, string>. Suggestions? ...

How to pass the PropertyInfo of a property as parameter in a attribute?

Lets say I have two classes: class A { [SortOrder(3)] public string Name { get; set; } } class B : A { [SortBefore(*****)] public string Age { get; set; } } Note the stars in the property attribute in the second class. Would it somehow (using expressions I guess) be possible to specify A.Name in the SortBefore attribute? ...

Any function on the framework with return type overloading?

Had the idea I'd seen at least one. ...

C# Detecting AnonymousType new{name=value,} and convert into Dictionary<string,object>

I need to detect if an object was created anonymously like new{name=value,} if it is an AnonymousType, it should add it's properties names/values into a Dictionary<string,object> This is what I hacked together myself: var name="name"; var obj = new { name = new object(), }; var lookup = new Dictionary<string,object>(); if(obj.G...

Where is the "official description" of Windows Forms events?

I've found this, but it doesn't look very much complete. Also, the description in Visual Studio about the events is mostly ambiguous. I don't want to go on a trial and error rampage to find things out. I'm particularly interested in the events related to exit/abort from a Form. EDIT: I know events are part of the framework and not spe...

Get a MS GeoId from a 3 lettor ISO code (ISO 3166-1 alpha-3)

I have a 3 letter ISO code (e.g. DEU for germany, USA for America...) and would like to get the GeoID as listed in this table, also available here How can I do that using either straight .NET, P/Invoking or through the MapPoint PIA. e.g. given "SWE", I would like to retrieve 221. System.Globalisation.RegionInfo looks kinda promising - ...

What is the rationale behind EventArgs class

Hi I'm learning events in C# and am having difficulties understanding why exactly is the EventArgs class that carries data about the event necessary. E.g. in this sample couldn't the WakeMeUp class read all the necessary data(snoozePressed,nrings) from AlarmClock fields? If it can set them, why couldn't it get them? Thanks in advance. ...

Best practice entity validation in ASP.NET MVC & ADO.NET Entity Framework

Hi, i am using ASP.NET MVC & ADO.NET Entity Framework in a project. I want to add validation logic to my entities via partial classes. It works similar like shown in the NerdDinner.com ASP.NET MVC Application which is using LINQ2SQL. The main difference is, that i have to use the"OnPropertyChanging" event instead the "OnValidating" like...

Share imagelist in .Net Winforms application

I want to have ONE instance of an image list that I want to share over all the forms in my application(s) (icons for the toolbar). I've seen the question asked before and people came up with a user control (which is no good, since it will create multiple instances of the imagelist and thus create unnecessary objects and overhead). Desig...

Viewing code of debugged .Net application BEFORE an exception is thrown

I've attached to a running .net 1.1 application using Visual Studio 2008. I have the debug symbols and the code on the local machine. If an exception occurs, the code pops up fine. However I can't work out how to view the code and set a breakpoint pre-emptively. Is there a trick? ...

.NET copy protection

Hi, Is it possible to restrict a .NET executable to a specific machine somehow so that it can only be run on that machine. ...

Why should I add reference to DLL?

Strange and probably trivial problem. I have three projects in one solution (.NET 2.0, Visual Studio 2005, C#). The first one produces GenericService.dll which contains one abstract generic class called GenericService: public abstract class GenericService< T > { } The second one is ServiceImplementation.dll which contains ServiceImple...

How can I create a windows service that is a standalone exe application?

I would like to create an console exe application, that may be run as a standalone application as well as a windows service. Is it possible to do? What are actually the benefits of using svchost? ...