Should ConditionalWeakTable be used for non-compiler purposes?

I don’t see anything wrong with using ConditionalWeakTable. If you need ephemerons, you pretty much have no other choice. I don’t think future .NET versions will be a problem – even if only compilers would use this class, Microsoft still couldn’t change it without breaking compatibility with existing binaries. As for overhead – there certainly … Read more

What is CLR hosting?

See here for information about CLR hosting that was relevant for CLR v2 (.NET 2.0, 3.0 and 3.5). For information about the newer CLR Hosting API in .NET 4.0, see here. Basically, the CLR acts as a library that can be loaded and “hosted” by a process. You can develop an app that loads and … Read more

How to call .NET methods from Excel VBA?

Here is a canonical answer on the 3 main methods to call .Net from Excel (or VBA). All three ways work in .Net 4.0. 1. XLLs The 3rd party vendor Add-In Express offer XLL functionality, however its free and easy to use Excel-DNA the author is here https://stackoverflow.com/users/44264 Here is an extract from the Excel-DNA … Read more

JIT vs NGen – what is the difference?

The difference is when they occur. The JIT compilation occurs while your program is running. NGen is a typically done at installation time of your program and happens before your program is run. One of the goals of NGen is to remove the JIT penalty from application start up.

Unable to load SqlServerSpatial.dll

I had the same problem on a Windows Server 2012 machine. It had an SqlServerSpatial110.dll file in \Windows\System32, but no SqlServerSpatial.dll. The solution was installing the Microsoft System CLR Types for SQL Server 2008 R2 on the machine. http://www.microsoft.com/en-us/download/details.aspx?id=26728 Click Download Check off one of these depending on your processor architecture: 1033\x64\SQLSysClrTypes.msi 1033\x86\SQLSysClrTypes.msi 1033\IA64\SQLSysClrTypes.msi Click … Read more

What happens when a .net application is started?

Hmm, let me take a shot at this too. Somebody builds a .NET application in C#, or .NET ‘Intermediate Language’, or another managed language. The compiler for that language csc.exe (C#), or ilasm.exe (bytecode assembler), or whichever, produces a PE executable. The PE executable has a specific structure that the compiler or assembler populates. That … Read more

Why does null exist in .NET?

We’ve got Tony Hoare, an early pioneer that worked on Algol to thank for that. He rather regrets it: I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W). … Read more

.Net 4.0 Windows Application crashes in clr.dll under Windows Server 2008

I’m having the same issue. At approximately 8-10 hours of application life CLR error rises. I suspected my unmanaged code generating exception in the background thread. However I could not really find out why. You can give the following a try however: If you are using unmanaged code review exception handling statements while executig it. … Read more

C# casting to nullable type?

In your first example, the as operator attempts to use the object s as an int?. Since int? isn’t anywhere in the inheritance chain of short?, this operation fails. In your second example, you’re actually creating a new int? i with the value from short? s. This is a more generous operation, because it doesn’t … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)