clr

Resolving MSB3247 - Found conflicts between different versions of the same dependent assembly

只谈情不闲聊 提交于 2019-11-26 16:51:11
A .NET 3.5 solution ended up with this warning when compiling with msbuild. Sometimes NDepend might help out but in this case it didn't give any further details. Like Bob I ended up having to resort to opening each assembly in ILDASM until I found the one that was referencing an older version of the dependant assembly. I did try using MSBUILD from VS 2010 Beta 2 (as the Connect article indicated this was fixed in the next version of the CLR) but that didn't provide any more detail either (maybe fixed post Beta 2) Is there a better (more automated) approach? AMissico Change the "MSBuild project

How to debug System.TypeLoadException errors in .NET?

十年热恋 提交于 2019-11-26 16:39:41
问题 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

What is CLR hosting?

人走茶凉 提交于 2019-11-26 16:05:38
问题 What is CLR hosting? What is the use case for that? 回答1: 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.

Static Generic Class as Dictionary

旧城冷巷雨未停 提交于 2019-11-26 15:29:11
A static field in a generic class will have a separate value for each combination of generic parameters. It can therefore be used as a Dictionary<Type, whatever > Is this better or worse than a static Dictionary<Type, whatever >? In other words, which of these implementations is more efficient? public static class MethodGen<TParam> { public static readonly Action<TParam> Method = CreateMethod(); static Action<TParam> CreateMethod() { /*...*/ } } Or, public static class MethodGen { static readonly Dictionary<Type, Delegate> methods = new Dictionary<Type, Delegate>(); public static Action<T>

How do I detect at runtime that .NET version 4.5 is currently running your code?

£可爱£侵袭症+ 提交于 2019-11-26 15:03:33
I installed .NET 4.5 Developer preview from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27541 , which 'replaces' .NET 4.0 version. However, the old way to detect the .NET framework version seems to return 4.0 (more precisely 4.0.30319.17020 on my PC), instead of 4.5 (sure probably for backward compatibility, or?): using System; namespace ConsoleApplication { class Program { static void Main(string[] args) { var version = Environment.Version; Console.WriteLine(version.ToString()); Console.ReadKey(); } } } How do I detect that my code is really executed by .NET 4.5?

Are static indexers not supported in C#? [duplicate]

北城余情 提交于 2019-11-26 14:33:34
问题 This question already has an answer here: Static Indexers? 7 answers I've been trying this a few different ways, but I'm reaching the conclusion that it can't be done. It's a language feature I've enjoyed from other languages in the past. Is it just something I should just write off? 回答1: No, static indexers aren't supported in C#. Unlike other answers, however, I see how there could easily be point in having them. Consider: Encoding x = Encoding[28591]; // Equivalent to Encoding.GetEncoding

Is it possible to get parameters&#39; values for each frame in call stack in .NET

こ雲淡風輕ζ 提交于 2019-11-26 14:23:46
问题 I'm talking about managed .NET code. If we run any program and attach VS to it we can see parameters' values for each method in call stack. I'd like to create a logging solution which will log all parameters' values for each method in call stack. Actually I need this info in case an exception occurs. I know it's possible with profiling API. But I wonder is it possible with only managed code? UPDATE: Ok, probably with pure .NET it's impossible. Then may be with some kind of unmanaged code...

How does CorFlags.exe /32BIT+ work?

谁说我不能喝 提交于 2019-11-26 14:06:01
问题 I guess my question is about the CLR Loader. I want to understand the mechanics behind CorFlags.exe /32BIT+ functionality. We know that when one starts an assembly compiled with the Any CPU flag set on 64-bit Windows, it starts as a 64-bit process. If one run CorFlags /32BIT+ on that assembly, it will start as a 32-bit process. I think this is a fascinating feature. I have so many questions about it: How is it implemented? Does the OS Loader get involved? Is possible to build a custom

In C++/CLI, what does the hat character ^ do? [duplicate]

巧了我就是萌 提交于 2019-11-26 13:22:48
This question already has an answer here: What does the caret (‘^’) mean in C++/CLI? 7 answers I was reading Ivor Horton's Beginning Visual C++ 2008 and many of its CLR examples have this definition for main: int main(array<System::String ^> ^args) I went back, page by page, to the beginning of the book to find the first such instance with an explanation what it really means, but couldn't find one. Obviously it means the same as the standard int main(int argc, char *argv[]) , but I'd like to know when and why that ^ is really used, and why it even exists (does it do something that pointers *

Does the .NET CLR JIT compile every method, every time?

ぐ巨炮叔叔 提交于 2019-11-26 12:56:39
问题 I know that Java\'s HotSpot JIT will sometimes skip JIT compiling a method if it expects the overhead of compilation to be lower than the overhead of running the method in interpreted mode. Does the .NET CLR work based upon a similar heuristic? 回答1: Note: this answer is on a "per-run" context. The code is normally JITted each time you run the program. Using ngen or .NET Native changes that story, too... Unlike HotSpot, the CLR JIT always compiles exactly once per run. It never interprets, and