.net

Generic interface VS generic method?

I'm writing a generic type to handle the underlying Active Directory objects such as groups, organisational units and users. I'm also using "manual" dependency injection within my generic interface. I would like to know if, in my situation, which is more appropriate: generic interface or generic method? Here's a simplified code sample ...

Advantages of Code Only model in Entity Framework 4?

The Entity Framework 4.0 Futures preview (CTP3 now) has a code only modeling paradigm for mapping between your types and the database. No edmx files involved and no EDM designer needed. I wanted to know what are the big advantages of Code Only vs Model First? What can be done in Code First which can't be done in other models (Model Firs...

Consuming REST service with .NET 4 Client Profile

What's the easiest/best way to consume a RESTful service from a .NET client application using the .NET 4 Client Profile? Everything I have found ends up pushing me towards the full framework: WCF REST Starter Kit. HttpClient class requires full framework. WebChannelFactory<> is in System.ServiceModel.Web, now removed from the Client ...

Using WinDbg with SOS extension to troubleshoot WSPBuilder: Unable to load one or more of the requested types.

I am currently getting an "Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information" error when trying to build a wsp from within visual studio 2010 to be deployed to sharepoint. There is an article here that references this issue with an interesting answer by miko: http://stackover...

How to find the .net framework version of a Visual Studio Project?

i have a project in visual studio. I want to know .net framework version of it? where can i look at? ...

Complete list of .NET conversion operators

Does anyone have a complete list of the conversion operators for VB/C# and how they differ? So far I know about... value as type [C#] TryCast(value, type) [VB] Convert.ToXxx(value) [any] (type)value [C#] CType(value, type) [VB] DirectCast(value, type) [VB] CXxx(value) [VB] CTypeDynamic [any] implicit conversions when using Option Stri...

Migrate Delphi 2007 component to .NET

Hello everybody. I need some help. I have generated a component in Delphi 2007 Code Gear and I need to migrate it to .NET to be used by VB.NET platform. I generated an ActiveX dll but I have been told that only the declaration of the class is visible in .NET. Actually the component I have generated is inherited by another component o...

HttpWebRequest error 403

I am new in C# and have requirement to retrieve a url from C#. Most of case it’s working fine but in one case its throws an error. url is as follows http://whois.afrinic.net/cgi-bin/whois?searchtext=41.132.178.138 Error is: Exception in the HTTP request for url: http://whois.afrinic.net/cgi-bin/whois?searchtext=41.132.178.138 The remo...

Binding a List<string> to a Listview in asp.net 3.5

How do I bind a List to a in ASP.NET 3.5 <asp:ListView ID="lvDiagnosisCodes" runat="server"> <LayoutTemplate> <ul> <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder> </ul> </LayoutTemplate> <ItemTemplate> <li> ...

ASP.NET MVC - How should sending email be handled?

In an ASP.NET MVC application, how should the sending of emails be handled? I've been thinking about this, and I really like the idea of handling it in an MVC-oriented way (it is an MVC application, after all.) What I mean is that the email that gets delivered to the user is really just a view that should have a model passed to it. This...

Getting SIM card data via .Net

I need to access a SIM card and get the SIM card Serial No, Phone No. and carrier from SIM card at5tached to a PC via a USB/SIM adapter. .Net platform, C# prefered. Any ideas? BP... ...

Serialize IDictionary of objects

I'm writing a logging framework and need to serialize each object in an IDictionary<string,object>. Object can be a simple string, int etc. or a complex business object or a collection of either. Therefore I need a flexible method for doing this. At the more complex end of things I'd like the output to be something like: Object = IList...

What is the easiest way to validate a UPN and a NT login name?

We allow our users to enter Active Directory account information using either an NT account name (domain\account) or a UPN (account@email,xxx). I would like to write some code to validate the account in active directory before allowing the user to move on. Note, we are not validating a password, just the account name. I can use UserPr...

Keeping folder permissions when using web deployment project?

I'm using a web deployment project to deploy a project on my local dev machine. Within this project I have a specific folder to receive uploaded files so the ASPNET machine account needs permissions to write to this folder. Unfortunately the web deployment process loses these permission each time I run it. Does anybody know of a way to k...

Get the optimizations from retail build into debug build

I have a function when unit tested takes around 15 minutes to finish in debug mode. When I run the same tests in retail mode, it takes around 30 seconds. Is there anyway I can figure out what optimizations were done in the retail build? ...

Attribue to verify field is initilized by a given point in an ASP.Net page lifecycle

I would like to create an attribute I can decorate specific fields or properties with. This attribute will throw an exception if the field or property it decorates is null at a given point in an ASP.Net page lifecycle. I.E. if a property, "x", is null at the prerender stage of an ASP.Net page, it will cause a "ArgumentNullException" exc...

Filtering derived classes in Entity set by OfType and getting exception.

Hello everybody I am trying to filter derived classes in my entities but i am getting exception. var filtered = db.PersonSet.OfType<Person>(). Where(person =>person.GetType()==typeof(Person)) I am getting below exception if i try to loop filtered collection by foreach. "LINQ to Entities does not recognize the method '...

Building an application to do a task periodically on a server

I'm looking for some guidance on the overall architecture of this little system I'm building. Currently, I have an app that is deployed (and updated) via xcopy to a few servers. This works well for updating the code, but it does not work well for updating the period of the code's execution, since it is setup as a windows scheduled task ...

Easiest way to compare arrays in C#

In Java, Arrays.equals() allows to easily compare the content of two basic arrays (overloads are available for all the basic types). Is there such a thing in C# ? Is there any "magic" way of comparing the content of two arrays in C# ? ...

Parsing a decimal number

Guys, I have a string that contains a decimal number. The problem is, sometimes it is negative and it is stored in accounting format (positive number surrounded by parenthesis). In other words, I got a string like this: string s = "(35.00)"; What I'm doing currently is: decimal TheValue = decimal.Parse(s); This value of TheValue sh...