clr

How CLR works when invoking a method of a struct

谁说我不能喝 提交于 2019-11-27 01:42:13
问题 I think I've known the answer for a class, just want to confirm my understanding is correct. Let's say I have a ClassA and its instance named a . When a.MethodA() is invoked: (1) CLR find the type of ClassA by the type pointer of a in the heap(the type have been loaded into the heap) (2) Find the MethodA in the type, if not found, go to its base type, until the object class. Maybe my understanding is not quite precise, but I think it's basicly correct(Correct me if it's wrong!). And here

Creating a pure MSIL assembly from a C++/CLI project?

匆匆过客 提交于 2019-11-27 01:11:49
问题 I am trying to create a pure MSIL assembly from a C++/CLI project using /clr:pure and /clrimagetype:pure flags, however, the output assembly specifically targets x86. Am I missing anything that might be preventing my project to be compiled as MSIL only? 回答1: You can create an AnyCPU dll with C++/CLI , but in the simplest case, you will not be able to use MFC, ATL or the CRT. However, if you just want to write pure managed .NET code in C++/CLI, including managed pointers (which /clr:safe does

calling managed c# functions from unmanaged c++

随声附和 提交于 2019-11-27 01:09:06
问题 How to call managed c# functions from unmanaged c++ 回答1: Or use a project of mine that allows C# to create unmanaged exports. Those can be consumed as if they were written in a native language. 回答2: I used COM interop first, but by now I switched to IJW (it just works), as it is a lot simpler. I have a wrapper C++/CLR DLL (compile with /clr). A simple example (using statics to make the calls easier): namespace MyClasses { public class MyClass { public static void DoSomething() { MessageBox

Is there a high resolution (microsecond, nanosecond) DateTime object available for the CLR?

旧街凉风 提交于 2019-11-27 01:04:41
问题 I have an instrument that stores timestamps the microsecond level, and I need to store those timestamps as part of collecting information from the instrument. Note that I do not need to generate timestamps; these time stamps are pre-generated by the instrument itself using a high resolution real-time operating system. Parsing out these values is not an issue — they are stored using a standard format in UTC time. Originally I wanted to use the C# DateTime structure can only store time stamps

Calling C# from C++, Reverse P/Invoke, Mixed Mode DLLs and C++/CLI

喜夏-厌秋 提交于 2019-11-27 01:02:29
问题 As I understand it I can use reverse P/Invoke to call C# from C++. Reverse P/Invoke is simply a case of: Create you managed (c#) class. Create a c++/cli (formerly managed c++) class library project. Use this to call the managed c# class (presumably via a reference). Call the c++/cli code from native c++. Questions: Is this correct? Is the DLL created at step 2 known as a mixed mode DLL? Has C++/CLI completely superseded Managed C++ as far as MS are concerned? Is COM completely avoided using

Is casting the same thing as converting?

霸气de小男生 提交于 2019-11-27 00:58:59
In Jesse Liberty's Learning C# book, he says "Objects of one type can be converted into objects of another type. This is called casting." If you investigate the IL generated from the code below, you can clearly see that the casted assignment isn't doing the same thing as the converted assignment. In the former, you can see the boxing/unboxing occurring; in the latter you can see a call to a convert method. I know in the end it may be just a silly semantic difference--but is casting just another word for converting. I don't mean to be snarky, but I'm not interested in anyone's gut feeling on

Float vs Double Performance

ぃ、小莉子 提交于 2019-11-27 00:11:34
I did some timing tests and also read some articles like this one (last comment), and it looks like in Release build, float and double values take the same amount of processing time. How is this possible? When float is less precise and smaller compared to double values, how can the CLR get doubles into the same processing time? On x86 processors, at least, float and double will each be converted to a 10-byte real by the FPU for processing. The FPU doesn't have separate processing units for the different floating-point types it supports. The age-old advice that float is faster than double

Why does struct alignment depend on whether a field type is primitive or user-defined?

余生颓废 提交于 2019-11-27 00:01:00
问题 In Noda Time v2, we're moving to nanosecond resolution. That means we can no longer use an 8-byte integer to represent the whole range of time we're interested in. That has prompted me to investigate the memory usage of the (many) structs of Noda Time, which has in turn led me to uncover a slight oddity in the CLR's alignment decision. Firstly, I realize that this is an implementation decision, and that the default behaviour could change at any time. I realize that I can modify it using

How does C# compilation get around needing header files?

那年仲夏 提交于 2019-11-26 23:54:35
问题 I've spent my professional life as a C# developer. As a student I occasionally used C but did not deeply study it's compilation model. Recently I jumped on the bandwagon and have begun studying Objective-C. My first steps have only made me aware of holes in my pre-existing knowledge. From my research, C/C++/ObjC compilation requires all encountered symbols to be pre-declared. I also understand that building is a two-step process. First you compile each individual source file into individual

Unable to load SqlServerSpatial.dll

那年仲夏 提交于 2019-11-26 22:41:49
问题 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