clr

Can AppDomainManager be loaded by ProvideAssembly from a CLR Host?

走远了吗. 提交于 2019-12-07 15:44:42
问题 I have an application hosting the .net clr with a custom AppDomain Manager and an AssemblyManager with a store. This all works fine when the Assembly with the AppDomainManager in is a dll in the same directory as the executable. What I want to do is embed the Managers assembly inside the executable. When I do this ProvideAssembly is called with the correct strong name, I return a stream with the assembly bytes, but ICLRRuntimeHost->Start() returns an error indicating that a type cannot be

Dynamic code execution: String -> Runtime code VB.net

混江龙づ霸主 提交于 2019-12-07 13:51:06
问题 I'm trying to execute some code inside a string in runtime. I.E. Dim code As String = "IIf(1 = 2, True, False)" How do i run the code inside code string ? 回答1: As @ElektroStudios said - the proper way to do this is to use the CodeDom compiler, but this is a bit overkill for something as simple as this. You can sort of cheat and harness the power of a DataColumn Expression So for example: Dim formula = "IIF(Condition = 'Yes', 'Go', 'Stop')" Dim value As String = "Yes" Dim result As String 'add

Implementating functional languages for the CLR (Or, papers on the implementation of F#)

依然范特西╮ 提交于 2019-12-07 13:00:00
问题 Does anyone know of any good papers on the implementation of the F# compiler? I'm trying to generate CIL code for a simple functional language targeting the CLR, but I am struggling with a few aspects. The differences between functional languages and CIL are making it hard to generate well-typed CIL code. I have solutions that work via type erasure, but I'd much rather find a way to generate CIL code that reflects (to at least some extend) the Hindley-Milner type system of my source language

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

自闭症网瘾萝莉.ら 提交于 2019-12-07 11:45:12
问题 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

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

不打扰是莪最后的温柔 提交于 2019-12-07 10:45:02
问题 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

Restricting .Net CLR memory usage

与世无争的帅哥 提交于 2019-12-07 08:47:46
问题 Ok, so here's the problem. In our production environment (ASP.Net) our servers have a massive amount of memory as well as a massive number of users / sessions. My computer has 8 gigs, and I'm the only user. In production, we're (rarely) getting a System.OutOfMemoryException . With that background information, here is the question: is it possible to make the CLR think I only have a gig of memory or less? IIRC, there's a command-line option to do this for Java. Another option is to make some

When does the CLR load an assembly in a .NET process?

倖福魔咒の 提交于 2019-12-07 08:44:30
问题 Is a .NET assembly loaded by the CLR when a class from the assembly is referenced? Or When a class which declares the using namespace from the assembly is loaded? Also having loaded an assembly, does it ever unloads the assembly if it is not used for a long time? 回答1: It's the JIT compiler that instructs the CLR to load an assembly once it has translated it to machine code which is done on demand and the exact time is not deterministic. As to the second question, once an assembly is loaded

Preventing Thread.CurrentPrincipal from propagating across application domains

对着背影说爱祢 提交于 2019-12-07 07:51:38
问题 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

Using reflection to override virtual method tables in C#

£可爱£侵袭症+ 提交于 2019-12-07 07:51:33
问题 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 } } 回答1: Take a look at LinFu. On Linfu's author's Blog there's an example of

CLR Profiler and 0 Heap Statistics

僤鯓⒐⒋嵵緔 提交于 2019-12-07 07:48:09
问题 Why would I get 0 for my heap statistics allocation for an ASP.NET MVC web application with CLR profiler? 回答1: I was getting zeroes, but I think doing these two things solved the issue of zeroes: make sure you have "Allocations" checked in the "Profile" section and be sure to end the application before trying to see the profiling info. Either end it through CLR Profiler ("Kill Application") or from within the application itself. I believe both of those things were required to make it work for