clr

Simplest way to make cross-appdomain call?

只谈情不闲聊 提交于 2019-11-27 15:06:51
I need to call a method of object in another appdomain (pass param and get result). Ideas? UPD both AppDomain's are created not by my code (host app creates it, and then my code gets called). How I can get access to one AppDomain from another? Centro If you created an object in another domain e.g. with AppDomain.CreateInstanceAndUnwrap , all you need to call the object in another domain is to call an object's method. The simplest way to make a cross-application domain call is just to make a call directly on that object, which actually is exposed from another domain via its proxy, existing in

How are String and Char types stored in memory in .NET?

六眼飞鱼酱① 提交于 2019-11-27 15:06:47
I'd need to store a language code string, such as "en", which will always contains 2 characters. Is it better to define the type as "String" or "Char"? private string languageCode; vs private char[] languageCode; Or is there another, better option? How are these 2 stored in memory? how many bytes or bits for will be allocated to them when values assigned? Adam Houldsworth How They Are Stored Both the string and the char[] are stored on the heap - so storage is the same. Internally I would assume a string simply is a cover for char[] with lots of extra code to make it useful for you. Also if

Advantage of SQL SERVER CLR

纵然是瞬间 提交于 2019-11-27 14:52:37
问题 What advantages does SQLServer CLR offer over T-SQL? Is using .NET syntax easier than T-SQL? I see that you can define user types, but I'm not quite clear on why that's better. For example, you could define an email type and it would have a prefix property and a domain property. You could then search on domain or prefix or both. However, I don't see how that's any different from adding a couple of columns one called prefix and one called domain and searching on them individually. Maybe

What does ----s mean in the context of StringBuilder.ToString()?

只愿长相守 提交于 2019-11-27 14:21:12
问题 The Reference Source page for stringbuilder.cs has this comment in the ToString method: if (chunk.m_ChunkLength > 0) { // Copy these into local variables so that they // are stable even in the presence of ----s (hackers might do this) char[] sourceArray = chunk.m_ChunkChars; int chunkOffset = chunk.m_ChunkOffset; int chunkLength = chunk.m_ChunkLength; What does this mean? Is ----s something a malicious user might insert into a string to be formatted? 回答1: In the CoreCLR repository you have a

How to debug System.TypeLoadException errors in .NET?

元气小坏坏 提交于 2019-11-27 14:18:01
I'm getting the following error on one of my referenced assemblies: Could not load type 'System.Func`2' from assembly 'MyAssembly, ... I'll be honest, I don't think I can remember the last time I saw a System.TypeLoadException error, or if I saw it, the solution was obvious. My first instinct was to see what MSDN had to say about it : TypeLoadException is thrown when the common language runtime cannot find the assembly, the type within the assembly, or cannot load the type. Perhaps I'm reading this wrong, but it is saying that the CLR simply can't find the type? That might make more sense if

VB.NET WithEvents keyword behavior - VB.NET compiler restriction?

不打扰是莪最后的温柔 提交于 2019-11-27 13:50:29
问题 I'm working on becoming as familiar with C# as I am with VB.NET (the language used at my workplace). One of the best things about the learning process is that by learning about the other language you tend to learn more about your primary language--little questions like this pop up: According to the sources I've found, and past experience, a field in VB.NET that is declared as WithEvents is capable of raising events. I understand that C# doesn't have a direct equivalent--but my question is:

When passing a managed byte[] array through PInvoke to be filled in by Win32, does it need to be pinned?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 13:31:46
Suppose you're calling a Win32 function that will fill in your byte array. You create an array of size 32, empty. Then pass it in to the Win32 function to be filled int, and use it later in your managed code. Does there exist the chance that the byte array might be moved or overwritten in between the time it was allocated and it is filled in by the Win32 function? Short Answer: No, pinning is not necessary in this case Longer Answer: The CLR will automatically pin references to managed objects when the cross the PInvoke boundary. As soon as the PInvoke function exits the reference will be

windows form CLR application in Visual studio 2012 RC?

泄露秘密 提交于 2019-11-27 13:13:36
问题 quick question, im just trying out VS2012 and trying to make a c++.net app but for the life of me i cant find the option anymore when making a new project. In vs2008 it used to be under new project>visual c++> CLR>windwos form application. Have they removed the option to make c++/CLR application in .net from vs2012? Or is it something i must download? 回答1: Although Microsoft removed the option to create a C++/CLI Windows Forms application, the template files are still installed. The only

In .NET 4.0, What is the default implementation of Equals for value types?

為{幸葍}努か 提交于 2019-11-27 12:50:47
问题 The two documentation pages seem to contradict on this topic: ValueType.Equals Method says "The default implementation of the Equals method uses reflection to compare the corresponding fields of obj and this instance." Object.Equals Method (Object) says "The default implementation of Equals supports reference equality for reference types, and bitwise equality for value types ." So is it bitwise equality or reflection? I took a glimpse at the source code of ValueType and found a comment saying

What is CLR hosting?

喜夏-厌秋 提交于 2019-11-27 12:39:14
What is CLR hosting? What is the use case for that? CesarGon See here for information about CLR hosting that was relevant for CLR v2 (.NET 2.0, 3.0 and 3.5). For information about the newer CLR Hosting API in .NET 4.0, see here . Basically, the CLR acts as a library that can be loaded and "hosted" by a process. You can develop an app that loads and hosts the CLR if you wish; that would allow your app to contain a whole CLR virtual machine, load assemblies and run .NET managed code all within it. SQL Server 2008, for example, can do this. You can write .NET code that is stored in a SQL Server