.net

Changing a Property into a Method - any side effects?

I have a class that has some properties. And I want something that calculates a Score out of these properties. Since this is a trivial task (some additions and divisions, but nothing spectacular). So naturally, the question is: "When to use a Property with some code in the getter, and when to use a function?", and that question was alre...

ThreadAbortException calling OdbcDataReader.ExecuteReader()

I'm running an SQL query against a mainframe DB2 database using the OdbcDataReader class and ExecuteReader() method. This code is in production and has been running fine for months. The query normally takes 1-2 minutes to execute. This past Friday, the query encountered a ThreadAbortException. Below is the formatted stack trace. The A...

Resharper: vars

Why does Resharper want you to change most variables to var type instead of the actual type in the code? ...

Where is the copy local option?

I'm trying to add dll references to an ASP.NET 3.5 project(Web Forms not MVC), and all of the references I'm adding keep showing up as auto updating. I right clicked on the dll in the bin folder to specify copy local, but the option isn't there. I went back to one of 2.0 projects, and I have plenty of dll's that aren't auto updating, b...

.NET DateTime.Now returns incorrect time when time zone is changed

This problem occurred during daylight saving time change. After the change occurred, we've noticed that our server application started writing into the log incorrect time - one hour ahead which means that .NET caches time zone offset. We had to restart our application to resolve this problem. I wrote a simple application to reproduce thi...

When is it better to use String.Format vs string concatenation?

I've got a small piece of code that is parsing an index value to determine a cell input into Excel. It's got me thinking... What's the difference between xlsSheet.Write("C" + rowIndex.ToString(), null, title); and xlsSheet.Write(string.Format("C{0}", rowIndex), null, title); Is one "better" than the other? And why? ...

Is it possible to use workflow parameters with workflows hosted by WorkflowServiceHost?

Normally, the method of passing workflow parameters to the workflow happens in the call to RunWorkflow. However, with the WorkflowServiceHost, there is no such method call involved. You simply call the Open() method on the instance. Any ideas? Of course, the implication is that I add more parameters to the service contract, but these...

Best OO practice to adapt one type to another?

I have a collection of domain objects that I need to convert into another type for use by the .NET framework. What is the best practice for doing such a transformation? Specifically, I have a type called ContentEntry and I need to convert it into a SyndicationItem for use in putting into a SyndicationFeed. The conversion itself is strai...

Dealing with passwords in NAnt build script

Is there a way to prompt the user for input during a NAnt build? I want to execute a command that takes a password, but I don't want to put the password into the build script. ...

Does anyone know where I can find String Resource Generator?

Is the project still around? ...

Is there any advantage to using C++/CLI over either standard C++ or C#?

I'm not seeing any real advantages, other than the fact that you have a C++ syntax, and with it, things like pointers and destructors. ...

ChannelFactory don't have an address on the endpoint, why?

When I create a new instance of a ChannelFactory: var factory = new ChannelFactory<IMyService>(); and that I create a new channel, I have an exception saying that the address of the Endpoint is null. My configuration inside my web.config is as mentioned and everything is as it is supposed to be (especially the address of the endpoin...

ASP.NET Long Running SQL Server Procedure - How to handle? Messaging?

I have a web application that needs to fire off a long-running SQL Server procedure (to rebuild a table) when certain criteria are met. What is the recommended procedure to do this? I was thinking, when the criteria are met a record would be inserted into the database and a scheduled SQL server job would check that table at a specified ...

Disabling authenticode signature verification in .NET exe without app.config

Does anyone know how to disable authenticode signature verification in a .NET executable (to avoid slow startup) without using an application config file? In other words, do this: <configuration> <runtime> <generatePublisherEvidence enabled="false"/> </runtime> </configuration> without an app.config. Is it possible? ...

How do I get PowerShell to grab a logfile when it overflows?

I am using Powershell PSeventing plugin but have had no luck so far finding an event that triggers when an event log is full. I am looking everywhere MSDN .net events I know it has to do with maximum event log size but I can't find that trigger and I'm not sure how to get PSeventing to make thing happen. Can anyone help me. Thank in a...

VBx language hosting via DLR?

There are various samples available for how to host Python or Ruby running on the DLR, inside your own AppDomain. Are you able to do this yet with VB? There have been mentions of this since the DLR was announced 18 months ago, but I can't find a code sample for it. Maybe with the PDC VS10 CTP? If so, what assembly contains the appropri...

Provisioning SQL 2008 Database with C# Application

Hi all, I have an internal enterprise application I've developed for my company built on .Net 3.5 / SQL 2008. I have two types of databases. The main system database which contains all of our global data, such as user names, and customers, etc. And project databases, which contain the actual data pertaining to our clients project. ...

Async command pattern - exception handling.

I am implementing an asynchronous command pattern for the "client" class in a client/server application. I have done some socket coding in the past and I like the new Async pattern that they used in the Socket / SocketAsyncEventArgs classes. My async method looks like this: public bool ExecuteAsync(Command cmd); It returns true if the e...

Default font for Windows Forms application

Hello, Everytime I create new form in my application, it uses "Microsoft Sans Serif, 8.25pt" font by default. I'm not changing it, because I know that in this case my form will pick up whatever default font in system is. However, when I run my application, the font is still anything but Segoe UI. Why this happens? How do I make sure th...

System.IO.FileNotFoundException exception when attempting to drop UserControl on Form in designer

I have created a custom UserControl in Managed C++ that wraps some native code controls. I have confirmed the control works at runtime, and have been trying to make the control work with the Visual Studio designer by allowing drag and drop of the control from the designer toolbox. While I have successfully added the UserControl to the t...