.net

How does SetUnhandledExceptionFilter work in .NET WinForms applications?

I am working on a project to enhance our production debugging capabilities. Our goal is to reliably produce a minidump on any unhandled exception, whether the exception is managed or unmanaged, and whether it occurs on a managed or unmanaged thread. We use the excellent ClrDump library for this currently, but it does not quite provide ...

Calling .NET methods from VB6 via COM visible DLL

I have created a .NET DLL which makes some methods COM visible. One method is problematic. It looks like this: bool Foo(byte[] a, ref byte[] b, string c, ref string d) VB6 gives a compile error when I attempt to call the method: Function or interface marked as restricted, or the function uses an Automation type not supported ...

What's the neatest way to stop a Winforms window being moved around

We have a WinForms application which runs on a touch-screen on a bit of industrial equipment. For historical reasons which are not up for changing today, the displayed form has a normal Windows title bar. We would like to stop people using the mouse (i.e. touchscreen) from moving the window by dragging the title bar. We don't care i...

ASP.NET 2.0 Application on IIS 5 Resulting in Error (aspnet_wp.exe (PID: XXXX) stopped unexpectedly.)

After hosting an ASP.NET 2.0 web application on a windows 2000 server(IIS 5). I was unable to browse the web site. The following error message was displayed on the browser and three Event Log entries were added... Error Message on Browser Server Application Unavailable The web application you are attempting to access on this web se...

Need to Impersonate user forAccessing Network resource, Asp.Net Account

Hi, I need to access a network resource on which only a given Domain Account has access. I am using the LogonUser call, but get a "User does not have required priviliege" exception, as the web application is running with the asp.net account and it does not have adequate permissions to make this call. Is there a way to get around it? Ch...

Best Practice for Forcing Garbage Collection in C#

In my experience it seems that most people will tell you that it is unwise to force a garbage collection but in some cases where you are working with large objects that don't always get collected in the 0 generation but where memory is an issue, is it ok to force the collect? Is there a best practice out there for doing so? ...

What is the most useful .net library you've found?

The .net framework comes with a bunch of really useful libraries, but there's always something better out there. What 3rd party libraries have you found that you can't live without now? is it C5? is it db4o? is it something off CodePlex? Share with the rest of us! EDIT: Please post both Free and Non-free libraries- but it would be ...

Rich Diagram Controls in WinForms

I just started using ANTS 4 .NET profiler and I am looking for something similar to their Call Graph to implement in our own WinForms application(s). In essence, we are looking for a rich (animated) control that we could use to display the relationship between objects in our application - such as the hierarchal relationships between cust...

Programmatically Printing in Adobe Reader 9 using .NET Interop

I am using VB.Net WinForms. I would like to call the Adobe Reader 9 ActiveX control to print some PDFs. I have added the ActiveX control to the VS toolbox (the dll is AcroPDF.dll, the COM name "Adobe PDF Reader". After some experiment the following code works. Dim files As String() = Directory.GetFiles(TextBoxPath.Text, "*.pdf", Sear...

Keep ConnectionString in LINQ designer file

Whenever I drop a new database object from server explorer into the dbml, Visual Studio replaces the connection string in the designer file with a new one that it automatically adds to the connection strings in my config file. They both have exactly the same parameters, just different names. How do I force Visual Studio to use and keep ...

Query with a join or use LINQ magic?

Is is better to do a joined query like this: var employer = (from person in db.People join employer in db.Employers on person.EmployerID equals employer.EmployerID where person.PersonID == idPerson select employer).FirstOrDefault(); Or is it just as good to do th...

How do I create a network of sites that understand single sign-on?

I have several sites (Asp.Net) that I would like to have a single sign on for... I would like a user to visit Site1 and have Site1 contact a central single sign-on server (SSS). The SSS would then determine that the user was not logged on (Not sure how) and would redirect the user to a Logon screen (Still on the SSS). If authenticat...

Is a memory leak created if a MemoryStream in .NET is not closed?

I have the following code: MemoryStream foo(){ MemoryStream ms = new MemoryStream(); // write stuff to ms return ms; } void bar(){ MemoryStream ms2 = foo(); // do stuff with ms2 return; } Is there any chance that the MemoryStream that I've allocated will somehow fail to be disposed of later? I've got a peer...

.Net DataBinding a new object with value type properties

Using data binding, how do you bind a new object that uses value types? Simple example: public class Person() { private string _firstName; private DateTime _birthdate; private int _favoriteNumber; //Properties } If I create a new Person() and bind it to a form with text boxes. Birth Date displays as 01/01/0001 and ...

How to "bind" services to specific channels (tcp, http, ipc) in a .NET Remoting server?

I have a complex .NET Remoting server app that provides a couple of services. Clients can currently use tcp and http channels to connect to the server. Now I need to implement some new administration services, but I want to restrict their availability to the local machine, i.e. I want to create an administration tool that can use these ...

Why CLR integration assemblies have a random version number

For some reason, new projects set the version number of the assembly to 1.0.*, which then assigns what appears to be a random number once compiled. Why is this not set to 1.0.0.0 like all other projects. Thanks. ...

Getting i-th value from a SortedList or SortedDictionary

Hi, I have a sorted collection of objects (it can be either SortedList or SortedDictionary, I will use it mainly for reading so add performance is not that important). How can I get the i-th value? So e.g. when I have numbers 1, 2, 3, 4, 5 in the collection and I want the median (so 3 in this example), how can I do it? ...

Is it possible to translate a user-entered mathematical equation into C# code at runtime?

I would like to allow the user to enter any equation, like the following, into a text box: x = x / 2 * 0.07914 x = x^2 / 5 And have that equation applied to telemetry data that is coming from a device connected via a serial port. The incoming data points are represented by x and each data point is processed by the user-specified equa...

creating application shortcut in a directory

How do you create an application shortcut (.lnk file) in C# or using the .NET framework? The result would be a .lnk file to the specified application or URL. ...

CAS: Running exe from intranet

Before I get flamed and down-voted without mercy, my company will not allow the install of .NET3.5 on non-dev machines yet (others are currently on 3.0). I have a managed exe on network share that needs to be able to run from there. This is a common problem with pre-.NET3.5SP1, but I cannot figure out how to solve it. I have read thi...