.net

How does TransactionScope work?

When Method1() instantiates a TransactionScope and calls Method2() that also instantiates a TransactionScope, how does .Net know both are in the same scope? I believe it doesn't use static methods internally otherwise it wouldn't work well on multithreaded applications like asp.net. Is it possible to create my own TransactionScope-like ...

Question about checking for null values.

I just got into a debate with one of my coworkers about checking for null values. He SWEARS that "in certain situations" the code below would give him a null value exception: string test = null; if(test == null) //error here { } but that if changed the code to this there would be no error: string test = null; if(null == test) //NO ...

LINQ Entities vs Custom Entities in LINQ to SQL

I didn't use LINQ to SQL in project, I just went through a hand-on lab for Developing Data Access Logic with LINQ, one of the tasks is to create entity translator classes to translate between linq entities and business entities. I am a little confused about this because I thought the reason we use LINQ to SQL is that it can auto gener...

Get ConnectionTimeout from Data Link Properties Dialog

Using the below code I open the DataLinkDialog. The type ADODB._Connection has a ConnectionTimeout property and the dialog has two spots to edit a property called Connect Timeout. But these properties don't seem to correspond to each other. No matter what I change the value on the dialog to connection.ConnectionTimeout is always 15. For ...

Performance Problems - Large DLLs and Large Namespaces

This is sort of the next step of the LINQ to DB2 question I asked here. Following zb_z's answer, I poked around a bit with the code for DB_Linq and have managed to add working DB2 support. (It's still in its infancy now, not ready to be contributed back to the project yet.) The proof of concept worked great, it was pretty exciting act...

Does a property within an ObservableCollection require a PropertyChangedEvent

Do properties on an object within an Observable collection require a PropertyChangedEvent? For example: public class MyObject { public int MyProperty { get; set;} } public class MyViewModel { ObservableCollection<MyObject> MyObjects = new ObservableCollection<MyObject>(); } From what I can tell, if I execute MyObjects[0].My...

How can I make messages (coming from the domain) format/markup ignorant?

I want to send back formatted messages from my domain, For example things like: (Bear with me this is not a real example, its just to illustrate my point) Hello Mr user, you cannot perform that task because: reason 1 reason 2 reason 3 I also want to show colors. Right now I am sending it from the domain already ma...

WebBrowserNavigatingEventArgs.Cancel not working on WebBrowser.Navigating?

I have a WebBrowser, a check box, a button and the following code: public partial class Form1 : Form { public Form1() { InitializeComponent(); webBrowser1.Navigating += new WebBrowserNavigatingEventHandler(webBrowser1_Navigating); } void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs...

System.Diagnostics.Trace.TraceListener UnsafeStringCopy exception from ASP.NET

I get an odd intermittent error when trying to write a Diagnostics.Trace message from an assembly used by an ASP.NET application. It's .NET 3.5 on IIS7. The code setup is that when web.config has debug specified I add an instance of HttpResponseTraceListener to System.Diagnostics.Trace.Listeners. I'm doing it that way so in my other a...

WPF DataGrid MouseOver on DataGridRow

I can't figure out why the first part of code isn't working, but the second is. PART 1 <DataGrid.RowStyle> <Style TargetType="DataGridRow"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" ...

How do you safely store an encryption key in .Net?

If you have a .Net application (or any other application for that matter,) how do you safely store internal encryption keys? I'm not talking about user-entered keys, but keys that are hard-coded in the program itself, for talking between other instances of the program. For example, if you have a peer to peer type program, you may want to...

What is the relative path of a Resources.resx file with regards to the .exe?

I have a simple Console Application, and I have several configurable strings in the Resources.resx, but the binary is unable to find its Resources.resx when I do run it from Debug, or Release directory. When I do run it from VS 2010, everything works fine. Where should I locate that Resources.resx file? I tried putting the Resources....

How to get ALL child controls of a WinForm of a specific type (Button/Textbox)?

I need to get all controls on a form that are of type x, I'm pretty sure I saw that code once in the past that used something like this: dim ctrls() as Control ctrls = Me.Controls(GetType(TextBox)) I know I can iterate over all controls getting children using a recursive function, but wondering if there is something more easier or str...

How to use the "where" keyword in C# with a generic interface, and inheritance

What I want to achieve is this: Declare a generic class (<T>), Have the "T" restricted to types that implement IMySpecialInterface<X> (where "X" is not a known type), And have the class inherit from a parent class. to give an incorrect example: public class MyClass<T> : MyParentClass where T : IMySpecialInterface<X> { ... } What i...

Convert PDF File to Image - VB/C#

Hello, Was just wondering if anyone's written or come across a PDF to Image Conversion App! If so, I need some guidelines or preferably, code. I tried using some cheap s/w's but they all were turned out to be unreliable. FYI: I need to process a large set of PDF Files (~5-10 K) and convert usually 1-2 Pages of it to an Image Format. ...

VB.NET: Declaring a function inside a base class non-overridable

I have a base class foo that will be used in multiple child classes of similar but slightly different function: Public MustInherit Class foo Public Function bar1() as Something ''// Perfectly OK to change what this method does End Function Public Function bar2() as Something ''// Does a very specific thing I...

CacheCallHandler Enterprise Library Contrib?

The CachingCallHandler included in Enterprise Library 4.1 was removed for Enterprise Library 5.0+. The documentation refers to using the Enterprise Contrib Library to get this functionality, if needed. My questions: Where is this functionality in the Enterprise Contrib Library? Does this work with Enterprise Library 5.0? This is the...

DataServiceContext.Timeout Property Unit of Time

I am trying to determine what is the unit of time for the ADO.Net Data Services timeout property. MSDN help doesn't identify it: http://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicecontext.timeout.aspx Can anyone confirm what the property value represents? ...

Drag and Drop in .Net c#

Hi I have implemented a list that i want to be able to order using drag and drop. I have implemented the list using the ajaxToolkit ReorderList. It works perfectly on the user interface the problem i am having is related to the update of the data into the database. I created a button that allows the user to save the changes (all at ...

Application's shortcut keys "swallowed" by child components

In my main application Form I have a number of menu and toolbar button functions to which I have assigned shortcut keys such as F10, F11 and F12. The shortcuts work well except for instances where certain controls have focus, such as a 3rd-party grid control. In that case the F11 or other shortcuts are handled by that control and swallow...