clr

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

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

casting vs using the 'as' keyword in the CLR

I'm learning about design patterns and because of that I've ended using a lot of interfaces. One of my "goals" is to program to an interface, not an implementation. What I've found is that I'm doing a lot of casting or object type conversion. What I'd like to know is if there is a difference between these two methods of conversion: pu...

In C++/CLR, what does a hat character ^ do?

I was reading Ivor Horton's Beginning Visual C++ 2008 and many of its CLR examples have int main(array<System::String ^> ^args) definition for main. I went back, page by page, to the beginning of the book to find first such instance with an explanation what it really means, but couldn't find one. Obviously it means the same as the st...

Size of varbinary field in SQL server 2005

Hi! I am trying to determine the size in bytes of the contents in a varbinary(max) field in sql server 2005, using sql. As I doubt there is native support for this, could it be done using CLR integration? Any ideas would be greatly appreciated. ...

Difference between VB.Net and C# "As New WebControl"

I was refactoring some code, and part of it included moving it from VB.Net to C#. The old code declared a member like this: Protected viewMode As New WebControl The new code, I eventually got working, like this: protected WebControl _viewMode = new WebControl(HtmlTextWriterTag.Span); I can presume that the "New" keyword mean...

Question about GetHashCode implementation

http://msdn.microsoft.com/en-us/library/system.object.gethashcode(VS.80).aspx says: For the best performance, a hash function must generate a random distribution for all input. Does it have any effect in performance or it's ok to use a function (like return this.Id) that doesn't give a "random distribution" but it doesn't cause mor...

jvm design decision

Why does the jvm require around 10 MB of memory for a simple hello world but the clr doesn't. What is the trade-off here, i.e. what does the jvm gain by doing this? Let me clarify a bit because I'm not conveying the question that is in my head. There is clearly an architectural difference between the jvm and clr runtimes. The jvm has a ...

Java and .NET heap overhead

I have understanding how heap and garbage collector works: garbage collection happens in generations, memory allocation happens sequentially, during garbage collection free/unused space compacted by shifting data and forming continues block, etc. Is there any headers for allocated memory chunks are present and how big are they (I heard...

Need help getting NGen back into working condition.

NGen is unhappy on my computer, and i can't find a way to get a deep understanding of what is going wrong. After every startup, ngen logs this message: .NET Runtime Optimization Service (clr_optimization_v2.0.50727_32) - Service reached limit of transient errors. Will shut down. Last error returned from Service Manager: 0x...

Seemingly random crashes with VB.NET and COM Interop

I'm thinking of rewriting a brand new VB.NET application in VB 6. The application runs under terminal services and makes heavy use of COM. For some reason, there is random weirdness with the application - Random Access Violation errors (WinDbg exception analysis points into dll's like comdlg32.dll, mscorwks) Random Buffer Overflow er...

C# - Is this declared string treated as a const?

Help me settle an argument here. Is this: SqlCommand cmd = new SqlCommand( "sql cmd", conn); treated exactly the same as this: const string s = "sql cmd"; SqlCommand cmd = new SqlCommand( s, conn); Ie. does it make a difference if I state specifically that the string s is a const. And, if it is not treated in the same way, why n...

What does the file security.config.cch do with the CLR ?

I've been experiencing nasty lockups while debugging under VS2008, SP1 on my machine. I was running ProcMon.exe to try and determine what is going on. One thing I see is 100s or 1000s of repeated reads + writes to a file called security.config.cch and security.config.cch.new. What are these files? Why would my application need to r...

What can you do in MSIL that you cannot do in C# or vb.NET?

All code written in .NET languages compiles to MSIL, but are there specific tasks / operations that you can do only using MSIL directly? Let us also have things done easier in MSIL than C#, VB.NET, F#, j# or any other .NET language. So far we have this: 1. Tail recursion 2. Generic Co/Contravariance 3. Overloads which differ only in re...

Using multiples "usings", how this affect performance?

Hello, I'm not against using "Using" statement, but I'm wondering how this affect performance when we use it inside one of another. For example: using (test1 (type1)) { using (test2(type2)) { using (test2(type3)) { } } } This,...

Stipulating that a property is required in a class - compile time

Is there a way to stipulate that the clients of a class should specify a value for a set of properties in a class. For example (see below code), Can i stipulate that "EmploymentType" property in Employment class should be specified at compile time? I know i can use parametrized constructor and such. I am specifically looking for outp...

.net Runtime - Silverlight Runtime = ?

I've googled around a bit, and I haven't been able to find a good listing of what classes from the .net CLR are not included in the 'CoreCLR' aka Silverlight. What is Silverlight missing from the Windows .net Framework? Also, is there anything that the Silverlight runtime has that the .net Framework doesn't? ...

Why is ReflectionOnlyAssemblyResolve not executed when trying to Assembly.ReflectionOnlyLoad?

I'm trying to load a few modules via hooking into the AppDomain.AssemblyResolve and AppDomain.ReflectionOnlyAssemblyResolve events. While I got the former to work, I fail miserably on the latter. I've boiled my problem down to this little program: public static class AssemblyLoader { static void Main(string[] args) { App...

What makes the CLR show Assertions?

If I define the Debug constant for my C# Project in visual studio I can be sure that assertions will be evaluated and a messagebox is shown when they fail. But what flag, attribute makes the CLR at runtime actually decide whether a an assertion is evaluated and displayed. Does the assertion code not end up in the IL when DEBUG is define...

Alternatives to MS SQL 2005 FullText Catalog

I can't seem to get acceptable performance from FullText Catalogs. We have situations where we must run 100k+ queries as quickly as possible. Some of the queries use FREETEXT some don't. Here's an example of a query IF EXISTS(select 1 from user_data d where d.userid=@userid and FREETEXT(*, @activities) SET @match=1 This can take bet...

Is it possible to determine in which language a .NET Assembly was written ex post facto?

This started as a way to find C++/CLI and Managed C++ assemblies so that all classes internal to them could be tested to ensure all inherited methods were being reimplemented. I would like to add this as a build process step to ensure that it never happens again. Thinking about this problem also made me a bit curious as it would be int...