Re: [ADVANCED-DOTNET] obsfucation

2006-08-04 Thread Arlie Davis
Keep in mind that all obfuscation is still only obfuscation. If a customer can run the code, they can (eventually) reverse engineer it. If you encrypt an assembly, then the customer's computer cannot decrypt or run it. So, of course, the obfuscator includes a stub that both decrypts and runs the

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

2006-07-29 Thread Arlie Davis
The main reason that methods are not virtual by default in C# is because virtual methods allow derived classes to alter the contract between a base class and the user of a class, without the base class having any control over how this is done, or even knowledge that this is being done. In other

Re: [ADVANCED-DOTNET] VS2003 Debugging Issues with Multiple UI Threads

2006-07-29 Thread Arlie Davis
I believe it gets down to one message pump handling UI messages--since each message pump needs to be on it's on thread there can be only one UI thread. Win32, and WinForms, both *definitely* support having more than 1 UI thread per process. You need to do the right thing in WinForms, which

Re: [ADVANCED-DOTNET] Stress Testing woes

2004-06-28 Thread Arlie Davis
No way no how. XP is a client OS. The documentation for IIS on XP clearly states that there is a connection limitation. This is by design. By the time you are doing stress testing, you should have access to a server. Even if you are still doing development in your office, you need to acquire

Re: [ADVANCED-DOTNET] ThreadPool.QueueUserWorkItem Memory Problems

2004-06-07 Thread Arlie Davis
Use the CLR memory profiler. It does a good job of showing you what's chewing up memory. That is, if it is instances of managed classes. If you're leaking unmanaged memory, it's more difficult to diagnose. -- arlie -Original Message- From: Unmoderated discussion of advanced .NET

Re: [ADVANCED-DOTNET] Large structures

2004-05-22 Thread Arlie Davis
Such optimizations could be done only if the method never modifies the structure. Detecting this is easier with MSIL (though not trivial) than with previous compilers. -- arlie -Original Message- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf

Re: [ADVANCED-DOTNET] Large structures

2004-05-17 Thread Arlie Davis
That isn't my decision to make. Managed DirectX uses value types for Matrix and several other types. Overall, I agree with the decision. I'm certainly not going to waste my time rolling another managed interop layer for DirectX. -- arlie -Original Message- From: Unmoderated

Re: [ADVANCED-DOTNET] Large structures

2004-05-17 Thread Arlie Davis
also decides to inline the function in question -- wouldn't even need to pass a pointer, on x86 -- just emit opcodes which read the fields from somewhere above the ebp, instead of below it.) Cheers, -Shawn http://www.windojitsu.com/ -Original Message- From: Arlie Davis [mailto:[EMAIL

Re: [ADVANCED-DOTNET] Large structures

2004-05-17 Thread Arlie Davis
That's all nice and applicable to 3D programming, but it's not really relevant. No matter how fancy your shaders are, and how powerful your GPU is -- you will still need to manipulate matrices in your app. Doing 3D in a managed language should not impose any undue / silly penalties, especially

Re: [ADVANCED-DOTNET] Large structures

2004-05-17 Thread Arlie Davis
It's an empty structure because it is a stub emitted by the managed C++ compiler. In other words, the Managed DirectX libraries are written in managed C++. This compiler has to emit *something* in the MSIL metadata that describes the types that the MDX libraries manipulate. _D3DMATRIX is

Re: [ADVANCED-DOTNET] Large structures

2004-05-17 Thread Arlie Davis
John Elliot writes: I guess I meant 'strange' as in 'closed source, poorly documented, I didn't write it, etc.' (don't know much about DirectX doco, so that's not a sledge as such). The DirectX docs are actually fairly decent. Say for example I'm targeting the managed DirectX API, and my

Re: [ADVANCED-DOTNET] Large structures

2004-05-17 Thread Arlie Davis
Almost, but not quite. Instances of a value type can be hosted within a reference type, which is always allocated in the managed heap. Two threads can then access the same instance of a value type at the same time. However, nothing horrible can happen. -- arlie -Original Message-

[ADVANCED-DOTNET] Large structures

2004-05-16 Thread Arlie Davis
I have a few questions for the advanced CLR people here. I haven't been able to find any satisfactory answers elsewhere. Consider value types / structures in CLR, and passing them as arguments to methods. Does the MS CLR *always* copy the entire structure onto the stack? Or does it ever simply

Re: [ADVANCED-DOTNET] Large structures

