.net

Adding .net Webservice references

I'm getting near completely different objects from the same WSDL file when I try to Add a Web Reference depending if I am using Express or Pro version of the vs2008 .NET IDE. 1) Why is this happening? I'd expect the WSDL's to act the same across platforms--clearly they are not! 2) How do I determine what tool/wizard the IDE is calling w...

What's the right way to dynamically choose menu items for a context menu in WinForms?

I'm trying to make a context menu for a control that is "linked" to a main menu item. There are two fixed menu items that are always there and an arbitrary number of additional menu items that might need to be on the menu. I've tried solving the problem by keeping a class-level reference to the fixed menu items and a list of the dynami...

Handling different ConnectionStates before opening SqlConnection

If you need to open a SqlConnection before issuing queries, can you simply handle all non-Open ConnectionStates in the same way? For example: if (connection.State != ConnectionState.Open) { connection.Open(); } I read somewhere that for ConnectionState.Broken the connection needs to be closed before its re-opened....

Machine.Migrations mature enough to be used?

Ok thanks for the 1st guy I found the code. Machine.Migrations: I mean, the data schema/data migration framework. I mean, the one mentioned here: http://blog.eleutian.com/2008/04/25/AFirstLookAtMachineMigrations.aspx Ok so somebody had used it? I think I would like to have such framework in my project (I have been using rails, such fr...

How Do VB.Net Optional Parameters work 'Under the hood'? Are they CLS Compliant?

Let's say we have the following method declaration: Public Function MyMethod(ByVal param1 As Integer, _ Optional ByVal param2 As Integer = 0, _ Optional ByVal param3 As Integer = 1) As Integer Return param1 + param2 + param3 End Function How does VB.NET make the optional parameters work within the confines of the CLR? Are...

When to use Windows Workflow Foundation?

Some things are easier to implement just by hand (code), but some are easier through WF. It looks like WF can be used to create (almost) any kind of algorithm. So (theoretically) I can do all my logic in WF, but it's probably a bad idea to do it for all projects. In what situations is it a good idea to use WF and when will it make thing...

What is "Best Practice" For Comparing Two Instances of a Reference Type?

I came across this recently, up until now I have been happily overriding the equality operator (==) and/or Equals method in order to see if two references types actually contained the same data (i.e. two different instances that look the same). I have been using this even more since I have been getting more in to automated testing (comp...

How do I embed an image in a .NET HTML Mail Message?

I have an HTML Mail template, with a place holder for the image. I am getting the image I need to send out of a database and saving it into a photo directory. I need to embed the image in the HTML Message. I have explored using an AlternateView: AlternateView htmlView = AlternateView.CreateAlternateViewFromString("<HTML> <img src=cid:V...

Why should events in C# take (sender, EventArgs)?

It's known that you should declare events that take as parameters (object sender, EventArgs args). Why? ...

WCF service for receiving image

What is the best way to create a webservice for accepting an image. The image might be quite big and I do not want to change the default receive size for the web application. I have written one that accepts a binary image but that I feel that there has to be a better alternative. ...

Reduce startup time of .NET windows form app running off of a networked drive

I have a simple .NET 2.0 windows form app that runs off of a networked drive (e.g. \MyServer\MyShare\app.exe). It's very basic, and only loads the bare minimum .NET libraries. However, it still takes ~6-10 seconds to load. People think something must be wrong that app so small takes so long to load. Are there any suggestions for impr...

Is there a .NET performance counter to show the rate of p/invoke calls being made?

Is there a .NET performance counter to show the rate of p/invoke calls made? I've just noticed that the application I'm debugging was making a call into native code from managed land within a tight loop. The intended implementation was for a p/invoke call to be made once and then cached. I'm wondering if I could have noticed this mist...

Testing Abstract Class Concrete Methods

How would design and organize tests for the concrete methods of an abstract class? Specifically in .NET. ...

ReSharper giving C# 3.0 Code Inspection Warnings to .NET 2.0 Projects

When I am working in .NET 2.0 projects with the newest version of ReSharper (4.1) I am getting warnings about using the var keyword and lambadas etc.. Any idea how I can disable this only for .NET 2.0 projects? ...

How do you maintain separate webservices for dev/stage/production

We want to maintain 3 webservices for the different steps of deployment, but how do we define in our application which service to use? Do we just maintain 3 web references and ifdef the uses of them somehow? ...

Is there any performance benefit with "chaining" statements in .NET?

When retrieving a lookup code value from a table, some folks do this... Dim dtLookupCode As New LookupCodeDataTable() Dim taLookupCode AS New LookupCodeTableAdapter() Dim strDescription As String dtLookupCode = taLookupCode.GetDataByCodeAndValue("EmpStatus", "FULL") strDescription = dtLookupCode.Item(0).Meaning ...however, I've also ...

Connection Timeout exception for a query using ADO.Net

Update: Looks like the query does not throw any timeout. The connection is timing out. This is a sample code for executing a query. Sometimes, while executing time consuming queries, it throws a timeout exception. I cannot use any of these techniques: 1) Increase timeout. 2) Run it asynchronously with a callback. This needs to run in a...

(any == System.DBNull.Value) vs (any is System.DBNull)

Does any one have a preference on how to check if a value is DBNull? I've found these two statements give me the results I want, but just wondering if there's a preference? if (any is System.DBNull) ... same as: if (any == System.DBNull.Value) ... Thanks! Ricardo. ...

Get a list of all computers on a network w/o DNS

Greetings, I need a way (either via C# or in a .bat file) to get a list of all the computers on a given network. Normally, I use "net view", but this tends to work (from my understanding) only within your domain. I need the names (or at least the IP Addresses) of all computers available on my network. Being able to get all compute...

.NET String.Format() to add commas in thousands place for a number

I want to add a comma in the thousands place for a number. String.Format()? ...