clr

How to throw custom exception when exception type was passed by constructor

I've created class that takes Exception type in constructor private readonly Exception _exception; public StringToObject(Exception exception) { _exception = exception; } i wanted to throw exception throw new _exception(""); but i got error: '._exception' is a 'field' but is used like a 'type' is any possib...

.NET 3.5 web app - C# image scaling on the fly - lower quality on deployed site vs development

I have a VS 2008, .NET 3.5 targeted MVC.NET app. I am developing on Windows 7 with its IIS, but deploying to a Windows Server 2003 environment with .NET 3.5 SP1 installed. We have a image scaling action that returns an image from the database in the requested resolution, and converts to PNG on the fly with System.Drawing and System.Draw...

Lists in User Defined Types (SQL Server 2008)

I'm trying to define a new type and have not had much luck finding any information about using lists within them. Basically my new type will contain two lists, lets say x and y of type SqlSingle (the user defined type is written in C#) is this even possible? If not how are you supposed to go about simulating a two lists of an arbitary l...

How to debug unreleased COM references from managed code?

I have been searching for a tool to debug unreleased COM references, that usually cause e.g. Word/Outlook processes to hang in memory in case the code does not call Marshal.ReleaseCOMObject on all COM instances correctly. (Outlook 2007 partially fixes this for outlook addins, but this is a generic question). Is there a tool that would ...

Does the .NET CLR Really Optimize for the Current Processor

When I read about the performance of JITted languages like C# or Java, authors usually say that they should/could theoretically outperform many native-compiled applications. The theory being that native applications are usually just compiled for a processor family (like x86), so the compiler cannot make certain optimizations as they may...

.NET converting simple arrays to List Generics

This question might seem trivial and also stupid at the first glance, but it is much more than this. I have an array of any type T (T[]) and I want to convert it into a List generic (List<T>). Is there any other way apart from creating a Generic list, traversing the whole array and adding the element in the List? Present Situation: st...

.net Compiler Optimizations

I am writing an application that I need to run at incredibly low processor speeds. The application creates and destroys memory in creative ways throughout its run, and it works just fine. I am wondering what compiler optimizations occur so I can try to build to that. One trick off hand is that the CLR handles arrays much faster than list...

How to see JIT-Compilated code in .NET VM (CLR)

Hi, How can I have a trace of native code generated by the JIT-Compiler ? Thanks ...

Language Interoperability in .NET (CLR) and Mono

Let's say I need to use Python and C++. I can call Python function from C++ with Python C API, and reverse is possible with SWIG or equivalent. How about .NET? I know there are IronPython and C# that finally produces .NET assembly. Is there any well-defined language interoperability mechanism in .NET so that one can use whatever functi...

listing all members of an active directory group

hi, I'm having trouble retrieving the members of a certain group in active directory. The code im usinf is the following [Microsoft.SqlServer.Server.SqlFunction(FillRowMethodName = "fillRow")] public static IEnumerable getNTGroupMembers(string groupName) { SearchResult result; DirectorySearcher search = new Directory...

System::IDisposable woes

public ref class ScriptEditor : public Form { public: typedef map<UInt32, ScriptEditor^> AlMap; static AlMap AllocationMap; Form^ EditorForm; RichTextBox^ EditorBox; Status...

Production debugging: Is there a less intrusive way than WinDbg?

Hi, I was wondering if there is a less intrusive way to analyze a running, managed process in production environments. Less intrusive meaning: No delay of execution when attaching the debugger. No delay of execution when getting basic stats like running threads. In the Java world there is a such a tool part of the JDK. I was wonder...

Delegates in .NET: how are they constructed ?

While inspecting delegates in C# and .NET in general, I noticed some interesting facts: Creating a delegate in C# creates a class derived from MulticastDelegate with a constructor: .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed { } Meaning that it exp...

Identity column in SQL CLR Split UDF

How can I return a identity column with a standard SQL CLR Split UDF for example the code below will return a table with the string value split by delimiter, I need to somehow return an identity column as well. <SqlFunction(FillRowMethodName:="FillRow", TableDefinition:="value nvarchar(4000)")> _ Public Shared Function GetStrings(ByVal ...

Intellisense in header files

I just right now "migrated" from C# to C++/CLR. First I was annoyed, that I had to write all class' declarations twice (into .h and .cpp). Then I figured out, that I could place the code also into the h-files - it compiles at least. Well, I deleted all cpp's of my classes and now I realized, VS won't give me any Intellisense when I work ...

Adding code to the beginning / end of methods in runtime dynamically

I know instrumentation is a technique to add trace code dynamically into the methods to enable tracing and debugging. I was wondering if this is only a "Trace" option, hard coded into the CLR to add only trace code, or is there the ability to add any code to the methods? For example, I want to check for a condition in the beginning of ...

Error deploying CLR udf project in VS - system.core 3.5 not found in SQL catalog

I am building CLR Stored Procedures and UDFs as discussed in this article: http://www.codeproject.com/KB/cs/CLR_Stored_Procedure.aspx When I execute Build > Deploy, I get the following error: Error: Assembly 'system.core, version=3.5.0.0, culture=neutral, publickeytoken=b77a5c561934e089.' was not found in the SQL catalog. N...

What CLR do when compare T with null, and T is a struct?

private static void SaveOrRemove<T>(string key, T value) { if (value == null) { Console.WriteLine("Remove: " + key); } //... } If I call passing 0 to value: SaveOrRemove("MyKey", 0), the condition value == null is false, then CLR dont make a value == default(T). What really happens? ...

Writing an Iron Python debugger

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 manag...

C++ app fails to initialize (0xc0000005), when using C# dll

Hi, I have a C# DLL, which I call from a native C++ programm. As I use Qt and /clr compiler option did not work I followed this tutorial for a bridge. So I have a VS2008 project (compiled with /clr), which links to the C# DLL and contains the bridge class and the native class, which exposes interfaces to my C++ programm. Another VS2008...