clr

What are the benefits of using Scala in .Net?

Scala is a peculiar programming language in that it targets both JVM and the CLR. But what are the benefits? Is it worth considering it as a viable alternative to the F# language? ...

Why are immutable objects thread-safe?

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

How slow is NaN arithmetic in the Intel x64 FPU?

Hints and allegations abound that arithmetic with NaNs can be 'slow' in hardware FPUs. Specifically in the modern x64 FPU, e.g on a Nehalem i7, is that still true? Do FPU multiplies get churned out at the same speed regardless of the values of the operands? I have some interpolation code that can wander off the edge of our defined data...

Degree of C# support in SQL CLR user-defined function?

Hi, This may be naive but I cannot get any confirmation of this: When I write a SQL function via the SQLCLR and as a C# SQL Server Project, can the SQL function include any method/class/namespace in the .NET BCL? Are there any restrictions on what the function can do? I have full control of the SQL Server and its hosting OS, so I can am...

Assembly locking rules and when is shadow copy useful ?

Hello, from what I've understood so far, by reading this doc for instance : http://msdn.microsoft.com/en-us/library/ms404279.aspx, Shadow copy is a feature that allows the use of an assembly while currently loaded by an application. From the above doc : The common language runtime locks an assembly file when the assembly is loaded,...

How do I learn enough about CLR to make educated guesses about performance problems?

Yes, I am using a profiler (ANTS). But at the micro-level it cannot tell you how to fix your problem. And I'm at a microoptimization stage right now. For example, I was profiling this: for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { packedCells.Add(Data[x, y].HasCar); packedCells.Add(Data[x, ...

Can we use "Boost" librarys in our own librarys compiled under CLR?

So it is easy to create a win 32 project and use boost. I did not tried it yet but I plan to. I wonder If I can use boost in CLR mode. Is it possible? Has any one tried? ...

Would the CLR optimize and inline this GetHashCode()?

Let's say we have a value type like this, where the fields are readonly and initialized during construction: public struct SomeValue { private readonly Int32 field1; private readonly Int32 field2; ... } Also, let's say we have a helper class that lets us implement GetHashCode() for composite types in a reusable manner: p...

Usages of object resurrection

I have a problem with memory leaks in my .NET Windows service application. So I've started to read articles about memory management in .NET. And i have found an interesting practice in one of Jeffrey Richter articles. This practice name is "object resurrection". It looks like situating code that initializes global or static variable to "...

Showing .NET child window under Win32 unmanaged host

I am writing now plugin for FL Studio 9. I have sdk which is intended to work fine with MFC or Win32 Visual C++ 2008 Project. The question is how to make CLR C++ plugin work in Win32 Application in general? I've build the plugin correctly - it is loaded by FL Studio, but only one thing which works is plugin Width and Height properties of...

Should we always include a default constructor in the class?

I have been asked this question by a colleague that should we always include a default constructor in a class? If so, why? If no, why not? Example public class Foo { Foo() { } Foo(int x, int y) { ... } } I am also interested to get some lights on this from experts. ...

Is a ret instruction required in .NET applications?

I noticed that the C# compiler generates a ret instruction at the end of void methods: .method private hidebysig static void Main(string[] args) cil managed { // method body L_0030: ret } I've written a compiler for .NET and it works regardless if I emit a ret statement or not (I've checked the generated IL and it's indeed n...

How to create a custom .NET base class library (BCL) aka mscorlib replacement?

Does anybody know how to make a custom BCL work with the stock CLR? How to discover existing the most essential ties between CLR and BCL and reuse them? Here is what I have so far: http://lightnet.codeplex.com ...

CLR detected an Invalid Program

Need any help, ideas to figure out this issue. We are working on an application that makes a call to SAP for posting some data using ERPConnect. We encounter the following issues in one of our Entity Framework call in our WCF service. We are using .NET4.0, Win 2008 Server. The following information was included with the event: excep...

Examples of CLR compiler optimizations

I'm doing a presentation in few months about .Net performance and optimization, I wanted to provide some samples of unnecessary optimization, things that will be done by the compiler anyways. where can I find some explanation on what optimizations the compiler is actually capable of maybe some before and after code? ...

running code in remote process CLR runtime through ICLRRuntimeHost and ExecuteInDefaultAppDomain()

I tried to combine the examples at coding the wheel and profiler attach. Everything seems to go fine, except, when I try to enumerate running assemblies in the remote processes' default appdomain, I don't get the right list. public class remoteFoo { public static int sTest(String message) { AppDomain currentDomain = AppDomai...

Call a WCF Service from a SQL CLR procedure in C#

I'm trying to call a WCF Service from a SQL Stored Procedure written in C#. I saw various posts or questions on about the same topic : http://stackoverflow.com/questions/3502343/calling-a-wcf-service-from-sql-clr-stored-procedure http://stackoverflow.com/questions/751500/sql-clr-stored-procedure-and-web-service But there's something I ...

Why would System.Type.GetType("Xyz") return null if typeof(Xyz) exists?

I have come across a strange behaviour in my (huge) .NET 4 project. At some point in the code, I am referring to a fully qualified type, say: System.Type type = typeof (Foo.Bar.Xyz); later on, I do this: System.Type type = System.Type.GetType ("Foo.Bar.Xyz"); and I get back null. I cannot make sense of why this is happening, becaus...

Calling a c# .dll from native visual c++ code

Hello, the system I'm working with consists of: A front-end application written in most likely VB or else VC++ (don't know, don't and can't have the sources for it) An unmanaged VC++ .dll A C# .dll The application calls the first dll, the first dll calls different methods from the second one. In order to make the first dll able to se...

C# Generics with IronPython Type Parameters

So, the situation is I have a C# generic class named Foo with a template parameter T which has the new() constraint. I've declared my classes something like this: class Baz { public Baz() { } } class Foo<T> where T : Baz, new() { // blah blah } And in Python: class Bar(Baz): def __init__(self): """ do various...