2004-05-16 Thread Arlie Davis
Well, I understand all about boxing, and I appreciate the response. But boxing has nothing at all to do with my question. My question is -- what, *exactly*, does the JIT compiler do when it compiles methods that take large structures as parameters? Is there a threshold beyond which the JIT

Re: [ADVANCED-DOTNET] .NET function for finding out COM ports on a PC

2004-04-29 Thread Arlie Davis
You definitely don't want to do it this way. This is fragile, and not even guaranteed to find all serial ports. Use the documented PNP APIs to discover and enumerate devices of specific device classes. For starters, look at SetupDiEnumDeviceInterfaces in Win32 SDK. There may be easier ways to

Re: [ADVANCED-DOTNET] Thread in ASP.NET, ThreadStatic, Thread Pool

2004-04-24 Thread Arlie Davis
Angel, Philip, ASP .Net requests can be handled either synchronously or asynchronously. If you are handling requests via instances of the Page class, then your requests are processed synchronously. For the duration of a synchronous call, the entire request is handled on one thread. ASP .Net

Re: [ADVANCED-DOTNET] Smuggling delegates via the context

2004-04-20 Thread Arlie Davis
There are so many different ways to do this, and many of them seem preferable to (ab)using the remoting infrastructure. Can you describe what you are trying to accomplish, and why you believe it requires using the call context? -- arlie -Original Message- From: Moderated discussion of

Re: [ADVANCED-DOTNET] Is this legal? - no compiler or runtime errors are generated

2004-04-20 Thread Arlie Davis
Enums are not boxed directly to their base (integer) type. Casting an instance of an enum to object boxes the enum instance. Try this some time: Console.Write (((object) TestEnum1.Value).GetType().FullName); -- arlie -Original Message- From: Moderated discussion of advanced .NET

Re: [ADVANCED-DOTNET] Public abstract classes with internal abstract methods

2004-04-15 Thread Arlie Davis
I'm sorry, but a public internally implementable interface just sounds like a nightmare. Keep it simple. Interfaces are interfaces. I think too many people focus on contorting object-oriented programming languages into things that they are not. They are not UML, they are not rights management

Re: [ADVANCED-DOTNET] Enumeration bounds checking?

2004-04-11 Thread Arlie Davis
Daniel is completely correct in his description of enums. One additional note -- if you do wish to validate enum values, validate them only when it makes sense to do so. In other words, validate them only when they are generated through some means other than identifying a member of the enum

Re: [ADVANCED-DOTNET] Delegate Invocation Lists

2004-04-11 Thread Arlie Davis
Actually, although it STILL may not be a good idea, it IS safe in the current implementation of the CLR. The CLR does use singly-linked lists for the default implementation of an event, i.e. public event EventHandler Foo;. However! The list is NOT managed destructively. The default

Re: [ADVANCED-DOTNET] Enumeration bounds checking?

2004-04-11 Thread Arlie Davis
Of course it fails. Why would you ever expect otherwise? -- arlie -Original Message- From: Moderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of John Elliot Sent: Friday, April 09, 2004 6:57 PM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET]

Re: [ADVANCED-DOTNET] Exceptions in Constructors

2004-04-02 Thread Arlie Davis
Throwing exceptions in a constructor is perfectly fine in .Net. And in many circumstances, it is the Right Thing. If a constructor cannot build a valid instance of a class, then it should throw an exception -- just like any other method. One key difference between virtual methods in .Net and in

Re: [ADVANCED-DOTNET] Transparent Persistence [WAS: Web Services, Remoting and Coupling]

2004-02-16 Thread Arlie Davis
Agreed, it is a problem. Transparent persistence never is. Transparent remoting -- also never is. Frameworks that make message passing easy (and which allow you to easily map message attributes to object instances or attributes) are, in general, better. Even Microsoft is moving in that

Re: [ADVANCED-DOTNET] Catching access violations

2004-01-07 Thread Arlie Davis
This is more of a Win32 problem than a CLR problem. It sounds like you are working on a service (with no user in front of it), rather than a user app. In that case, you'll need to dig into Win32 exception and error handling. When a process raises an unhandled SEH exception, NT goes through all

Re: [ADVANCED-DOTNET] Socket.ReceiveFrom and excess data

2003-12-22 Thread Arlie Davis
No. Definitely not. Allocate buffers of an appropriate size before calling ReceiveFrom or BeginReceiveFrom. Appropriate depends on your application protocol. -- arlie -Original Message- From: Moderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Alex

