clr

Garbage Collection and Threads

夙愿已清 提交于 2019-11-27 19:46:23
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 blocking all threads). I can imagine more robust mechanisms, but KISS often prevails. If I am incorrect my

Size of VARBINARY field in SQL Server 2005

有些话、适合烂在心里 提交于 2019-11-27 19:34:37
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. mwigdahl Actually, you can do this in T-SQL! DATALENGTH(<fieldname>) will work on varbinary(max) fields. John Sansom 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 column content. For example: SELECT DATALENGTH(CompanyName), CompanyName FROM Customers 来源:

Converting .NET App to x86 native code

一世执手 提交于 2019-11-27 19:24:04
There's a program written entirely in C# that targets .NET Framework 2.0. Is there a way I could somehow compile (translate) managed EXE to a native one so it could be .NET-agnostic? I know there are probably commercial products for that purpose... but they are a bit expensive. The problem is that we are to deploy the program on computers running Windows XP with no .NET Framework installed. There's also a requirement that the program's size must not exceed 500Kb (1Mb maximum) for it is downloaded from the web server (now the size is 255Kb). That is why there's no way we could attach a full

Why are immutable objects thread-safe?

こ雲淡風輕ζ 提交于 2019-11-27 19:19:59
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 the same memory location. One thread starts reading that memory, so isn't it "locked out" then? Does the

Why is an assembly .exe file?

自闭症网瘾萝莉.ら 提交于 2019-11-27 18:47:29
Assembly in .net Framework is, as I understand, intermediate language file + some metadata, manifest and maybe something else. CLR translates an assembly to the machine code, which can be executed on the given local machine. That means that assembly shouldn't be executable by the machine before being processed by CLR. If it's so, then why does it have .exe extension, which is executable on Windows machines? Since Windows needs to create a process and the first thing .exe will do is to host CLR by loading mscoree . From CLR via C# : After Windows has examined the EXE file's header to determine

CLR and CLI - What is the difference?

心已入冬 提交于 2019-11-27 18:41:47
I want to know what exactly is the difference between CLR & CLI? From whatever I have read so far, it seems to indicate that CLI is a subset of CLR. But isn't everything in the CLR mandatory? What exactly may be left out of CLR to create a CLI? The CLR is Microsoft's implementation of the CLI standard . CLR is the execution environment in which a .NET application is safely hosted/run. You can see it as .NET's private Operating System that initiates and loads just before a .NET application starts. The CLR takes care of certain essential requirements of any .NET application that otherwise would

Unable to load SqlServerSpatial.dll

孤街醉人 提交于 2019-11-27 18:31:58
I am trying to use the SqlServer Spatial CLR types in a C# .Net project. I want to use SqlGeometry to query spatial records out of my db. I have this working on my local machine in a unit test running in Visual Studio 2010 hitting a remote SqlServer machine. All good. I then publish a WCF Rest service to my local IIS instance that has a service that hits the same class library as the unit test to do some spatial querying and it fails. I get an error saying Unable to load DLL SqlServerSpatial.dll : The specified module could not be found. I have googled this and found many, many answers - none

“Object has been disconnected or does not exist at the server” exception

我只是一个虾纸丫 提交于 2019-11-27 18:29:00
I need to use cross-appdomain calls in my app, and sometimes I have this RemotingException: Object '/2fa53226_da41_42ba_b185_ec7d9c454712/ygiw+xfegmkhdinj7g2kpkhc_7.rem' has been disconnected or does not exist at the server. The target object is still alive, I have checked it. UPD I've set breakpoint in the finalizer of the target object, and it never hits. Thus, this object is alive and wasn't GC'ed. That is probably because the local garbage collector at the server side collects the object. You can prevent that by renewing the leasing. You can read more about that in these articles: Managing

Where is the .NET JIT-compiled code cached?

浪子不回头ぞ 提交于 2019-11-27 17:30:27
A .NET program is first compiled into MSIL code. When it is executed, the JIT compiler will compile it into native machine code. I am wondering: Where is these JIT-compiled machine code stored? Is it only stored in address space of the process? But since the second startup of the program is much faster than the first time, I think this native code must have been stored on disk somewhere even after the execution has finished. But where? Memory. It can be cached, that's the job of ngen.exe. It generates a .ni.dll version of the assembly, containing machine code and stored in the GAC. Which

What is the maximum length of a C#/CLI identifier?

∥☆過路亽.° 提交于 2019-11-27 15:26:27
Which other restrictions are there on names (beside the obvious uniqueness within a scope)? Where are those defined? From the PDF of ECMA-335 , Partition II, section 22, "Metadata preserves name strings, as created by a compiler or code generator, unchanged. Essentially, it treats each string as an opaque blob. In particular, it preserves case. The CLI imposes no limit on the length of names stored in metadata and subsequently processed by the CLI". If I've read this correctly and the context is correct then there's no actual limit to the length of an identifier in the CLR. In addition to the