Re: [ADVANCED-DOTNET] Why is Activator.CreateInstance() so much slower than CreateInstance(type) ?

2007-02-28 Thread Marc Brooks
In my benchmark using the Dynamic library[1], my LCG stuff is much faster: 10 ReferenceType objects (Person):. Activator:00:00:00.0843059 Activator: 00:00:00.3047689 Dynamic: 00:00:00.0179958 [1] http://www.codeplex.com/Dynamic -- "I am Dyslexic of Borg. Resistors are fertil

Re: [ADVANCED-DOTNET] Alternatives to remoting

2007-02-28 Thread Dean Cleaver
Hi, My issues aren't with the returned serialisable classes - it's with the remote classes. Strangely, I can create an instance of my remote factory, but when the factory tries to return an instance of another MarshalByRef class, it fails with a "System.InvalidCastException: Return argument has an

Re: [ADVANCED-DOTNET] Why is Activator.CreateInstance() so much slower than CreateInstance(type) ?

2007-02-28 Thread Barry Kelly
Sébastien Lorion <[EMAIL PROTECTED]> wrote: > Ok, makes sense... But the question of Frans then remains unanswered. > Without measuring, I would also have guessed that the generic version > would be faster. The cost differential for value types is even bigger. Same test program as last time, only

Re: [ADVANCED-DOTNET] Why is Activator.CreateInstance() so much slower than CreateInstance(type) ?

2007-02-28 Thread Sébastien Lorion
Ok, makes sense... But the question of Frans then remains unanswered. Without measuring, I would also have guessed that the generic version would be faster. Sébastien www.sebastienlorion.com On 2/28/07, Barry Kelly <[EMAIL PROTECTED]> wrote: Barry Kelly <[EMAIL PROTECTED]> wrote: > Your result

Re: [ADVANCED-DOTNET] Why is Activator.CreateInstance() so much slower than CreateInstance(type) ?

2007-02-28 Thread Barry Kelly
Barry Kelly <[EMAIL PROTECTED]> wrote: > Your results appear to be anomalous because typeof(T) where T is a > non-public type invokes more security checking. I get the following > results: Oops: I meant Activator.CreateInstance(typeof(T)) invokes more checking, not typeof(T), where T is non-publi

Re: [ADVANCED-DOTNET] Why is Activator.CreateInstance() so much slower than CreateInstance(type) ?

2007-02-28 Thread Barry Kelly
Sébastien Lorion <[EMAIL PROTECTED]> wrote: > Funny, I get exactly the inverse behavior both in debug and release ... ?! > class MyReferenceType Your results appear to be anomalous because typeof(T) where T is a non-public type invokes more security checking. I get the following results: Ac

Re: [ADVANCED-DOTNET] Why is Activator.CreateInstance() so much slower than CreateInstance(type) ?

2007-02-28 Thread Frans Bouma
Hmm, my code: using System; using System.Collections.Generic; using System.Text; using System.ComponentModel; using System.Data; using System.Xml; using System.Text.RegularExpressions; using System.Diagnostics; using System.IO; using System.Collections; using System.Configuration; using System.Dat

Re: [ADVANCED-DOTNET] Why is Activator.CreateInstance() so much slower than CreateInstance(type) ?

2007-02-28 Thread Sébastien Lorion
Funny, I get exactly the inverse behavior both in debug and release ... ?! using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { const int Count = 100; DateTime now = DateTime.No

[ADVANCED-DOTNET] Why is Activator.CreateInstance() so much slower than CreateInstance(type) ?

2007-02-28 Thread Frans Bouma
I was benchmarking some type instantiation code, and I stumbled upon this: when I instantiate in a loop 1,000,000 times a class with the code: MyType t = Activator.CreateInstance(); it takes 2800ms or thereabout. When I use: MyType t = (MyType)Activator.CreateInstance(typeof(MyType)); it takes

Re: [ADVANCED-DOTNET] Virtual methods in .NET - was Implementing an Interface - C# vs. VB.NET

2007-02-28 Thread Fabian Schmied
Okay, since this months-old thread has now turned towards AOP, I'll chime in, since I've been working on a proxy-based AOP tool (and its uses) for the last two years. As I said the profiling API is not an optimal way of doing things (in particulaer because there is no good way of updating symbol

Re: [ADVANCED-DOTNET] Creating thread-safe classes to use in an ASP.NET app

2007-02-28 Thread Ben Joyce
Yes, sorry Public without Shared. Thanks for pointing that out Ryan. Ben On 2/28/07, Ryan Heath <[EMAIL PROTECTED]> wrote: > I've changed the variable declaration to "Public" and ran a test > (making use of System.Threading.Thread.Sleep) and with the Shared > declaration I was able to mimic th

Re: [ADVANCED-DOTNET] Creating thread-safe classes to use in an ASP.NET app

2007-02-28 Thread Ryan Heath
I've changed the variable declaration to "Public" and ran a test (making use of System.Threading.Thread.Sleep) and with the Shared declaration I was able to mimic the behavior and with Public it seems to be "thread safe". With "Public" you mean, without the "Shared" keyword? If not, then it is

Re: [ADVANCED-DOTNET] Alternatives to remoting

2007-02-28 Thread Krebs Kristofer
Hi I had a similar problem like this and managed to solve this by implementing my own binder. How do you get hold of the object references that you are unable to cast? In my case I couldn't do this in a certain situation: [Serializable] class MyType { ... public object Clone() { Mem

Re: [ADVANCED-DOTNET] Creating thread-safe classes to use in an ASP.NET app

2007-02-28 Thread Ben Joyce
I think I have found the problem. In my base class I had some variabled declared as "Protected Shared ". Multiple client sessions would create instances of classes derived from this base class and assign values to the variables (via exposed public properties). There was a situation yesterday wh