Re: [ADVANCED-DOTNET] .NET, XML serialisation and encapsulation (was: Web Service Desig n Question)

2003-12-15 Thread Arlie Davis
I think that's a very fair criticism. Partly, I think this is due to a sense of decompression after the strict interface-based world of COM. COM interfaces were a good idea. But COM forced everything through interfaces, since it had no real concept of classes beyond class factories and a set of

Re: [ADVANCED-DOTNET] ServiceProcess and ServiceController

2003-12-12 Thread Arlie Davis
Do NOT do this. Direct modification of the SCM registry keys is a very, very bad idea, because it gets the registry out of sync with the SCM itself. This has nothing to do with managed vs. unmanaged code. This is simply the rules for using the SCM. The best way (and it's fairly easy) is to

Re: [ADVANCED-DOTNET] thread exceptions terminate entire app - forcing try-catch usage

2003-12-09 Thread Arlie Davis
NEVER throw an exception. Or are you proposing a special exception handler for unhandled exceptions? THAT is far more offensive than any new keyword! :p -jade -Original Message- From: Moderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Arlie Davis Sent

Re: [ADVANCED-DOTNET] thread exceptions terminate entire app - forcing try-catch usage

2003-12-08 Thread Arlie Davis
Ummm, no. Methods are things that can do things. Being the top-level method frame in a stack is just one thing you can do with a thread. Methods should NOT be decorated with threadentry or other such attributes. Java has things like this, with declared exceptions that are thrown from a thread.

Re: [ADVANCED-DOTNET] C++ Dll Import Callback Function Question

2003-12-03 Thread Arlie Davis
1) Make sure you handle the calling convention correctly. As far as I know, .Net only supports using the __stdcall calling convention. So make sure that LPFN_CALLBACK is declared using __stdcall. Otherwise, if your C++ code is compiled with a different default calling convention, then when the

Re: [ADVANCED-DOTNET] WaitHandle.WaitAny Limitations

2003-11-03 Thread Arlie Davis
No. This is a design constraint of the NT kernel. Each thread has a block of wait handle pointers in its KTHREAD structure, and that block has a finite length. The reason that it is relatively small, is that WaitForMultipleObjects becomes more expensive when you have more handles involved.

Re: [ADVANCED-DOTNET] Do properties need a 'holder' keyword?

2003-10-22 Thread Arlie Davis
You're mostly smoking crack. The JIT compiler knows how to inline trivial get/set methods. However, there's nothing wrong with this approach. In the future, optimizers may be able to make better use of readonly hints, to reduce pointer dereferencing, etc. But for now, yeah, there is no real

Re: [ADVANCED-DOTNET] Do properties need a 'holder' keyword?

2003-10-22 Thread Arlie Davis
Provide performance data that backs this up, before saying there can be quite a performance penalty. Speculation is not data. Debug builds are not release builds. -- arlie -Original Message- From: Moderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Urs

Re: [ADVANCED-DOTNET] Synchronization question

2003-10-17 Thread Arlie Davis
#1 - Why are you trying to do this? This doesn't look like it performs anything useful. #2 - It appears that Microsoft's implementation is more accepting than the specifications for Monitor.Exit. The docs are pretty clear. -- arlie -Original Message- From: Moderated discussion of

Re: [ADVANCED-DOTNET] XP Disk Caching Issue

2003-10-14 Thread Arlie Davis
In XP, disks can still be optimized for fast removal. In Device Manager, open the property page for the storage device. There should be a Policies tab, which has options for Optimize for quick removal vs. Optimize for performance. On fixed disks, there are also options for controlling write

Re: [ADVANCED-DOTNET] XP Disk Caching Issue

2003-10-14 Thread Arlie Davis
You need more than just no caching. You need to dismount the volume, so that the NT device driver reloads ALL state relevant to the disk. See FSCTL_DISMOUNT_VOLUME. This is also provided via fsutil volume dismount X:. I don't see how this is relevant to advanced .Net topics, though. -- arlie

Re: [ADVANCED-DOTNET] Async Data Commands with ADO.Net

2003-10-08 Thread Arlie Davis
Use async delegates. Declare a delegate that matches SqlCommand.ExecuteNonQuery, create an instance of the delegate, and call BeginInvoke on it. Provide a completion delegate. In your completion delegate, call the delegate's EndInvoke method. Badda-bing. -- arlie -Original Message-