clr

I'm confused about default access modifier of C# interface members [duplicate]

陌路散爱 提交于 2019-12-05 18:08:37
This question already has answers here : Why are C# interface methods not declared abstract or virtual? (6 answers) Closed 6 years ago . What is the access modifier of interface methods? It should be public or protected because you have access to them when you implement them (which makes sense). It also should be abstract because they don't have implementation. But lately I've been reading a book called CLR Via C# and the chapter about interfaces says the following The CLR requires that interface methods be marked as virtual . If you do not explicitly mark the method as virtual in your source

GCHandle.FromIntPointer does not work as expected

好久不见. 提交于 2019-12-05 17:13:25
Here's a very simple (complete) program for exercising the use of GCHandle.FromIntPointer: using System; using System.Runtime.InteropServices; namespace GCHandleBugTest { class Program { static void Main(string[] args) { int[] arr = new int[10]; GCHandle handle = GCHandle.Alloc(arr, GCHandleType.Pinned); IntPtr pointer = handle.AddrOfPinnedObject(); GCHandle handle2 = GCHandle.FromIntPtr(pointer); } } } Note that this program is essentially a transliteration of the procedure described in English on CLR via C# (4e) on page 547. Running it, however, results in an unmanaged exception like:

How do I find out what CLR i am using?

自闭症网瘾萝莉.ら 提交于 2019-12-05 17:06:19
Is there something available that tells me what .NET version I am using and whether it is .NET 2.0 SP1? Thanks You can use Environment.Version to find the version of the CLR you are running on. This can be checked against the list of framework version numbers . For .NET 2.0 SP1 you'd be looking to match 2.0.50727.1433. 来源: https://stackoverflow.com/questions/2161119/how-do-i-find-out-what-clr-i-am-using

Preventing Thread.CurrentPrincipal from propagating across application domains

拟墨画扇 提交于 2019-12-05 16:14:22
Does anyone if it's possible to stop the current thread's IPrincipal from propagating over an application domain boundary? I have no control over the IPrincipal that's assigned to the thread, but I do have control over creating the application domains. (The reason I want to do this is to prevent a serialization error from occuring if the principal object type's assembly is unavailable in the other domain.) Edit: ExecutionContext.SuppressFlow looks promising, but it doesn't appear to achieve the goal. The following prints "MyIdentity": static void Main () { ExecutionContext.SuppressFlow ();

Manual Memory Paging in the .Net Framework (Is it possible / How?)

时间秒杀一切 提交于 2019-12-05 16:09:08
I have a major interest in writing a database management system. Having read a few pages about how SQL Server 2000 was implemented, I discovered that 4KB memory pages were used, each being a direct copy of a 4KB page on the hard disk. These pages were loaded into RAM as needed, and then lazily wrote back to disk when they fell idle (oversimplification). Being in the planning stage of my project, I am wondering if this level of control is possible in code running on the CLR. I realize that C, C++, or D is probably a better fit for this task, but I would like to prove that to myself first. Part

Fatal Execution Error on Browser.ReadyState [duplicate]

前提是你 提交于 2019-12-05 16:06:20
Possible Duplicate: Troubleshooting .NET “Fatal Execution Engine Error” My code is throwing a Fatal Execution Error. The exact error is this: The runtime has encountered a fatal error. The address of the error was at 0xed40646c, on thread 0x2044. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack. I'm not using unsafe user code as far as I know. The code which is causing the issue is this one: WebClient client

Is it possible to link a method marked with MethodImplOptions.InternalCall to its implementation?

坚强是说给别人听的谎言 提交于 2019-12-05 15:23:21
In trying to find the possible cause of an exception, I'm following a code path using Reflector. I've got deeper and deeper, but ended up at a method call that looks like: [MethodImpl(MethodImplOptions.InternalCall)] private extern void SomeMethod(int someParameter); This markup on the method tells the framework to call a C++ function somewhere. Is there any way to find out what method actually gets called, and in turn what else is likely to be called? NB: I don't really want to see the source code of this method, I just want to know the possible things that could throw the exception I am

Derived method stronger than override in c#?

你说的曾经没有我的故事 提交于 2019-12-05 15:18:12
( again annoying question... ) after asking this before - ( which is partly related to my question) - i got an answer : See §7.6.5.1 of the C# 4 spec: The set of candidate methods is reduced to contain only methods from the most derived types: For each method C.F in the set, where C is the type in which the method F is declared, all methods declared in a base type of C are removed from the set. ok. i have this code : // .Dump() is like a WriteLine command... public class Base { public void Foo(string strings) { "1".Dump();} public virtual void Foo(object strings) { "2".Dump();} } public class

Cannot obtain value because it has been optimized away

本小妞迷上赌 提交于 2019-12-05 14:25:39
问题 I have a problem with debugging... All of a sudden I can't see the values of most variables while debugging. I've managed to get two different messages in the Immediate Window: Cannot obtain value of local or argument 'parameter' as it is not available at this instruction pointer, possibly because it has been optimized away. and Internal error in the expression evaluator. I've tried and checked the following things: Solution Configuration is set to debug ( not release) Project -> Settings ->

Using reflection to override virtual method tables in C#

别等时光非礼了梦想. 提交于 2019-12-05 14:25:19
Is there a way to change the virtual methods tables in C#? like change where a virtual method is pointing? class A { public virtual void B() { Console.WriteLine("B"); } } class Program { public static void MyB(A a) { Console.WriteLine("MyB"); } public static void Main(string[] Args) { A a = new A(); // Do some reflection voodoo to change the virtual methods table here to make B point to MyB a.B(); // Will print MyB } } Take a look at LinFu . On Linfu's author's Blog there's an example of using LinFu.AOP to intercept and change calls even to methods of classes that you don't control directly.