clr4.0

Single objects still limited to 2 GB in size in CLR 4.0?

As I understand it there's a 2 GB limit on single instances in .NET. I haven't paid a lot of attention to that since I have mainly worked on 32 bit OS so far. On 32 but it is more or less an artificial limitation anyway. However, I was quite surprised to learn that this limitation also applies on 64 bit .NET. Since collections such as L...

Event and delegate contravariance in .NET 4.0 and C# 4.0

While investigating this question I got curious about how the new covariance/contravariance features in C# 4.0 will affect it. In Beta 1, C# seems to disagree with the CLR. Back in C# 3.0, if you had: public event EventHandler<ClickEventArgs> Click; ... and then elsewhere you had: button.Click += new EventHandler<EventArgs>(button_C...

Can we construct an instance of `OpCode`?

The .NET Framework 4.0 introduces several items to the Reflection API that range from extremely useful to vital for my work. Among these are protected constructors for Assembly, Module, MethodBody, and LocalVariableInfo and the new CustomAttributeData class. There are a couple items I still need that are quite troublesome to work around....

Is there a c# precompiler define for the CLR version

Hi, I need to compile code conditionally by the CLR version. e.g there's a code that I need to compile only in CLR 2 (.NET 3.5 VS2008) and not in CLR 4 (.NET 4 VS2010) Is there a precompiler directive for the current CLR version that I can use inside an #if clause? Thanks. ...

Repercussions of enabling useLegacyV2RuntimeActivationPolicy?

For my current project, we're using some CLR 2 based mixed mode assemblies. In order to use these from within a .NET 4 targetted assembly, I know you have to add useLegacyV2RuntimeActivationPolicy=true to the <startup> element within app.config. I understand that this changes the activation policy, causing these mixed-mode assemblies t...

Loading/Executing CLR 2.0 assemblies in CLR 4.0

Can the CLR 4.0 execute CLR 2.0 IL without the need for source code recompilation? ...

.NET 4 GC known thresholds to trigger collection?

I know that the logic for GC to trigger is not simple but it has certain thresholds to monitor. Anyone knows what are these thresholds could be for .NET 4 workstation and server GC ? Thank you ...

Does HyperDescriptor work when built in .NET 4?

I'm working on a .NET 4 project, and would be able to benefit from the dynamic property access that HyperDescriptor provides, but it doesn't seem to be working properly when built in .NET 4. I downloaded the source from CodeProject, converted the solution an projects to VS2010, and updated the target framework to 4.0. While it builds, ...

How does one create a .NET Expression with NodeType of ExpressionType.Index?

I'm writing code that evaluates .NET Expression trees. I'm trying to create a C# 4 test to exercise my handling of an ExpressionType.Index, but I can't figure out how to create that type of expression through a LambdaExpression. No matter what I try, the expression comes out as an ExpressionType.Call or ExpressionType.ArrayIndex. For ...

.Net object Life cycle\lifetime vs unmanaged code

I am trying to understand how objects are created in a .Net world as oppose to that in an unmanaged code environment (VB6 etc) From what I understand, when an object is created in lets say C# by using the new keyowrd, the reference variable is placed in the managed heap until the garbage collector takes a proactive measure to check if t...

.NET4 error loading resources in assembly references of CSharpCodeProvider compiled assembly

I have updated an application to Target .Net 4.0. Part of this application uses CSharpCodeProvider at runtime to compile source code files to assemblies and use them within the application. The complier provider options are set to "CompilerVersion", "v4.0". When executing the compiled code which references a 4.0 external dll (added as re...

How to late bind a CLR 4.0 assembly from a 3.5 project?

The title is self-explanatory of what I want to accomplish. I have a COM-visible component built in 3.5 and my new projects are 4.0. Code very similar to the one below is what I want to run from the 3.5 component. Assembly a = Assembly.LoadFrom(@"C:\MyCLR4.exe"); Type t = a.GetType("MyCLR4Class"); object o = Acti...