clr

C++ to bytecode compiler for CLR?

I'd like to be able to compile a C/C++ library so that it runs within a managed runtime in the CLR. There are several tools for doing this with the JVM (NestedVM, LLJVM, etc) but I can't seem to find any for the CLR. Has anyone tried doing this? ...

C++ to bytecode compiler for Silverlight CLR?

I'd like to be able to compile a C/C++ library so that it runs within a safe managed runtime in the Silverlight CLR. There are several tools for doing this with the JVM that allows C++ code to run within a CRT emulation layer (see NestedVM, LLJVM, etc), which effectively allows C++ code to be run within a Java Applet. There's even a to...

var in C# - Why can't it be used as a member variable?

Why is it not possible to have implicitly-typed variables at a class level within C# for when these variables are immediately assigned? ie: public class TheClass { private var aList = new List<string>(); } Is it just something that hasn't been implemented or is there a conceptual/technical reason for why it hasn't been done? ...

Is it possible to link a method marked with MethodImplOptions.InternalCall to its implementation?

In trying to find the possible cause of an exception, I'm following a code path using Reflector. I've got deeper and deeper, but ended up at a method call that looks like: [MethodImpl(MethodImplOptions.InternalCall)] private extern void SomeMethod(int someParameter); This markup on the method tells the framework to call a C++ function...

Why are static classes considered “classes” and “reference types”?

I’ve been pondering about the C# and CIL type system today and I’ve started to wonder why static classes are considered classes. There are many ways in which they are not really classes: A “normal” class can contain non-static members, a static class can’t. In this respect, a class is more similar to a struct than it is to a static cla...

How do actually castings work at the CLR level?

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

In a Visual Studio C++ project with /clr, are its dependencies also compiled to managed code?

To be a bit more clear. If I have a Visual Studio C++ solution that has two projects, say a static library with CLR support turned off, and a second project with CLR support turned on that depends on this static library, does the static library get compiled as managed code? What about libraries that the CLR project uses that are external...

Passing a DataTable into a Stored Procedure. Is there a better way?

Can A datatable somehow be passed into SQL Server 2005 or 2008 ? I know the standard way seesm to be passing XML to a SP. And a datatable can easily be converted to XML somehow to do that. What about passing a .NET object into a SP ? Is that possible ? I remember hearing about SQL and CLR working together in 2008 somehow but I never...

Handle .NET exceptions within Classic ASP pages

Hi All, I am making MSSQL stored procedure CLR calls from ASP pages. When an exception occurs, it is logged and then rethrown. In this scenario I need to be able to handle the exception (if possible) in the ASP page. Note that I cannot move away from classic ASP in this instance; I am stuck within a legacy system for this project. P...

How do I use Entity Framework in a CLR stored procedure?

I am looking forward to move all the logic (which is implemented as manipulating Entity Framework 4 objects) to a server side. It looks going to be simple (thanks to the application structure) and beneficial (as all I have is one oldy laptop as a client and one tough server which runs SQL Server 2008, and building a separate service for ...

How does the CLR know which if the given assembly is the correct one?

If we have a .NET executable that's using a .NET library, how does the CLR ensure you are using the correct version of the dll? CLRwise what is considered be the "correct dll version", to start with? Does it only look at the version? Looks also at the build-time(?). Maybe it looks at an hash or something? Thanks ...

C++/CLI: Compiling static library with /CLR support

We have old (working) code that consists of a static library compiled with /CLR, and a C++/CLI DLL that links to the static lib. We are about to add new features to this static lib. Now, I've have heard from numerous sources that CLR static libraries are not supported by Microsoft, and therefore I'm pushing to clean this up and switch t...

How do I set properties related to the calling method's scope?

I'm not looking for a way to associate values with a thread using the 'SetData' method. I need to store some kind of data that will only exist during the scope of a calling method, could be the immediate parent or any other call that is made down on the stack. For example: void SomeMethod() { string someInfo = "someInfo"; SomeOth...

Can I make the compiler and the CLR ignore non implemented interfaces on my types?

I would like to define a type implementing a certain interface, however I would only implement it in a proxy at runtime. I can see two obstacles in this scenario : 1-Make the compiler ignore non implemented interfaces. 2-Make the CLR ignore(or at least delay) the TypeLoadException with the following description : "Method SOMEMETHOD in t...

Code Review: CLR RegexSubstring

Could this be better? .NET 2.0 compatibility for SQL Server 2005: public static SqlString RegexSubstring(SqlString regexpattern, SqlString sourcetext, SqlInt32 start_position) { SqlString result = null; if (!regexpattern.IsNull && !sourcetext.IsNull ...

Closing some instances of an app, increases Gen-2 Garbage Collection Heap?

We're in the middle of debugging some memory issues. We were watch 5 instances of the same app. We stopped 3. The Gen2 Heap size went from about 5M to almost 10M, and the Gen0 and Gen1 heap sizes changed insignificantly. This is the exact opposite of what I'd expect. I expected it to reduce in size, and would never expect it to incre...

How does the CLR (.NET) internally allocate and pass around custom value types (structs)?

Question: Do all CLR value types, including user-defined structs, live on the evaluation stack exclusively, meaning that they will never need to be reclaimed by the garbage-collector, or are there cases where they are garbage-collected? Background: I have previously asked a question on SO about the impact that a fluent...

Beanshell equivalent for .Net

Is there anything like Beanshell, which exposes CLR classes instead of Java classes, and lets you write scripts in C# or VB.Net (or any .Net language for that matter) Should come in handy to test one-liner code snippets ...

Cannot load Windows PowerShell snap-in Microsoft.PowerShell.Host

Hi everyone, I'm attempting to invoke Windows Powershell cmdlets via Visual Studio .NET. However, I'm getting the exception shown below when I try to call a function.The Microsoft.PowerShell.ConsoleHost.dll wasn't initially in that path so I copied it over from another location. Is this the right way of installing a snap-in? It still sp...

Why is the CLR's jmp instruction unverifiable?

The title says it all. I've known about the jmp instruction for awhile, but it never struck me as being even remotely unsafe. I recently had cause to check the CIL specs and was very surprised to discover jmp is considered unverifiable. Any explanations would be much appreciated. ...