clr

Garbage Collection and Threads

久未见 提交于 2019-11-26 20:01:53
问题 AFAIK when a GC is doing its thing the VM blocks all running threads -- or at least when it is compacting the heap. Is this the case in modern implementions of the CLR and the JVM (Production versions as of January 2010) ? Please do not provide basic links on GC as I understand the rudimentary workings. I assume global locking is the case as when compaction occurs references might be invalid during the move period, and it seems simplest just to lock the entire heap (i.e., indirectly by

Size of VARBINARY field in SQL Server 2005

大兔子大兔子 提交于 2019-11-26 19:58:39
问题 I am trying to determine the size in bytes of the contents in a VARBINARY(MAX) field in SQL Server 2005, using SQL. As I doubt there is native support for this, could it be done using CLR integration? Any ideas would be greatly appreciated. 回答1: Actually, you can do this in T-SQL! DATALENGTH(<fieldname>) will work on varbinary(max) fields. 回答2: The VARBINARY(MAX) field allocates variable length data up to just under 2GB in size. You can use DATALENGTH() function to determine the length of the

Why are immutable objects thread-safe?

こ雲淡風輕ζ 提交于 2019-11-26 19:49:39
问题 class Unit { private readonly string name; private readonly double scale; public Unit(string name, double scale) { this.name = name; this.scale = scale, } public string Name { get { return name; } } public string Scale { get { return scale; } } private static Unit gram = new Unit("Gram", 1.0); public Unit Gram { get { return gram; } } } Multiple threads have access to Unit.Gram . Why is it ok for multiple threads simultaneously read Unit.Gram.Title ? My concern is that they are referring to

Hosting CLR in Delphi with/without JCL - example

我只是一个虾纸丫 提交于 2019-11-26 19:46:02
Can somebody please post here an example how to host CLR in Delphi? I have read similar question here but I cannot use JCL as I want to host it in Delphi 5. Thank you. EDIT: This article about hosting CLR in Fox Pro looks promising but I don't know how to access clrhost.dll from Delphi. Edit 2: I give up on Delphi 5 requirement. Now I'm trying JCL with Delphi 7. But again I am unable to find any example. Here is what I have till now: My C# assembly: namespace DelphiNET { public class NETAdder { public int Add3(int left) { return left + 3; } } } I have compiled it to DelphiNET.dll . Now I want

How do the .NET Framework, CLR and Visual Studio version numbers relate to each other?

跟風遠走 提交于 2019-11-26 19:28:41
With the recent announcement of .NET 4.0 and Visual Studio 2010, it is becoming ever more difficult to keep track of what .NET Framework versions build on what version of the CLR and belong with which version(s) of Visual Studio. Is there a definitive table that shows these relationships? Scott Dorman Visual Studio CLR .NET Framework ---------------------------------------------------------------------------------------- Visual Studio .NET (Ranier) 1.0.3705 1.0 Visual Studio 2003 (Everett) 1.1.4322 1.1 Visual Studio 2005 (Whidbey) 2.0.50727 2.0 Visual Studio 2005 with .NET 3.0 Extensions 2.0

Why is stack size in C# exactly 1 MB?

允我心安 提交于 2019-11-26 19:27:33
Today's PCs have a large amount of physical RAM but still, the stack size of C# is only 1 MB for 32-bit processes and 4 MB for 64-bit processes ( Stack capacity in C# ). Why the stack size in CLR is still so limited? And why is it exactly 1 MB (4 MB) (and not 2 MB or 512 KB)? Why was it decided to use these amounts? I am interested in considerations and reasons behind that decision . You are looking at the guy that made that choice. David Cutler and his team selected one megabyte as the default stack size. Nothing to do with .NET or C#, this was nailed down when they created Windows NT. One

.NET 4.0 and the dreaded OnUserPreferenceChanged Hang

℡╲_俬逩灬. 提交于 2019-11-26 18:59:19
I have been plagued with the dreaded OnUserPreferenceChanged Hang that's refered to quite nicely by Ivan Krivyakov, here: http://ikriv.com/en/prog/info/dotnet/MysteriousHang.html#BeginInvokeDance I posted a question a while back, when I originally encountered the problem: Yet another C# Deadlock Debugging Question I thought I had solved it by removing a Control that was constructed off the UI thread, but after a little while it reappeared (probably never left...). We've been using .NET 3.5, which I understand uses CLR 2.0. Recently, the applciation has been upgraded to use .NET 4.0 Client

Initialization of instance fields vs. local variables

霸气de小男生 提交于 2019-11-26 18:56:10
I have always been wondering about why in the following example it is OK to not initialize the instance field (relying that it will have its default value) and accessing it, while local variables apparently must be initialized, even if I initialize it to default value it would get anyway... public class TestClass { private bool a; public void Do() { bool b; // That would solve the problem: = false; Console.WriteLine(a); Console.WriteLine(b); //Use of unassigned local variable 'b' } } For local variables, the compiler has a good idea of the flow - it can see a "read" of the variable and a

Canonical: How to call .NET methods from Excel VBA

自闭症网瘾萝莉.ら 提交于 2019-11-26 18:55:49
I have found a way to call .NET 2 code directly from a VBA macro: Dim clr As mscoree.CorRuntimeHost Set clr = New mscoree.CorRuntimeHost clr.Start Dim domain As mscorlib.AppDomain clr.GetDefaultDomain domain Dim myInstanceOfDotNetClass As Object Set myInstanceOfDotNetClass = domain.CreateInstanceFrom("SomeDotNetAssembly.dll", "Namespace.Typename").Unwrap Call myInstanceOfDotNetClass.ExecuteSomeDotNetMethod (To make this code work I had to add references to mscoree.tlb and mscorlib.tlb to the Excel VBA using Tools -> References.. in Excel) But this only works for .NET CLR 2 assemblies, up to

What is a “rooted reference”?

荒凉一梦 提交于 2019-11-26 18:53:59
Quote from ( Safe in C# not in C++, simple return of pointer / reference, answer 3) by Eric lippert. Also, note that it is not any reference to the Person object that keeps it alive. The reference has to be rooted. You could have two Person objects that reference each other but are otherwise unreachable; the fact that each has a reference does not keep them alive; one of the references has to be rooted. I dont understand, can someone explain what a rooted reference is? It means a GC root. Have a read through this article , maybe it will help with your understanding: GC roots are not objects in