.net

Is it possible to write a C# code, which would trigger the AppDomain.TypeResolve event?

Dear ladies and sirs. The AppDomain.TypeResolve is mysterious in my eyes. Can someone provide a sample code that triggers this event? Thanks. ...

Why am I getting a compile error when I'm trying to create a list of a dynamic object at runtime?

I've done some research and found that there apparently is an easy and understandable way to do this using reflection. Type MyType = typeof(MyObject); IList lst = (IList)Activator.CreateInstance((typeof(List<>).MakeGenericType(MyType))); I'm getting compile error. It's telling I do in fact need to supply the type to IList... Am I miss...

How do I make a .net assembly filesize as small as possible?

I have a .net assembly that contains data access code (a bunch of Typed Datasets and helper classes) that is quite large on disk (~2.5MB). What can I do to work out why it's so big and make it smaller? ...

Run code on WPF form close

How can I automatically run some code when a WPF form is closed? ...

Ecommerce Shopping Carts - Is there a gold standard?

Is there a gold standard among ecommerce shopping cart packages? I would prefer a .NET solution, but any suggestions are appreciated. I have been looking at ablecommerce and aspdotnetstorefront specifically, but both seem to have mixed reviews. Edit: To elaborate on my question, I am looking for a software package that is customizab...

Equivalent (functionality) of ObjPtr from VB6 in C#?

Does any one know if C# has an equivalent of ObjPtr from VB6, or equivalent functionality (see more info below)? Here are a couple of links to info on ObjPtr devx , thevbzone. Basically I have a third party treeview that I need to walk thru to get specific nodes but the only (relevant) info the nodes have is name ... but the node names...

Is it OK to redistribute the utility installutil that ships with .NET?

I have a .NET service built with C# and it requires install util to be properly installed. However I don't trust that it's always in the right place when my installer runs on a customer's machine. Does Microsoft allow you to freely redistribute installutil with your products? ...

Refactoring an If else tree

I have an if else tree that is going to grow as I add additional items for it to maintain and I'm looking at the best way to write it for maintainability I'm starting with this code private void ControlSelect() { if (PostingType == PostingTypes.Loads && !IsMultiPost) { singleLoadControl.Visible = true; singleTru...

AddWithValue difficulty

I want to run parameterized SQL with .NET. But when I use AddWithValue() the generated command does not work. SqlCommand cmd = new SqlCommand("SELECT * FROM table WHERE table.name = @A") cmd.Parameters.AddWithValue("@A", "A string"); Generates this sql command: exec sp_executesql N'SELECT * FROM table WHERE table.name = @A',N'@A nva...

How do I start a process with idle priority in .Net

I'm using System.Diagnostics.ProcessStartInfo to set up the parameters for launching a process from a .Net program. Once the the process is started, I can use myProcess.PriorityClass = ProcessPriorityClass.Idle to change the priority for the process to idle, so that it only runs in the background, and doesn't hog my CPU power. Is the...

C# - Emulate device - Parallel to Serial Port

We are trying to emulate a device that runs off a parallel port. We have the exact same model that runs on RS232, and can run a null modem cable from one port to another and emulate the device with the following settings: _port = new SerialPort { PortName = comport, BaudRate = 960...

Managing asp.net membership in production

I have been using the 'Web Site Administration Tool' that you can bring up in Visual Studio to manage users and roles in our dev and staging environment. Currently we have no way of managing users and roles when the app goes to our production servers. for now we have been calling stored-procedure in the membership database to manually ...

dynamic keyword, c# compilation service - how to run code that is not yet available at compile time?

I'm writing a small visualization tool in wpf, the idea is that average users can create interesting visualizations without being programming wizards. I have a controller class that has methods like StartPath(double x, double y) and LineTo(x,y) CurveTo(...) etc. The idea is that a user can type these commands into a textbox and have it...

Which is a good way to maintain resources for Internationalization in .Net

I have thought of three approaches to create and maintain resources in .Net projects for WinForms using Visual Studio 2008. (I am sure there should be more than three ways.) I need to decide on one before starting to implement internationalization for our product. Have individual sets of resource files (resx) for each windows form or p...

Does building a Delphi project with MSBuild create .Net dependencies?

This may be a stupid question, as I'm not sure how MSBuild works with Delphi under the hood, but we have a Delphi app that needs to run with no .Net dependencies, and since we have updated our build process (now using team build with msbuild) the app won't run without .Net. I am just trying to narrow things down, so I'd appreciate any he...

Code Coverage in VS2008 on .net runtime callable wrappers

I have a .DLL which contains .NET Runtime callable wrappers for COM/DCOM objects. I have written a testing suite in C# in VS 2008 which calls our server functions which are in the abovementioned .DLL. When code coverage was turned on and testing suite ran, code coverage test results did not yield any statistics and displayed zeroes for...

Should I make my private class methods static?

Is there a best practice for making private methods in classes static? I have a class with a few methods. Some of these can easily be made static, since they simply process data. Should I make them static or just leave them as is? Is this more of a style issue? Are there performance considerations? Edit: http://stackoverflow.com/qu...

Wcf Request Lifecycle

Is there a lifecycle that WCF requests go through? Specifically I need to be able to intercept and possibly cancel requests made before they get to the method that was invoked. ...

VB/C#: Placing disposible objects in global scope: Is this okay?

As an optimization, I decided to put an object I frequently need - an SDL surface with a prerendered image of the entire level (called S_AreaBMP) - at global scope. Now it doesn't have to be created and destroyed in the DrawScreen function every frame. I only need to dispose and change it when a new level or GFX sheet is loaded, which I ...

.Net mocking framework to capture method parameter and examine it latter?

Is there some .Net mocking framework that allows to capture the actual parameter passed to method to examine it latter? Desired code: var foo = Mock<Foo>(); var service = Mock<IService>(); service.Expect(s => s.Create(foo)); service.Create(new Foo { Currency = "USD" }); Assert(foo.Object.Currency == "USD"); Or a bit more complex exam...