clr

What kind of problem can cause a TypeLoadException?

江枫思渺然 提交于 2019-12-01 01:52:16
I have a big and bloated software and I want to add a new GUI element to it. The GUI element was written using XAML and WPF. I created the UI element in a separate assembly, and reference it in the big software. The two projects compiled smoothly under VS2010, but when I run my application I get a TypeLoadException . Looking into the exception with the debugger, I get the following message : Could not load type GUI.Dashboard from assembly GUI, blah, blah . There is no InnerException nor any further detail. The .GNU documentation says that this message appears when there is no message passed to

Call dll function from sql stored procedure using the current connection

萝らか妹 提交于 2019-12-01 01:49:57
Can I call a dll from a stored procedure using the open connection? I have a dll that gets data from SQL Server and I don't want to open a new connection when I call it from the stored procedure. Thank you Here is an exemple public class Class1 { public static SqlString GetName(SqlString str) { SqlCommand cmd = new SqlCommand(str.ToString()); cmd.CommandType = System.Data.CommandType.Text; string name = cmd.ExecuteScalar().ToString(); return name; } } and this is the SQL code CREATE FUNCTION fn_TestConnection ( @str nvarchar(255) ) RETURNS nvarchar(max) AS EXTERNAL NAME TestConnection.

How can I know the CLR version of a crash dump?

纵然是瞬间 提交于 2019-12-01 00:24:23
问题 I have a minidump crashed from a .NET application. Is there any way to know the CLR version (e.g. version of mscorwks.dll) of the fault machine (which generates the crash dump) using either Windbg or some other tool? 回答1: In WinDbg: the easiest way is to use the !eeversion command, but if you want additional info you can use the lm command with the v verbose option for the runtime module mscorwks . If you're on .NET 4 the runtime is called clr , so in that case you need to change the command

Turn off clr option for header file with std::mutex

一世执手 提交于 2019-12-01 00:12:52
问题 I have a Visual Studio project that contains files with managed code and files with unmanaged code. The project has the CLR support, but when I add a file where I do not need .NET I simply turn off the /crl option with a right-click on the file: I added a class that has to contain unmanaged code and use std::mutex. // Foo.h class Foo { std::mutex m; } I got the following error after compiling: error C1189: #error : is not supported when compiling with /clr or /clr:pure. The problem is that I

Windows service / A new guard page for the stack cannot be created

与世无争的帅哥 提交于 2019-11-30 22:40:11
问题 I have a windows service that does some intensive work every one minute (actually it is starting a new thread each time in which it syncs to different systems over http). The problem is, that after a few days it suddenly stops without no error message. I have NLog in place and I have registered for 'AppDomain.CurrentDomain.UnhandledException'. The last entry in the textfile-log is just a normal entry without any problems. Looking in the EventLog, I also can't find any message in the

A way How to Compile C library into .Net dll?

蓝咒 提交于 2019-11-30 21:30:51
Can we compile C library as .Net dll (containing and opening access to all C libs functions) by just compiling cpp project containing code like extern "C" { #include <library.h> } with /clr:pure argument with VS? (VS10) Or we should do something more trickey? I found it is the best to use the old style Managed C++ for this. CLR:PURE just wont cut it. Example: extern "C" int _foo(int bar) { return bar; } namespace Bar { public __gc class Foo { public: Foo() {} static int foo(int bar) { return _foo(bar); } }; }; Compile with: /clr:oldSyntax Now you can reference the assebmly, and call Bar.Foo

How do actually castings work at the CLR level?

安稳与你 提交于 2019-11-30 20:51:47
When doing an upcast or downcast, what does really happen behind the scenes? I had the idea that when doing something as: string myString = "abc"; object myObject = myString; string myStringBack = (string)myObject; the cast in the last line would have as only purpose tell the compiler we are safe we are not doing anything wrong. So, I had the idea that actually no casting code would be embedded in the code itself. It seems I was wrong: .maxstack 1 .locals init ( [0] string myString, [1] object myObject, [2] string myStringBack) L_0000: nop L_0001: ldstr "abc" L_0006: stloc.0 L_0007: ldloc.0 L

How to do dynamic object creation and method invocation in .NET 3.5

房东的猫 提交于 2019-11-30 20:01:58
问题 How does the code looks that would create an object of class: string myClass = "MyClass"; Of the above type, and then call string myMethod = "MyMethod"; On that object? 回答1: Use Type.GetType(string) to get the type object. Use Activator.CreateInstance(Type) to create an instance. Use Type.GetMethod(string) to retrieve a method. Use MethodBase.Invoke(object, object[]) to invoke the method on the object Example, but with no error checking: using System; using System.Reflection; namespace Foo {

UnhandledException not called when exception thrown in another thread

帅比萌擦擦* 提交于 2019-11-30 19:55:17
According to the Microsoft documentation, when an unhandled exception occurs on a thread (from either the thread pool or created using the System.Threading.Thread class) the AppDomain.UnhandledException event should fire for the default AppDomain of the application. Here is the MSDN link which explains it after the second NOTE section. But I cannot reproduce this behaviour, as far as I can tell from my test application it never fires the UnhandledException on either the default AppDomain or the AppDomain used to create the thread. Is the documentation wrong or my testing code? using System;

Writing an Iron Python debugger

一笑奈何 提交于 2019-11-30 19:34:43
As a learning exercise I'm writing myself a simple extension / plugin / macro framework using IronPython - I've gotten the basics working but I'd like to add some basic debugging support to make my script editor easier to work with. I've been hunting around on the internet a bit and I've found a couple of good resources on writing managed debuggers (including Mike Stall's excellent .Net Debugging blog and the MSDN documentaiton on the CLR Debugging API ) - I understand that IronPython is essentially IL however apart from that I'm a tad lost on how to get started, in particular: Are there any