clr

Type map from System.Type to xs:type

Hi, Is there a standard (framework) mapping between CLR types and xsd type codes. I need to convert a string, int, decimal etc to the equivalent XmlSchemaSimpleType. I can construct the necessary simple type and use a case statement to do the mappings myself. I was hoping their might be a standard framework class that can either constr...

Nothing != null - or does it?

Recently in a previous project I came across a peculiar difference between VB.NET and C#. Consider the following C# expression which: null <= 2 This expression evaluates to False which is what I would expect. Then the corresponding VB.NET expression: Nothing <= 2 I was surprised to learn that this expression actually evaluates to ...

Is there any tutorial on compiling C lib with Pure MSIL Common Language Runtime Support (/clr:pure) with VS? (VS10)

Is there any tutorial on compiling C lib with Pure MSIL Common Language Runtime Support (/clr:pure) with VS? (VS10) (eg x264 lib) ...

A way How to Compile C library into .Net dll ?

Can we compile C library as .Net dll (containing and opening access to all C libs functions) by just compiling cpp project containing code like extern "C" { #include <library.h> } with /clr:pure argument with VS? (VS10) Or we should do something more trickey? ...

How you use technique (described) to work with C structures and pointers from .Net?

How you use technique described here to work with C structures from .Net? Ofcourse I need a code example - on 3 parts: C declaring parts, C++ wrapping around C and C# acsessing. So what I wonder Is C structture A has as one of its params structure B which consists of at least 2 types one of which is pointer to some variable C which ...

setlocale() is not affecting ConvertBSTRToString() but system-wide setting does?

Given: ASP.Net application which uses a legacy COM library legacy COM library which is built without Unicode (MBCS) Windows 2008 dev server on which it all runs Needed: support web app users in different locales Test: 1) I set the system locale on the server to Russian and tested Russian inputs. .NET treats them as UTF16, passes o...

Is CLR loaded and initialized everytime,when a new managed application is loaded ?

Is CLR loaded and initialized everytime, when a new managed application is loaded and there is a managed application already present? e.g. If on my machine, application "TestApp" is running and after that I start another application "DemoApp". In this case, wiill CLR be loaded again for DemoApp? Or it will use the same one which is load...

Why doesn't the CLR always call value type constructors

Hi, I have a question concerning type constructors within a Value type. This question was inspired by something that Jeffrey Richter wrote in CLR via C# 3rd ed, he says (on page 195 - chapter 8) that you should never actually define a type constructor within a value type as there are times when the CLR will not call it. So, for example...

SSE2 instruction support with /CLR switch.

Why isn't the SSE2 enhanced instruction set optimization available for C++ programs compiled with the /clr switch? ...

How can I make my DynamicMethod security-critical?

I have a rather convoluted scenario where I want to create a DynamicMethod that's attached to a class in an in-memory AssemblyBuilder. The dynamic method calls a method "GetReplacement" in a (regular) assembly of mine. This worked fine in .NET 2.0, but in .NET 4.0 I get an error: MethodAccessException: Attempt by security transparent m...

Accuracy of Math.Sin() and Math.Cos() in C#

I am terribly annoyed by the inaccuracy of the intrinsic trig functions in the CLR. It is well know that Math.Sin(Math.PI)=0.00000000000000012246063538223773 instead of 0. Something similar happens with Math.Cos(Math.PI/2). But when I am doing a long series of calculations that on special cases evaluate to Math.Sin(Math.PI/2+x)-M...

Add static library to CLR Windows Forms Project, Get "unresolved external symbol _MAIN__"

I've reduced this issue to, with Visual Studio 2005, in Release mode: Create a new Windows Forms app Change to /CLR Check that the default Form1 runs Add one static library (which itself is linked with BLAS.lib, clapack.lib, libf2c.lib) Then I compile and link and get error LNK2019: unresolved external symbol MAIN_ referenced in...

How does .Net CLR implement an "Interface" internally?

Hi All, Just curious about how .NET CLR handles interfaces internally? Q1] What happens when CLR encounters something like : simple interface example. (same used below.) interface ISampleInterface { void SampleMethod(); } class ImplementationClass : ISampleInterface { // Explicit interface member imp...

When linking a .NET 2.0 Managed Assembly from a .NET 4.0 Application, which framework is used?

If I have a 2.0 CLR assembly (pure managed code, no mixed mode issues) that I need to link to from a 4.0 CLR Application, does the 2.0 code run on the 2.0 CLR or 4.0. Basically, is there any risk of 4.0 breaking changes affecting the 2.0 code? ...

Get notification of object disposal/destruction

I need a way to track instances of various classes, without those classes having any knowledge that they are being tracked. Essentially, I have a class factory which creates instances and hands them off to another thread. Once that thread completes and unloads the instance, I need to get notified of that so I can do reference counting an...

Haskell for the .net platform?

I'm a .NET developer by day, but have been playing with Haskell in my spare time for awhile now. I'm curious: any Haskell .net implemenations in the same vein as IronPython? ...

Is .NET VM a compiler or an interpreter?

Does the .NET's Virtual Machine compiles the CIL bytecode (and then execute the code at the lowest level - CPU assembler), or it is an interpreter (that reads the following instructions and execute them) ? ...

SQL Server 2008: Exception when excecuting CLR function which tries to access database through a connection

I want to use CLR table-valued function in SQL Server 2008, which accesses a database from inside itself. I've got a permission exception. I am trying to execute function as the same user as under which it was created. So cause of the problem is not clear.. Here is the function: public partial class MyClass { [SqlFuncti...

.NET 4 side-by-side execution, what is loaded in which case?

I've been doing a bit of investigative work into .NET 4 side-by-side execution recently and, while I have found out a fair amount, there are still some open questions in my mind. My queries are really around in-process loading of libraries into client applications. If I have a client application that uses v4.0 of the CLR then my underst...

Is the .NET JIT-compiled code cached? Where?

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 th...