clr

Nothing != null - or does it?

可紊 提交于 2019-12-08 14:56:25
问题 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 True It seems like a fairly fundamental design decision between the two languages and it certainly caught me out. Is anyone able to tell me why? Are null and Nothing

Curiosity: Converting a C# struct into an object still copies it

会有一股神秘感。 提交于 2019-12-08 14:14:24
This question is more out of curiosity than a real problem. Consider the following code (C# 4.0, if it matters): class Program { static Point myPoint = new Point(3, 5); static void Main(string[] args) { Console.WriteLine("Point Struct Before: " + myPoint); object point = GetPoint(); Console.WriteLine("Point Object Before: " + point); myPoint.X = 10; Console.WriteLine("Point Struct After: " + myPoint); Console.WriteLine("Point Object After: " + point); } static object GetPoint() { return myPoint; } } This outputs the following: Point Struct Before: 3;5 Point Object Before: 3;5 Point Struct

How do I force the CLR to exhibit OS thread switching?

谁说胖子不能爱 提交于 2019-12-08 14:11:14
问题 Related to these questions: How do I get the _real_ thread id in a CLR "friendly" way? How often does a managed thread switch OS threads? I would like to be able to actually test the Thread.BeginThreadAffinity() methods and verify how they work and that they work. Is there some .NET functionality that will force an OS thread switch? 回答1: There is not much to test with Thread.BeginThreadAffinity(). I calls a function in the CLR host, IHostTaskManager::BeginThreadAffinity(). IHostTaskManager is

Redirecting Assembly versions to a different CLR/GAC

大憨熊 提交于 2019-12-08 13:30:59
问题 I have a question regarding the 2 CLR versions, i.e. version 2 and version 4 of the .NET framework, which use different GAC locations. I have a client application built which references an assembly “X” from the v2 GAC (C:\Windows\Assembly). I am now updating the assembly “X” to run on v4 of the .NET framework (C:\Windows\Microsoft.NET\assembly), however, I do not want to recompile the client application. Note, assembly "X" is removed from the v2 GAC before installing the to v4 GAC. Is it

C++ to bytecode compiler for Silverlight CLR?

末鹿安然 提交于 2019-12-08 10:46:52
问题 I'd like to be able to compile a C/C++ library so that it runs within a safe managed runtime in the Silverlight CLR. There are several tools for doing this with the JVM that allows C++ code to run within a CRT emulation layer (see NestedVM, LLJVM, etc), which effectively allows C++ code to be run within a Java Applet. There's even a tool for this for the Adobe Flash VM (see Alchemy). However, I can't seem to find any tools like this for the CLR. fyi, the MSVC tools don't seem to allow for

Difference CLR and CLI and how to call those from pure C

非 Y 不嫁゛ 提交于 2019-12-08 09:25:52
问题 Could somebody tell me what the difference between CLR and CLI is in it's basic functionallity but most important would be which one of them is better? All I got so far is that using the ICLRRuntimeHost Interface does not allow me to return anything else than an int and the only allowed parameter is a LPCWSTR (see ExecuteInDefaultAppDomain) At this point I am wondering if one could/would allocate memory e.g. for a struct in his C program, give a pointer as a LPCWSTR string to

How to use embedded registration-free manifest for ActiveX component from managed code like C#?

﹥>﹥吖頭↗ 提交于 2019-12-08 09:07:02
问题 I would like to use a specific version of ActiveX component that is not registered system- or user-wide. Everything works as expected if I use manifest files. However embedded manifest works only for C++ client code only. Here is dependency declaration <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="MapWinGIS.ocx" version="4.9.1.0" /> </dependentAssembly> </dependency> If I use SxStrace, I see the following INFO: Parsing Manifest File C:\OSGeo4W\bin\TestApplication.exe.

C++ to bytecode compiler for CLR?

孤者浪人 提交于 2019-12-08 08:13:17
问题 I'd like to be able to compile a C/C++ library so that it runs within a managed runtime in the CLR. There are several tools for doing this with the JVM (NestedVM, LLJVM, etc) but I can't seem to find any for the CLR. Has anyone tried doing this? 回答1: Microsoft already provides such a tool with Visual Studio. The C++ compiler cl.exe accepts the /clr option to tell it to generate managed code instead of native code. See the MSDN document How To: Migrate to /clr for information on changing your

How to use mixed C++ & .Net dll in node.js? (Error: abort() has been called)

我是研究僧i 提交于 2019-12-08 08:12:56
问题 I want to create a native node extension using a dll containing C++ and C# code in Visual Studio 2015. I cannot make it work following my own instructions of yesteryear, which is based on the latest node-gyp . When not using the /clr option, I can run a program like the following just fine. console.log("1"); const addon = require('./build/Release/addon'); console.log("2"); When enabling /clr , only the first call to log gets executed. When compiling the dll in debug mode, I get the following

How to register CLR User Defined Function for use in linq query?

耗尽温柔 提交于 2019-12-08 05:42:05
问题 Using SQL Server 2008 I'd like to run a regex on a DB value before comparing it. I'm looking into CLR User-Defined Functions (I investigated EDM Functions but I got the impression that UDFs were more appropriate with a regex - please correct me if I'm wrong). Ideally I'd like to make a linq call like this: var results= db.Items.Where(i => i.CustomFormatFunction() == xyz); So far I have this c# code: public static partial class UserDefinedFunctions { [SqlFunction] public static SqlString