clr

Got the error “Symbol clr!XXX not found” when debugging the CLR object\class

半城伤御伤魂 提交于 2019-11-28 02:13:46
问题 I tried to print the CLR object/class by WinDbg, however it failed. Firstly, I tried to run x clr!Thread* to get some CLR class name, the output like below. 00007ffd`68957f18 clr!ThreadStore::s_pOSContext = <no type information> 00007ffd`685b0bf0 clr!ThreadNative::SetApartmentState (<no parameter info>) 00007ffd`685b12c0 clr!ThreadNative::YieldThread (<no parameter info>) 00007ffd`6806be60 clr!Thread::ResetManagedThreadObjectInCoopMode (<no parameter info>) 00007ffd`6895e928 clr!ThreadpoolMgr

Version Information on ASP.NET Server Error Page

倖福魔咒の 提交于 2019-11-28 02:07:23
I have a ASP.NET MVC5 Web Application configured to run on .NET Framework version 4.5.1. However, I notice that when I get an application runtime exception of some sort, the version information displayed at the bottom of the yellow server error page says the following: Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34009 Why is this not 4.5.x? That is not the actual .NET framework version. It is the version of the CLR. From .NET 4 up to 4.5.2 it is version 4. Between 2.0 and 3.5 it was version 2.0. That is also the reason that in your application

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.

CLR JIT optimizations violates causality?

馋奶兔 提交于 2019-11-28 01:49:23
I was writing an instructive example for a colleague to show him why testing floats for equality is often a bad idea. The example I went with was adding .1 ten times, and comparing against 1.0 (the one I was shown in my introductory numerical class). I was surprised to find that the two results were equal ( code + output ). float @float = 0.0f; for(int @int = 0; @int < 10; @int += 1) { @float += 0.1f; } Console.WriteLine(@float == 1.0f); Some investigation showed that this result could not be relied upon (much like float equality). The one I found most surprising was that adding code after the

How do I force an application compiled to target .NET Framework 4 to run under .NET framework 4.6.1?

时光怂恿深爱的人放手 提交于 2019-11-28 00:25:26
问题 I have done considerable research and not found any suitable answer. Here is the scenario. I have an application which was compiled to target .NET Framework 4. At runtime I want that application to actually execute within the .NET Framework 4.6.1. I found two options so far. Recompile the application under .NET Framework 4.6.1 Add the configuration/startup/supportedRuntime element to app.config with version="v4.0" sku=".NETFramework,Version=v4.6.1" Option 1 is not desirable as it would

Can you have multiple enum values for the same integer? [duplicate]

不问归期 提交于 2019-11-28 00:13:16
This question already has an answer here: Non-unique enum values 6 answers In .NET can you have multiple enum values for the same integer? eg. public enum PersonGender { Unknown = 0, Male = 1, Female = 2, Intersex = 3, Indeterminate = 3, NonStated = 9, InadequatelyDescribed = 9 } In C#, this is allowed, as per the C# Language Specication , version 4. Section 1.10 Enums doesn't mention the possibility but later on in section 14 Enums , we see (in 14.3 ): Multiple enum members may share the same associated value. The example enum Color { Red, Green, Blue, Max = Blue } shows an enum in which two

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

How do I find the current time and date at compilation time in .net/C# application?

我与影子孤独终老i 提交于 2019-11-27 23:57:13
I want to include the current time and date in a .net application so I can include it in the start up log to show the user what version they have. Is it possible to retrieve the current time during compilation, or would I have to get the creation/modification time of the executable? E.g. Welcome to ApplicationX. This was built day-month-year at time . If you're using reflection for your build number you can use that to figure out when a build was compiled. Version information for an assembly consists of the following four values: Major Version Minor Version Build Number Revision You can

How to see code of method which marked as MethodImplOptions.InternalCall?

荒凉一梦 提交于 2019-11-27 23:34:21
When use ILSpy to check the code of System.String, I found there are some methods marked as MethodImplOptions.InternalCall such as: [SecurityCritical] [MethodImpl(MethodImplOptions.InternalCall)] internal static extern int nativeCompareOrdinalEx(string strA, int indexA, string strB, int indexB, int count); I know MethodImplOptions.InternalCall means this method is implemented natively by the common language runtime to optimized code to improve performance. My question is: Is that anyway can enable us to see the code marked as MethodImplOptions.InternalCall? You'll need the source code for the

Usages of object resurrection

我是研究僧i 提交于 2019-11-27 22:56:19
I have a problem with memory leaks in my .NET Windows service application. So I've started to read articles about memory management in .NET. And i have found an interesting practice in one of Jeffrey Richter articles . This practice name is "object resurrection". It looks like situating code that initializes global or static variable to "this": protected override void Finalize() { Application.ObjHolder = this; GC.ReRegisterForFinalize(this); } I understand that this is a bad practice, however i would like to know patterns that uses this practice. If you know any, please write here. Speculative