.net

double in .net

If I have the following code (this was written in .NET) double i = 0.1 + 0.1 + 0.1; Why doesn't i equal 0.3? Any ideas? ...

Handling uncaught exceptions in C# console application

Hi all! I'm currently writing server that hosts several modules. Server runs each module in separate AppDomain. What I want to achieve is exception isolation. I mean when one module throws exception I don't want whole process to terminate, just this specific AppDomain. I know that I can tell CLR to fallback to old behaviour (.NET 1.0) wh...

How can I sort a DataSet before doing a DataBind?

I have data coming from the database in the form of a DataSet. I then set it as the DataSource of a grid control before doing a DataBind(). I want to sort the DataSet/DataTable on one column. The column is to complex to sort in the database but I was hoping I could sort it like I would sort a generic list i.e. using a deligate. Is this ...

How do I convert a string of the form %programfiles%\directory\tool.exe to a useable Filename in C#/.net?

I have an application which takes a string value of the form %programfiles%\directory\tool.exe from its application config file. I want to make this into a useable filename so that I can call System.Diagnostics.Process.Start(filename) and have it execute the application. I'm curently getting a System.ComponentModel.Win32Exception - ...

XamlParseException: Attribute in custom control missing, but it's defined!

I sometimes get the following exception for a custom control of mine: XamlParseException occurred Unknown attribute Points in element SectionClickableArea [Line: 10 Position 16] The stack trace: {System.Windows.Markup.XamlParseException: Unknown attribute Points on element SectionClickableArea. [Line: 10 Position: 16] at System.Win...

dbmetal visual metal error:"magma string must not be empty"

i am just trying to generate the classes for linq to mysql with dbmetal / visual metal and keep running into the error: "magma string must not be empty"... i've googled, i've recompiled locally, checked the references etc. and don't really want to start debugging this... anybody had the same issue before or knows of another way to genera...

Microsoft.SqlServer.Management.Smo and its brothers works on SQL2000?

As title, I need that to run an import script generated by SQL Server DB Publishing Tool. Would that work on Sql2000 server too? Also I have seen ppl reporting missing library issues related to GAC, which libraries I precisely need to include if I am not controlling the deployment server? To know how this thing works you can check here ...

Why should I never use an unsafe block to modify a string?

I have a String which I would like to modify in some way. For example: reverse it or upcase it. I have discovered that the fastest way to do this is by using a unsafe block and pointers. For example: unsafe { fixed (char* str = text) { *str = 'X'; } } Ar...

Protected Memory Violation calling FORTRAN DLL from C#

I am trying to call out to a legacy dll compiled from FORTRAN code. I am new to Interop, but I've read some articles on it and it seems like my case should be fairly straightforward. The method I really want to call has a complex method signature, but I can't even call this simple GetVersion method without getting a protected memory ...

.NET DataTable skips rows on Load(DataReader)

I'm trying to populate a DataTable, to build a LocalReport, using the following: MySqlCommand cmd = new MySqlCommand(); cmd.Connection = new MySqlConnection(Properties.Settings.Default.dbConnectionString); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT ... LEFT JOIN ... WHERE ..."; /* query snipped */ // prepare data dat...

How do I prevent a DataGridView from sharing rows?

I've made a custom DataGridViewCell that displays a custom control instead of the cell; but if the DataGridView uses shared rows, then the custom control instance is also shared, so you get strange behaviour (for example, hovering over buttons highlights all the buttons). Also, I can't access the DataGridViewCell.Selected property, so I...

What's the difference between Invoke() and BeginInvoke()

Just wondering what the difference between BeginInvoke() and Invoke() are? Mainly what each one would be used for. EDIT: What is the difference between creating a threading object and calling invoke on that and just calling BeginInvoke() on a delegate? or are they the same thing? Thanks ...

Is it wrong to cast an enumerator of a child class to an enumerator of a parent class?

I've got an error in my build which says: Error 12 Cannot implicitly convert type 'System.Collections.Generic.IEnumerator< BaseClass>' to 'System.Collections.Generic.IEnumerator< IParentClass>'. An explicit conversion exists (are you missing a cast?) Is it wrong to simply cast it away? This is my code: public Dictiona...

.NET: is there a Click-and-drag "Desktop-Like" control?

OK, first for context look at the Windows desktop; You can take items (folders, files) on the desktop and drag them around to different places and they "stay" where you dragged them. This seems to be a pretty useful feature to offer users so as to allow them to create their own "groupings" of items. My question is thus: Is there a con...

ASPX Textbox: Execute method on return keypress

I have a search box that doesn't have a submit button, I need to be able to hit enter and then execute a method, how do I do this? ...

How to stop visual studio from updating assembly references?

In our environment we have a Lib folder which contains various third party assemblies referenced by our projects. For example, Enterprise Libary and Elmah. Sometimes a dev doesn't do a get latest on that folder. When the dev then loads a project which can't find the assembly in the expected folder, Visual Studio automatically locates ...

Thread vs ThreadPool

What is the difference between using a new thread and using a thread from the thread pool? What performance benefits are there and why should I consider using a thread from the pool rather than one I've explicitly created? I'm thinking specifically of .NET here, but general examples are fine. ...

Drools.NET vs Windows Workflow Foundation (WF)

I am currently in the process of searching for a rules engine that works in .NET. Our logic is pretty simple, +, -, *, /, and, or, basic order of operations stuff. However we are going to need to store this information in the database and then generate the rules file when a new version is pulled from the database. So the common UI edi...

.NET Decimal = what in SQL?

What's the best data type in SQL to represent Decimal in .NET? We want to store decimal numbers with up to 9 decimal place precision and want to avoid rounding errors etc on the front end. Reading about data types, it appears using Decimal in .NET is the best option because you will not get rounding errors, although it is a bit slower ...

Is there an attribute I can add to a class so it will be edited as code, not in the designer?

I've made a class which inherits from UserControl, but which I only want to use as a base for subclasses. Is there a way I can stop VS2008 from trying to edit it in the designer, that won't stop the subclasses from being edited in the designer? ...