clr

Why CLR Exception FatalExecutionEngineError happens?

烂漫一生 提交于 2019-12-03 16:23:28
问题 We are using a struct that encapsulates numeric values and I found out when the nullable version of this struct is used in an expression, a FatalExecutionEngineError happens: Additional information: The runtime has encountered a fatal error. The address of the error was at 0x729c1e04, on thread 0x52d8. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM

Is there any way to change the .NET JIT compiler to favor performance over compile time?

試著忘記壹切 提交于 2019-12-03 16:11:56
问题 I was wondering if there's any way to change the behavior of the .NET JIT compiler, by specifying a preference for more in-depth optimizations. Failing that, it would be nice if it could do some kind of profile-guided optimization, if it doesn't already. 回答1: This is set when you compile your assembly. There are two types of optimizations: IL optimization JIT Native Code quality. The default setting is this /optimize- /debug- This means unoptimized IL, and optimized native code. /optimize

The uncatchable exception, pt 2

随声附和 提交于 2019-12-03 16:11:13
问题 Update: I've filed a bug report on Microsoft Connect: https://connect.microsoft.com/VisualStudio/feedback/details/568271/debugger-halting-on-exception-thrown-inside-methodinfo-invoke#details If you can reproduce this problem on your machine, please upvote the bug so it can be fixed! Ok I've done some testing and I've reduced the problem to something very simple: i. Create a method in a new class that throws an exception: public class Class1 { public void CallMe() { string blah = null; blah

Passing c# string to unmanaged c++ DLL

£可爱£侵袭症+ 提交于 2019-12-03 16:05:15
I have a simple application that loads an unmanaged dll and passes a few string values to it from C#. But in the C++ dll application, I receive an exception :: Tried to access a read/write protected memory. My DLL Import looks like this: [DllImport("X.dll", CallingConvention = CallingConvention.Cdecl) ] public static extern int DumpToDBLogFile([MarshalAs(UnmanagedType.I4)]int loggingLevel, [MarshalAs(UnmanagedType.I4)]int jobId, int threadId, [MarshalAs(UnmanagedType.LPStr)]string procName, [MarshalAs(UnmanagedType.LPStr)]string message); and the C++ Declaration is like extern "C" __declspec

C# casting to nullable type?

允我心安 提交于 2019-12-03 15:44:15
问题 Beyond the regular boring difference between Cast and As if i know that apple is a Fruit so I can use (Fruit)apple - and it throws an exception if it aint as value can be checked against null to see if succeeded [won't throw Exception...] However Ive been reading @EricLippert article about this and there was a nice sample about Nullable Value Types : short? s = (short?)123; int? i = s as int?; this won't compile... Cannot convert type 'short?' to 'int?' via a reference conversion, boxing

CLR hosting exception handling in a non-CLR-created thread

南笙酒味 提交于 2019-12-03 15:37:49
问题 The issue: An unhandled exception in a thread entering the CLR from unmanaged code does not trigger the "normal" unhandled exception CLR processing. In the code below calling CSSimpleObject.GetstringLength() from C++ with "1" throws an exception in the calling thread (non-CLR-created thread), "2" throws an exception in a new Thread() (CLR-created thread). In case "1" CurrentDomain_UnhandledException() is never called. The Application Domain and the process will stay loaded and running, you

Using System.Threading.Tasks.Parallel create new thread in the thread pool?

末鹿安然 提交于 2019-12-03 14:37:48
问题 Maybe I did not understand it right ... all the Parallel class issue :( But from what I am reading now, I understand that when I use the Parallel I actually mobilize all the threads that exists in the threadPool for some task/mission. For example : var arrayStrings = new string[1000]; Parallel.ForEach<string>(arrayStrings, someString => { DoSomething(someString); }); So the Parallel.ForEach in this case is mobilizing all the threads that exists in the threadPool for the 'DoSomething' task

What are the situations or pros and cons to use of C++/CLI over C#

半世苍凉 提交于 2019-12-03 14:08:46
I have been keeping up with .NET CLR for awhile now, and my language of choice is C#. Up until recently, I was unaware that C++/CLI could produce "mixed mode" executables capable of running native and managed code. Now knowing this, another developer friend of mine were discussing this attribute and trying to determine when and how this ability would be useful. I take it as a given that native code has the capability to be more efficient and powerful than managed code, at the expense of additional development time. In the past, I resorted to strictly native C++ code libraries and used Interop

Calling a SOAP webservice from TSQL stored procedure

こ雲淡風輕ζ 提交于 2019-12-03 13:19:16
I am trying to build a stored procedure in TSQL to call a webservice. I've done this before in Oracle, but it seems like it's not so easy in MSSQL. There are of course many reasons not to do this in a stored proc, but since this procedure is only to be used in a daily batch, performance is not too much of a issue. The thing I want to do is as follows: Send a full name to the webservice, the webservice will return a name divided in things like first name, prefix, lastname, etc. The returned values will need to be written to a table. I found a interesting procedure at http://www.vishalseth.com

WPF .exe - large filesize

老子叫甜甜 提交于 2019-12-03 12:48:50
I am working on a WPF application and the .exe is found to be over 1.2MB in size. I would like to reduce the size of the final executable. The code is no more than a few 200 Kb, I use a few .png images in the project, which alltogether takes up about 20kb. Why is the final executable so big? I used ILDASM statistics to take a look at the .exe statistics. Posting the output below: File size : 1267712 PE header size : 512 (496 used) ( 0.04%) PE additional info : 1547 ( 0.12%) Num.of PE sections : 3 CLR header size : 72 ( 0.01%) CLR meta-data size : 72524 ( 5.72%) CLR additional info : 1160002