What is the point of the finally block?
Syntax aside, what is the difference between try { } catch() { } finally { x = 3; } and try { } catch() { } x = 3; edit: in .NET 2.0? ...
Syntax aside, what is the difference between try { } catch() { } finally { x = 3; } and try { } catch() { } x = 3; edit: in .NET 2.0? ...
If I have 2 query sources how do I find ones that are in one that are not in the other? example of join to find items in both: var results = from item1 in qs1.Items join item2 in qs2 on item1.field1 equals item2.field2 select item1; So what would the linq code be to return the items in qs1 that are not in qs2? ...
So Far I know CLR via C# is considered one ...
What's the simplest way of blocking a thread until a file has been unlocked and is accessible for reading and renaming? EG: Is there a WaitOnFile() somewhere in the framework? I have a service that uses a FileSystemWatcher to look for files that are to be transmitted to an FTP site, but the File Created event fires before the other proc...
So I have about 10 short css files that I use with mvc app. There are like error.css login.css etc... Just some really short css files that make updating and editing easy (At least for me). What I want is something that will optimize the if else branch and not incorporate it within the final bits. I want to do something like this if(Deb...
When you use a Windows Forms TextBox, the default number of tab stops (spaces) is 8. How do you modify this? ...
I have a table in a MySql database that stores user accounts. One of the columns, expires, stores an expiration date but defaults to NULL. I need to be able to remove an expiration date and set it back to the default value. Currently, all of my CRUD routines are written using MySqlCommand with parameters. Can this be done directly with ...
I've encountered multiple third part .Net component-vendors use a licensing scheme. On an evaluation copy, the components show up with a nag-screen or watermark or some such indicator. On a licensed machine, a Licenses.licx is created - with what appears to be just the assembly full name/identifiers. This file has to be included when the...
I want to load a desktop application, via reflection, as a Control inside another application. The application I'm reflecting is a legacy one - I can't make changes to it. I can dynamically access the Form, but can't load it as a Control. In .Net Form expands on Control, and I can assign the reflected Form as a Control, but it throws ...
I need to host and run managed controls inside of a purely unmanaged C++ app. How to do this? To run unlicensed controls is typically simple: if (SUCCEEDED(ClrCreateManagedInstance(type, iid, &obj))) { // do something with obj } When using a licensed control however, we need to somehow embed a .licx file into the project (ref app...
I am trying to find a way to determine at run-time how much memory a given class is using in .NET. Using Marshal.SizeOf() is out, as it only works on value types. Is there a way to check exactly how much memory a class uses? ...
Is there a way to collect (e.g. in a List) multiple 'generic' objects that don't share a common super class? If so, how can I access their common properties? For example: class MyObject<T> { public T Value { get; set; } public string Name { get; set; } public MyObject(string name, T value) { Name = name; Value ...
I am using .Net 2 and the normal way to store my settings. I store my custom object serialized to xml. I am trying to retrieve the default value of the property (but without reseting other properties). I use: ValuationInput valuationInput = (ValuationInput) Settings.Default.Properties["ValuationInput"].DefaultValue; But it seems to re...
I was given an .xml file that I needed to read into my code as a DataSet (as background, the file was created by creating a DataSet in C# and calling dataSet.WriteXml(file, XmlWriteMode.IgnoreSchema), but this was done by someone else). The .xml file was shaped like this: <?xml version="1.0" standalone="yes"?> <NewDataSet> <Foo> ...
I have allways made a point of writing nice code comments for classes and methods with the C# xml syntax. I allways expected to easily be able to export them later on. Today I actually have to do so, but am having trouble finding out how. Is there something I'm missing? I want to go Menu->Build->Build Code Documentation... EDIT: This i...
When you send an email using C# and the System.Net.Mail namespace, you can set the "From" and "Sender" properties on the MailMessage object, but neither of these allows you to make the MAIL FROM and the from address that goes into the DATA section different from each other. MAIL FROM gets set to the "From" property value, and if you set...
Is the edit control I'm typing in now, with all its buttons and rules freely available for use? My web project is also .Net based. ...
I want to ask how other programmers are producing Dynamic SQL strings for execution as the CommandText of a SQLCommand object. I am producing parameterised queries containing user generated "WHERE" clauses and SELECT fields. Sometimes the queries are complex and I need a lot of control over how the different parts are built. Currently...
In a C# Windows Forms application I want to detect if another instance of the application is already running. If so, activate the main form of the running instance and exit this instance. What is the best way to achieve this? ...
I'm having a problem running a T4 template using TextTransform.exe on my build server. On my dev machine the template works perfectly. The error message is as follows. error : Running transformation: System.TypeLoadException: Could not instantiate type System.Xml.Linq.XDocument The build server has the windows 2008 SDK on it, my ma...