.net-4.0

Convert MethodBody to Expression Tree

Is there a way to convert a MethodBody (or other Reflection technique) into a System.Linq.Expressions.Expression tree? ...

What Xml manipulation component should I use with .Net 4?

Hi, It's been long time I manipulated raw XML. I have used XmlDocument and remember something called XDocument begining to evolve, but that was few years ago. What M$ recomends in these days? Thanks in advance ...

How much .NET Framework material will .NET 4.0 MCTS cert exam questions cover?

I am planning to get my MCTS for Visual Studio 2010. The list of exams I need along with descriptions and topics covered can be found here. There is now no equivalent of exam 70-536 for the new exams. I did some searching and although it is clear to me there is no replacement of the exam, it is not clear to me whether there are .NET fr...

Linq2Sql, DomainService & DynamicData 4.0 INSERT error: "...Id is required"

Hi, I am working on a Webforms app (in VS 2010, .net 4.0, VB) that uses SQL2008, Linq2Sql, Domain Services and Dynamic Data. My problem is that when I try to insert a new record, I get the error: "..CustomerId is required" but the ID is set as primary key and Identity in the database and the Customer entity in the L2S Datamodel is also...

PerformanceCounterCategory crashing the CLR

I have an unmanaged application that uses a managed library. One of the calls the managed component makes is to the PerformanceCounterCategory class. It looks like every time any methods are accessed (for example, PerformanceCounterCategory.Exists(String)), the CLR crashes pretty hard - exceptions are not catchable, and even the debugger...

Authorization in ASP.NET 4

I have a site which is running in ASP.NET 4.0, on Windows 7 Ultimate. It is using FormsAuthentication, with a nice little logon page, all of which is fine so far as logging in and authenticating. What is NOT working okay though is directory authorization overriding in sub-directories. I want both authenticated and non-authenticated u...

Inserting Certificate (with privatekey) in Root, LocalMachine certificate store fails in .NET 4

Hi, I'm having problems inserting a new CA certificate with privatekey in the Root certificate store of the localmachine. This is what happens: //This doesn't help either. new StorePermission (PermissionState.Unrestricted) { Flags = StorePermissionFlags.AddToStore }.Assert(); var store = new X509Store(StoreName.Root, StoreLocation.Lo...

.NET 4.0 dynamic - Getting more information about members returned from GetDynamicMemberNames

I am getting the members of a dynamic class using the following method: public static IEnumerable<string> GetDynamicMemberNames(this IDynamicMetaObjectProvider dynamicProvider) { DynamicMetaObject metaObject = dynamicProvider.GetMetaObject(Expression.Constant(dynamicProvider)); return metaObject.GetDynamicMemberNames(); } How can ...

Why does System.Numerics.BigInteger not have a Parse method in Silverlight 4.0, but does in .Net 4.0?

I've come across a weird discrepancy between BigIntegers used by .Net 4.0 and Silverlight 4.0; In .Net, BigInteger has a Parse and TryParse method where as in the Silverlight version, it does not have either of these. If you look at the .Net version of System.Numerics in Reflector, you also see that when you disassemble the code, every ...

WPF dependency properties - set in XAML when base class is generic

Hi As per the title really, how can you set a dependency property in XAML when the base class is generic? When trying to do this I get a NullReferenceException, setting the property from code behind works fine. It also works when the base class is not generic. I'm using .NET4 Here is some sample code to demonstrate: WindowBase.cs usi...

.net 4 WCF Endpoint in generated metadata (WSDL) points to node rather than virtual host hosted on load balanced (NLBS) IIS6

This is real simple. I have a wcf service (nothing fancy, just New Project-> WCF Service Application), that runs great in Visual Studio. When I deploy it to an clustered IIS6 environment, it works mostly. I can send a request and get a response. However, the generated metadata consistently refers to a particular node in the cluster...

Is there a relatively easy way for a hybrid .Net exe (console app/Windows service) to install and start itself as a service?

Suppose an executable named ConsoleOrService.exe is written in C#. It currently is a hybrid. I can just start it on the command line, or I can install it using the .Net's installutil ConsoleOrService.exe and then start the service. I would like a third option: running it on the command line like so: ConsoleOrService.exe --install and ha...

.Net 4.0 Framework Causing Issue for aspnet_regiis during installation

Hi Folks, We have a ASP.net 2.0 web app with an installer which appears to hit an issue with .Net Framework 4.0. This has occurred on XP and Windows 7. Seems to happen every time. During the installation, we call aspnet_regiis for various tasks such as encrypting the web.config. If .Net 4 is installed this throws the error: aspnet_r...

Sorting a List<T> by DateTime

Hi I am having trouble implementing sorting on a list when DateTime is involved. I need to sort by DateTime Just put together a noddy example and I don't get the expected result. Could you see what Am I doing wrong? Thanks class Program { static void Main(string[] args) { List<Customer>customers=new List<Cu...

Unable to start Ado.Net Data Service in IIS6

Hi, I am trying to run a sample WCF ADO.Net Data Sertice on my IIS, which give me message The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure t...

System.Threading.Timer not firing after some time

Hello All, I have a windows service application. And debugging it by running in console mode. Here http://support.microsoft.com/kb/842793 it is written that Timers.Timer has a bug and not firing in windows services. And workaround is to use Threading.Timer And this article is for .NET 1.0 and 1.1 I am using .NET 4 but after some time ...

AutoMapper / Castle - Inheritance security rules violated while overriding member

I am getting the following exception when calling any of my Mapper.Map methods. Inheritance security rules violated while overriding member: 'Castle.Core.Logging.LevelFilteredLogger.InitializeLifetimeService()'. Security accessibility of the overriding method must match the security accessibility of the method being overriden. I am us...

Uploading files in ASP.NET

I am trying to import an excel file using asp.net and C#. I found an example in VB, but it is using something called "Server.MapPath" which is not resolving to a namespace. I am on .NET 4.0, C#, and windows XP. I found a "HttpServerUtility.MapPath", but I don't know if this is the equivalent for IIS7? C# public OleDbCommand ExcelCon...

Backwards compatability between .Net 2.0/3.5 and 4.0

I have an app that I've upgraded from 3.5 to 4.0. But not all my 3rd party assemblies are built on .net 4.0. How is it that I'm still able to reference those assemblies without any problems? For instance, if another assembly references system.dll 2.0, and my upgraded project references system.dll 4.0 how does .net handle this? Obviosly ...

How to get a file and move it out of the isolated storage?

I want to take a file that stored already in the isolated storage, and copy it out, somewhere on the disk. IsolatedStorageFile.CopyFile("storedFile.txt","c:\temp") That doesn't work. Throws IsolatedStorageException and says "Operation not permitted" ...