.net

Converting COM object returned by IHTMLDocument2.Script.InvokeMember() to something useful

I'm working with some code in C#.NET for an Internet Explorer extension that calls Javascript in the browser and gets the return value from the Javascript call. When the Javascript returns a primitive type or an array of primitive types, I get something that I can deal with, but when the Javascript returns an object, I get an opaque COM...

What are the consequences of NON-CLS Compliant code in .NET?

I have a couple of nagging compiler warnings for an app that I ported from VB6 a while back regarding CLS-Compliance including: Name '_AnIdentifier' is not CLS-Compliant. Type of parameter 'myType' is not CLS-Compliant. Despite this, my app seems to perform just fine from COM and Managed clients. I have seen several articles describin...

Do you use TestInitialize or the test class constructor to prepare each test? and why?

This question regards unit testing in Visual Studio using MSTest (this is important, because of MSTest's execution order). Both the method marked [TestInitialize] and the test class constructor will run before each test method. So, the question is, what do you tend to do in each of these areas? Do you avoid performing certain activities...

SEHException from applications on a mapped share

Background We run all our windows forms applications from a windows share (UNC) mapped locally to user's W drive. We've had connection issues the past few days and are receiving System.Runtime.InteropServices.SEHException's from somewhat random places in our programs after they have been running from several minutes to several hours. ...

Is datareader quicker than dataset when populating a datatable?

Which would be quicker. 1) Looping a datareader and creating a custom rows and columns based populated datatable 2) Or creating a dataAdapter object and just (.Fill)ing a datatable. Does the performance of a datareader still hold true upon dynamic creation of a datatable? ...

Creating a new List

When creating a new list do you specify an initial size or leave it blank? I know by specifying an initial size you avoid having the list reallocate the underlying array every-time you add x number of items but you also add verbosity to your code. Is the minimal performance gain worth adding verbosity and complexity to your code. What ha...

ASP.NET/ADO.NET: Handling many database connections inside a .NET Object?

Hi! We have a .NET object that does a lot of reading/writing with the database. Throughout the life cycle of this object (or the asp page that uses it), it may hit the database with a query/update anywhere from 1 to 10 times. Instead of opening and closing a database connection every time the object needs to hit the database, it simpl...

Linqtosql remove from list

myRule.ToList().RemoveRange(0, count); Even though it does not give me error, it does not work. What's the other way? ...

How fast is AppDomain creation?

I have just discovered that if generating assemblies via Reflection.Emit, the .NET framework keeps references in a static member that prevents Reflection.Emit classes not to be GC'ed. I cannot use DynamicMethod due to limitations. I also generate a lot of assemblies (incremental compiler of IronScheme) over the course of a program (co...

How do I determine which monitor my winform is in?

I have been up and down this site and found a lot of info on the Screen class and how to count the number of monitors and such but how do I determine which montitor a form is currently in? ...

LINQ with FoxPro?

Is there a reasonable way to access FoxPro databases using LINQ? ...

Cancelling a WPF TextBox Changed Event

I'm in the process of learning WPF coming from WinForms development. I have a TextChanged event assigned to one of my TextBox's in my WPF application. If the user enters invalid data, I want to be able to revert to the previous text value. In the old forms day, I would replace NewValue with OldValue, but it seems WPF doesn't work the ...

How to Toggle confirm message box from aspx.cs page

I have a search program that will be looking at a database from a database. If the date range is more than 3 weeks I want to alert them that it might take a while with all the data in the database. I have a confirm message box in a javascript funtion. I want to check the date range in the aspx.cs page. how do I totrigger the message ...

InfoPath forms on client vs. hosted in Forms Server / MOSS

Is there a definitive list of functional differences between InfoPath forms in the InfoPath client vs. InfoPath forms hosted via Forms Server? Talking to people who have worked with and deployed the technology before, they can't tell me anything specific except that more complex forms are not possible when you host them in Forms Server....

Porting VB.NET Winforms Application to C#

Are there any 'good' resources for porting a VB.NET winforms application to C#? I'm sure there are is software that just translates the code, but I'm looking to refactor the code at the same time. Keeping it in its current form is problematic, since it uses some of the 'bad design' practices that VB.NET allows, and would further compli...

Setting the HTTP response status code from ASMX Web Service

Hello, I know with ASP.NET there's a global handler Application_EndRequest handler where I could change the Context.Response.StatusCode, and set it to 200 which is my desire. Now with asmx Web Services, I'm not really sure where I'd put this logic in. I know I'm definitely not interested in writing an ISAPI Filter, and I'm not really...

Windows/.NET way to monitor/debug the serial port?

I have an application which is .NET 2.0, running on Windows XP Professional. This app uses the Serial Port to communicate with some custom devices. For some reason, a few of our custom built PCs have an issue with the Serial Port, where it will stop functioning after a few weeks of use. Other that auto-reboots, which won't work in my ...

Why are my custom performance counters not appearing for my service?

I've got a windows service that has a part I'm very paranoid about, so I've instrumented it with custom performance counters (I'm moving calls from mta threads to sta threads--don't ask). The counters and the configuration section have been tested and are known to work... on my machine, but they aren't appearing on the server I instal...

Making Applications programmed in .NET languages work on older machines

Wondering if anyone knows how to see what parts of the .NET framework need to be installed to get cerftain functions working on older machines. Is there a way I can install them with my application without installing the entire .NET framework? ...

Are there tools to compile CIL to a binary?

After seeing a previous post "Making Applications programmed in .NET languages work on older machines", I've got to wonder; Are there tools to compile CIL to a binary? If so, you could convert a CIL file to a native Windows app if you didn't want the user to require the .NET framework? Or even target the linux platform from .NET! Tha...