clr4.0

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

[亡魂溺海] 提交于 2019-12-05 18:41:00
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 example: IList<int> myList = new ObservableCollection<int> { 3, 56, 8 }; Expression<Func<int>> myExpression = () => myList[3]; // myExpression.Body.NodeType == ExpressionType.Call myList = new int[] { 3, 56, 8 }; myExpression = () => myList[3]; // myExpression

Repercussions of enabling useLegacyV2RuntimeActivationPolicy?

拜拜、爱过 提交于 2019-12-04 22:33:49
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 to be loaded using the highest supported version of the CLR. However, are there any side effects to doing this? What potential issues should I watch for when enabling the non-default activation policy? Well, sure, you'll be running the app with a CLR version it

Does HyperDescriptor work when built in .NET 4?

孤者浪人 提交于 2019-12-03 00:21:38
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, and the sample executes correctly, the timings show that dynamic property access with HyperDescriptor is the slowest possible way of getting/setting object values. This problem is only when you build HyperDescriptor from source with .NET 4. If from your .NET 4

.NET 4 GC known thresholds to trigger collection?

半世苍凉 提交于 2019-12-01 18:09:16
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 There are no set thresholds, they dynamically change as the garbage collector learns more about the program's allocation pattern. There is no way for you to discover the current threshold, nor to change it. From casual observation, it appears workstation GC starts out with a 2 megabyte gen 0 heap. Which can grow to over 8 megabytes. Server GC is quite different from workstation, it normally uses larger

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

僤鯓⒐⒋嵵緔 提交于 2019-11-28 07:17:50
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_Click); ... the compiler would barf because they're incompatible delegate types. But in C# 4.0, it compiles fine, because in CLR 4.0 the type parameter is now marked as in , so it is contravariant, and so the compiler assumes the multicast delegate += will work. Here

CLR2 Compiled C# COM Doesn't Work with .Net 4

放肆的年华 提交于 2019-11-28 01:58:08
问题 Does anyone know why a C# created COM library that was compiled under CLR2 (.Net 3.5) doesn't work when used with only CLR4(.Net 4)? What is missing in CLR4 that is in CLR2 for COM? We are using the appropriate startup in the app.config to have the C# run under CLR4/.Net 4: <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> All the C# stuff works until it try's to create our COM interface. It provided the following exception: Failed to load the runtime.

typeof(T) may return null

旧巷老猫 提交于 2019-11-27 23:57:16
When using the typeof operator on type created through TypeBuilder, the operator will return null. I'm curious why this happens and how to prevent it. I'm starting to think this is a VS bug in the immediate window, but I'm not quite sure. It's very easy to blame others first. Ok... code to reproduce issue: static void Main() { AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly( new AssemblyName("MyAssembly"), AssemblyBuilderAccess.RunAndSave); ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("MyModule"); TypeBuilder typeBuilder = moduleBuilder

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

偶尔善良 提交于 2019-11-27 01:46:47
问题 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_Click); ... the compiler would barf because they're incompatible delegate types. But in C# 4.0, it compiles fine, because in CLR 4.0 the type parameter is now

typeof(T) may return null

房东的猫 提交于 2019-11-26 21:36:01
问题 When using the typeof operator on type created through TypeBuilder, the operator will return null. I'm curious why this happens and how to prevent it. I'm starting to think this is a VS bug in the immediate window, but I'm not quite sure. It's very easy to blame others first. Ok... code to reproduce issue: static void Main() { AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly( new AssemblyName("MyAssembly"), AssemblyBuilderAccess.RunAndSave); ModuleBuilder

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

大兔子大兔子 提交于 2019-11-25 23:08:07
问题 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 List<T> use an array to store items, that means that a .NET application running on 32 bit will be able to hold twice as many reference type items in a list