clr

Catching First Chance Exceptions in Managed Code without being debugged [duplicate]

戏子无情 提交于 2019-12-05 09:32:04
This question already has answers here : Is there a way to log or intercept First Chance Exceptions (3 answers) Closed 2 years ago . Is there a way to catch First-Chance exceptions, and log them without running under a debugger? I suppose another way to ask the question is can I write something that will act like a debugger being attached to my process and see what is going wrong while it happens? If you are on .NET 4.0, you can use the AppDomain.FirstChanceException event to get notification of exceptions. 来源: https://stackoverflow.com/questions/3888670/catching-first-chance-exceptions-in

How does catching an OutOfMemoryException work?

余生长醉 提交于 2019-12-05 09:14:06
问题 I am a little bit confused about the fact that we can just catch an OutOfMemoryException using a try/catch block. Given the following code: Console.WriteLine("Starting"); for (int i = 0; i < 10; i++) { try { OutOfMemory(); } catch (Exception exception) { Console.WriteLine(exception.ToString()); } } try { StackOverflow(); } catch (Exception exception) { Console.WriteLine(exception.ToString()); } Console.WriteLine("Done"); The methods I used to create the OutOfMemory + StackOverflowException:

What is the exactly Runtime Host?

 ̄綄美尐妖づ 提交于 2019-12-05 08:57:26
What is the exactly definition of Runtime Host? From MSDN : The common language runtime has been designed to support a variety of different types of applications, from Web server applications to applications with a traditional rich Windows user interface. Each type of application requires a runtime host to start it. The runtime host loads the runtime into a process, creates the application domains within the process, and loads user code into the application domains. So is it a process which loads the runtime into another process? How do I check it in Task Manager? No, it's a process that loads

“Failure loading DAC: CreateDacInstance failed” when loading dump file with ClrMD

孤街浪徒 提交于 2019-12-05 08:15:05
I'm trying the new library from microsoft, ClrMD , to analyze crash-dumps and live process. I've follow the sample in the .NET framework blog post (using the attached .cs file ). I tried to run the sample to analyze .dmp file which was taken from a program running on the same machine as the sample. when trying to create the run-time object, using the following code: ClrRuntime runtime = target.CreateRuntime(dacLocation); This exception is thrown: Message: Failure loading DAC: CreateDacInstance failed 0x80131c30 at Microsoft.Diagnostics.Runtime.Desktop.DacLibrary.Init(String dll) at Microsoft

Performance impact of changing to generic interfaces

与世无争的帅哥 提交于 2019-12-05 07:49:59
I work on applications developed in C#/.NET with Visual Studio. Very often ReSharper, in the prototypes of my methods, advises me to replace the type of my input parameters with more generic ones. For instance, List<> with IEnumerable<> if I only use the list with a foreach in the body of my method. I can understand why it looks smarter to write that but I'm quite concerned with the performance. I fear that the performance of my apps will decrease if I listen to ReSharper... Can someone explain to me precisely (more or less) what's happening behind the scenes (i.e. in the CLR) when I write:

Static methods vs instance methods in C#

旧巷老猫 提交于 2019-12-05 07:32:53
For an application I am writing, I want to have extreme extensibility and extension methods seem to give me what I want, plus the ability to call them without an instance, which I need too. I remember reading that static methods are faster than instance methods but don't get the advantages of GC. Is this correct? It's highly unlikely I will change my design unless I find a superior alternative by design not speed. But still for extra information I wanna know the differences in speed, GC, etc. EDIT: Thanks. More info: Let's say we have a Person class: class Person which can have an instance

How do C/C++/Objective-C compare with C# when it comes to using libraries?

这一生的挚爱 提交于 2019-12-05 07:21:39
问题 This question is based on a previous question: How does C# compilation get around needing header files?. Confirmation that C# compilation makes use of multiple passes essentially answers my original question. Also, the answers indicated that C# uses type and method signature metadata stored in assemblies to check code syntax at compile time. Q: how does C/C++/Objective-C know what code to load at run time that was linked at compile-time? And to tie it into a technology I'm familiar with, how

Create an SQL CLR UDF with C#

我怕爱的太早我们不能终老 提交于 2019-12-05 04:41:31
问题 I have been given the task of being able to push SQL query result sets to Excel files. Currently I have a C# console application in place (below) that takes a query, and dumps the results into a specified xlsx file using the EPPlus library. using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using OfficeOpenXml; using OfficeOpenXml.Style; namespace ExcelExport { class Program { static void Main

What are the most effective ways to use Lua with C#?

瘦欲@ 提交于 2019-12-05 04:23:21
问题 From my understanding, Lua is an embeddable scripting language that can execute methods on objects. What are the pitfalls to avoid? Is is it feasible to use Lua as an interpreter and execute methods in an web environment or as a rule engine? 回答1: Lua is very fast - scripts can be precompiled to bytecodes and functions execute close to C++ virtual method calls. That is the reason why it is used in gaming industry for scripting AI, plugins, and other hi-level stuff in games. But you put C# and

Array of pointers in C++/CLI MSIL assembly

我只是一个虾纸丫 提交于 2019-12-05 03:43:44
I'm trying to wrap some legacy C code for use with C# running on .NET Core. I'm using the approach given here to create a C++ wrapper that compiles to pure MSIL. It's working well for simple functions, but I've found that if my code ever uses pointers-to-pointers or arrays of pointers it will crash with a memory violation. Often it crashes Visual Studio and I have to restart everything, which is tedious. For example, the following code will cause the crashes: public ref class example { public: static void test() { Console::WriteLine("\nTesting pointers."); double a[5] = {5,6,7,8,9}; //Array.