clr

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

荒凉一梦 提交于 2019-11-29 08:52:28
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::LastCPThreadCreation = <no type information> 00007ffd`68627800 clr!ThreadPoolNative:

System.Int32 contains… another System.Int32

a 夏天 提交于 2019-11-29 08:01:02
问题 I used reflection to inspect the contents of System.Int32 and found that it contains another System.Int32 . System.Int32 m_value; I don't see how that's possible. This int really is the "backing integer" of the one you have: if you box an int and use reflection to change the value of its m_value field, you effectively change the value of the integer: object testInt = 4; Console.WriteLine(testInt); // yields 4 typeof(System.Int32) .GetField("m_value", BindingFlags.NonPublic | BindingFlags

'System::String ^' to 'LPCWSTR'

烈酒焚心 提交于 2019-11-29 06:31:04
I want to convert System::String ^ to LPCWSTR . for FindFirstFile(LPCWSTR,WIN32_FIND_DATA); Please help. The easiest way to do this in C++/CLI is to use pin_ptr : #include <vcclr.h> void CallFindFirstFile(System::String^ s) { WIN32_FIND_DATA data; pin_ptr<const wchar_t> wname = PtrToStringChars(s); FindFirstFile(wname, &data); } To convert a System::String ot LPCWSTR in C++/CLI you can you use the Marshal::StringToHGlobalAnsi function to convert managed strings to unmanaged strings. System::String ^str = "Hello World"; IntPtr ptr = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi

Why would System.Type.GetType(“Xyz”) return null if typeof(Xyz) exists?

a 夏天 提交于 2019-11-29 06:11:51
问题 I have come across a strange behaviour in my (huge) .NET 4 project. At some point in the code, I am referring to a fully qualified type, say: System.Type type = typeof (Foo.Bar.Xyz); later on, I do this: System.Type type = System.Type.GetType ("Foo.Bar.Xyz"); and I get back null . I cannot make sense of why this is happening, because my type name is correct, and I have checked with other types and they get resolved properly. Moreover, the following LINQ query finds the type: var types = from

Why does this generics scenario cause a TypeLoadException?

我的梦境 提交于 2019-11-29 05:36:39
This got a bit long-winded, so here's the quick version: Why does this cause a runtime TypeLoadException? (And should the compiler prevent me from doing it?) interface I { void Foo<T>(); } class C<T1> { public void Foo<T2>() where T2 : T1 { } } class D : C<System.Object>, I { } The exception occurs if you try to instantiate D. Longer, more exploratory version: Consider: interface I { void Foo<T>(); } class C<T1> { public void Foo<T2>() where T2 : T1 { } } class some_other_class { } class D : C<some_other_class>, I { } // compiler error CS0425 This is illegal because the type constraints on C

SecurityException: ECall methods must be packaged into a system module

六月ゝ 毕业季﹏ 提交于 2019-11-29 05:24:55
I have a (C#) function similar to the following. private static bool SpecialCase = false; public void Foo() { if (SpecialCase) { InternalMethod(); return; } Console.WriteLine(); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern void InternalMethod(); When I execute this with the .NET Framework 4 inside the debugger, the method successfully prints blank line to the console and returns. When I execute it outside the debugger, it throws an exception with the following message: System.Security.SecurityException: ECall methods must be packaged into a system module. It appears the

Does a Silverlight memory profiler exist?

余生长醉 提交于 2019-11-29 04:18:21
CLR profiler does not seem to work with the Silverlight CLR. Does another memory profiler exist? Doesn't seem to be one available yet. However, as recommended in this forum thread , you can convert your Silverlight app to a WPF application and profile that: There is no tool as of now but as a workaround you can easily create a desktop (WPF) version of your Silverlight client from the same code base and few tweaks (refer Scot's blog for an example on this - http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-8-creating-a-digg-desktop-application-using-wpf.aspx ) . Once you are done

Number of CLR and GC instances running on a machine?

你离开我真会死。 提交于 2019-11-29 03:40:23
问题 I create 2 .NET applications and run them on a machine - how many CLR's and gc's will be there? In addition: I would like to have some background information on how Windows handles COM components and CLR in particular. Hope someone could detail down to how CLR loads in memory and what it means if I get multiple CLR instances listed on running this command: tasklist /m mscor* Is it multiple CLRs actually or a single CLR as a COM server for all .NET processes? 回答1: Each process will have its

Why value types can't be null

匆匆过客 提交于 2019-11-29 03:11:45
I know that it is possible to have Nullable value types that wraps the value type and gives ability to store null. But is there a technical reason do not allow the value type to be null or the reason is only conceptual? A reference type is storeed as a reference (like a pointer) to an object instance. null means a reference that isn't pointing to an instance of an object. Value types are stored as the values themselves, without any references. Therefore, it doesn't make sense to have a null value type—the value type by definition contains a value. Nullable<T> is a value type with a HasValue

What is the (fnptr)* type and how to create it?

帅比萌擦擦* 提交于 2019-11-29 02:50:06
问题 The following IL code creates a Type instance named (fnptr)* (token 0x2000000 - invalid, module mscorlib.dll). ldtoken method void* ()* call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) What's the purpose of this type? Is it possible to create this type instance in C# without writing any IL code, maybe with reflection? Module.ResolveType on the token throws ArgumentOutOfRangeException . Edit: It's clear the (fnptr) type is