clr

Seemingly random crashes with VB.NET and COM Interop

僤鯓⒐⒋嵵緔 提交于 2019-12-06 05:08:05
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 errors (same) Random errors in general - for example this line in Form.Load sometimes throws - Me.Icon = Resources.MyIcon I have followed all possible advice concerning resources, garbage collection, disposal patterns, etc... It just doesn't seem to do any good. I'm

Create .NET 2.0 AppDomain in .NET 4.0 process

一曲冷凌霜 提交于 2019-12-06 04:29:15
I need to dynamically create a .NET 2.0 compatible assembly from within my .NET 4.0 process. Currently it is achieved with this: AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly(...) ModuleBuilder mb = assemblyBuilder.DefineDynamicModule(...); But unfortuntely all dll's produced are .NET 4.0 (inherited from my 4.0 process) which doesn't work with my other .NET 2.0 processes. Any idea how 2 different CLR versioned AppDomains can co-exist in the same process? Have a look at this question: http://social.msdn.microsoft.com/Forums/en/clr/thread/1bfd7f40-fd57-4c9f-803f-aa4b19214af9

How does the CLR handles static classes?

做~自己de王妃 提交于 2019-12-06 03:36:36
Can anyone explain how the CLR handles Static classes? Does the CLR create one singleton instance for handling static classes internally? If not, why do we have a static constructor in C#? (Per my understanding, we use constructors only for instantiating the class) Sriram Sakthivel First of all there is no static class in CLR. CLR doesn't know anything about static class. It is the feature of C#. Static classes are compiled into abstract as well as sealed class. Making it abstract prevent instantiation of it and sealed prevents inheritance. Static classes are no special, it is just a simple

C#/CLR: MemoryBarrier and torn reads

本秂侑毒 提交于 2019-12-06 03:33:25
问题 Just playing around with concurrency in my spare time, and wanted to try preventing torn reads without using locks on the reader side so concurrent readers don't interfere with each other. The idea is to serialize writes via a lock, but use only a memory barrier on the read side. Here's a reusable abstraction that encapsulate the approach I came up with: public struct Sync<T> where T : struct { object write; T value; int version; // incremented with each write public static Sync<T> Create() {

What could explain over 5,000,000 System.WeakReference instances on the managed heap?

强颜欢笑 提交于 2019-12-06 03:19:28
问题 I have been running load tests against a production ASP.NET web application and am seeing a huge number of System.WeakReferences created on the heap. Within about 15 minutes under load managed heap memory has shot up to about 3GB and I have approximately 5,000,000 references to System.WeakReference. Performing a forced garbage collection of all generations does not release these references. I have seen posts about the __ENCLIST helper class which if assemblies are compiled in debug can create

What is the use of IL file generated from .NET (using MSIL assembler- ilasm.exe)?

二次信任 提交于 2019-12-06 02:21:59
What is the use of IL file generated from .NET (using MSIL assembler- ilasm.exe)? I read it from http://msdn.microsoft.com/en-us/library/496e4ekx.aspx but i am not sure about the use of IL file generated from .NET (using MSIL assembler- ilasm.exe). Can any one explain me? You might want to use IL directly in those (admittedly rare) situations when a higher level language like C# doesn't provide the precision or features you need. For instance, there are some features in System.Dynamic that are used from the dynamic languages such as IronPython that can't easily be used in C#. Going straight to

Can AppDomainManager be loaded by ProvideAssembly from a CLR Host?

匆匆过客 提交于 2019-12-06 02:06:31
I have an application hosting the .net clr with a custom AppDomain Manager and an AssemblyManager with a store. This all works fine when the Assembly with the AppDomainManager in is a dll in the same directory as the executable. What I want to do is embed the Managers assembly inside the executable. When I do this ProvideAssembly is called with the correct strong name, I return a stream with the assembly bytes, but ICLRRuntimeHost->Start() returns an error indicating that a type cannot be loaded. All the assembly binding details match etc. My questions is, does anyone know if this

.net Runtime - Silverlight Runtime =?

大兔子大兔子 提交于 2019-12-06 01:32:54
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? Silverlight Runtime (Silverlight CLR) is essentially a mini-mini CLR :). Microsoft did the work of removing many dependencies to .NET Framework assemblies not part of the Silverlight release Silverlight CLR is a subset of the .NET Framework that contains components and libraries, including

Can my .Net app reference two different versions of a .net framework library?

倖福魔咒の 提交于 2019-12-06 01:29:44
问题 Say I have two projects, P4 and P3, targetting .net 4.0 and 3.5 respectively. Each project also has a reference to System.Data. In the case of P4, it will be to System.Data v4.0.0.0 In the case of P3, it will be to System.Data v2.0.0.0 Project P4 also references P3. If P4 is loaded and executed, it uses the .net 4.0 CLR. At runtime, references to System.Data seem to resolve to v4.0 inside both P4 and P3. I can override this by using assemblyBinding redirects, but then both P4 and P3 resolve

HashSets don't keep the elements unique if you mutate their identity

亡梦爱人 提交于 2019-12-06 01:27:15
问题 When working with HashSets in C#, I recently came across an annoying problem: HashSets don't guarantee unicity of the elements; they are not Sets. What they do guarantee is that when Add(T item) is called the item is not added if for any item in the set item.equals(that) is true . This holds no longer if you manipulate items already in the set. A small program that demonstrates (copypasta from my Linqpad): void Main() { HashSet<Tester> testset = new HashSet<Tester>(); testset.Add(new Tester(1