clr

MSSQL 2012 creating CLR triggers for WCF fails

本秂侑毒 提交于 2019-12-03 12:24:01
问题 I've created system that uses CLR triggers to connect to WCF server and notify it about changes in DB. It runs ok on SQL server 2008 R2. Now im trying to migrate on SQL Server 2012. To use WCF i need to load SMDiagnostics.dll assembly along the others. Ive checked that clr is enabled in db , and set trustworthy to be "on", ive disabled WCF debuging, ive checked that SQL server runs under Local System account so there is no problems with permissions. Now my problem is that when i run following

How do you protect yourself from runaway memory consumption bringing down the PC?

一笑奈何 提交于 2019-12-03 12:18:11
Every now and again I find myself doing something moderately dumb that results in my program allocating all the memory it can get and then some. This kind of thing used to cause the program to die fairly quickly with an "out of memory" error, but these days Windows will go out of its way to give this non-existent memory to the application, and in fact is apparently prepared to commit suicide doing so. Not literally of course, but it will starve itself of usable physical RAM so badly that even running the task manager will require half an hour of swapping (after all the runaway application is

List closed types that runtime has created from open generic types

懵懂的女人 提交于 2019-12-03 12:13:59
When I list all the types in the current AppDomain, I see my generic types with the generic placeholders. However, if I instantiate my generic types with a type and then list all the types in the appDomain, I don't see the newly created closed types. In the example below, the output is only: Foo`1[T] I'm looking for the closed type: Foo`1[System.Int32] Is there a way to see the closed types that the runtime has created for me based on my open generic types? class Foo<T> { } class Program { static void Main(string[] args) { var tmp = new Foo<int>(); ListTypes(); } private static void ListTypes(

decimal in c# misunderstanding?

一笑奈何 提交于 2019-12-03 12:01:36
(while trying to analyze how decimal works ) && after reading @jonskeet article and seeing msdn , and thinking for the last 4 hours , I have some questions : in this link they say something very simple : 1.5 x 10^2 has 2 significant figures 1.50 x 10^2 has 3 significant figures. 1.500 x 10^2 has 4 significant figures etc... ok...we get the idea. from jon's article : sign * mantissa / 10^exponent As usual, the sign is just a single bit, but there are 96 bits of mantissa and 5 bits of exponent ^ _ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^___ ^^^^^ 1 _ 96 5 ok so max mantiss val = 2^96-1 =

.net clr method table structure

谁说我不能喝 提交于 2019-12-03 11:57:22
I'm currently reading book titled Pro .NET Performance. One of its chapters contains detailed information about reference types internal structure. Method table is one of the internal fields of reference type layout structure. It is said in this book that method table consists of information about ALL methods of a class. I'm trying to check this theory with a little program class MyClass { public void M() { } } static void Main(string[] args) { MyClass m = new MyClass(); m.M(); Console.ReadLine(); } I start this program with WinDbg My WinDbg session looks like the following !clrstack -a

Overlaying several CLR reference fields with each other in explicit struct?

若如初见. 提交于 2019-12-03 11:45:49
Edit: I'm well aware of that this works very well with value types, my specific question is about using this for reference types. Edit2: I'm also aware that you can't overlay reference types and value types in a struct, this is just for the case of overlaying several reference type fields with each other. I've been tinkering around with structs in .NET/C#, and I just found out that you can do this: using System; using System.Runtime.InteropServices; namespace ConsoleApplication1 { class Foo { } class Bar { } [StructLayout(LayoutKind.Explicit)] struct Overlaid { [FieldOffset(0)] public object

Do all C# casts result in boxing/unboxing

丶灬走出姿态 提交于 2019-12-03 11:38:03
I am curious to know if all casts in C# result in boxing, and if not, are all casts a costly operation? Example taken from Boxing and Unboxing (C# Programming Guide) int i = 123; // The following line boxes i. object o = i; This line obviously causes boxing (wrapping up the int type as an object). This is an operation that is considered costly, since it creates garbage that will be collected. What about casts from 2 different types of reference types? what is the cost of that? can it be properly measured? (compared to the previous example) For example: public class A { } public class B : A { }

Is it possible to use branch prediction hinting in C#?

大兔子大兔子 提交于 2019-12-03 11:01:41
For example, I know it is defined for gcc and used in the Linux kernel as: #define likely(x) __builtin_expect((x),1) #define unlikely(x) __builtin_expect((x),0) If nothing like this is possible in C#, is the best alternative to manually reorder if-statements, putting the most likely case first? Are there any other ways to optimize based on this type of external knowledge? On a related note, the CLR knows how to identify guard clauses and assumes that the alternate branch will be taken, making this optimization inappropriate to use on guard clases, correct? (Note that I realize this may be a

Are .NET threads different from operating system threads?

假如想象 提交于 2019-12-03 10:55:31
Are .NET threads lightweight user-mode threads or are they kernel-mode operating system threads? Also, sparing SQL Server, is there a one-to-one correspondence between a .NET thread an an operating system thread? I am also intrigued because the Thread class that has a symmetric pair of methods named BeginThreadAffinity and EndThreadAffinity , whose documentation subtly suggests that .NET threads are lightweight abstractions over real operating system threads. Also, I read a while ago on some stack overflow thread itself that Microsoft scratched an attempt to maintain this separation in the CLR

What are the differences in JIT between Java and .Net

蹲街弑〆低调 提交于 2019-12-03 10:37:25
I know Microsoft .NET uses the CLR as a JIT compiler while Java has the Hotspot. What Are the differences between them? They are very different beasts. As people pointed out, the CLR compiles to machine code before it executes a piece of MSIL. This allows it in addition to the typical dead-code elimination and inlining off privates optimizations to take advantage of the particular CPU architecture of the target machine (though I'm not sure whether it does it). This also incurs a hit for each class (though the compiler is fairly fast and many platform libraries are just a thin layer over the