.net

Does Aero manipulate the DPI and Screen Size? Why?

In my application, I get the screen resolution with this code: SystemInformation.PrimaryMonitorSize And I get the DPI with this code: using (Graphics g = Graphics.FromHdc(NativeMethods.GetDC(IntPtr.Zero))) { dpiX = g.DpiX; dpiY = g.DpiY; } This works fine in most situations. But when the code runs on a ...

Understanding .NET GC and OutOfMemory Exceptions

I'm troubleshooting an OutOfMemory exception in my .NET 2.0 Windows Service application. To understand the issue better I began by writing a simple .NET WinForm test app that generates an OOM Exception by building an ArrayList until an OOM Exception is thrown. The exception is caught and logged and I can click on a form button to run t...

How do you close TCP connections gracefully without exceptions?

What is the pattern and/or how would you change the following code so that a connection can be closed gracefully from either server or client, without needing exception handling. TcpClient vs. Socket: I'm not tied to using the TcpClient client class. I wrote the following code to try to demonstrate the simplest case possible. I had bee...

Automatic reference of class files inside App_Code vs reference of class files outside App_Code

Hi, all questions refer to Web site projects. 1) Why are file classes inside App_Code folder automatically referenced by the rest of application, while file classes created outside App_Code aren’t? 2) I don’t know much about compilation, but why do we need to explicitly reference class files created outside App_Code? Because those...

Parsing Size and Position Objects from an XmlDocument?

Is there more elegant syntax for reading/parsing Size and Point objects in an Xml document? Source Xml Nodes: <objSize>{Width=64, Height=64}</objSize> <Location_X>20</Location_X> <Location_Y>20</Location_Y> Currently I use: For Size: Dim sizeNode As String = objSize.InnerText Dim sizeText() As String = sizeNode.Split(CChar("="...

what are the limitations of wpf web browser control?

What are the limitations of WPF web browser control? Is it good enough for a real-life browser implementation? And is it a fully managed implementation? ...

.Net RegularExpressionValidator Help (empty or over 6 chars)?

I'm looking to accept values of (6 chars long or nothing). This is for an update form. If a password is entered, I'd like to force 6 chars long. If not, I want to ignore the field. Here's a REGEX that gets me the 6 char part, any help on handling empty also? <asp:RegularExpressionValidator id="rev1" runat="server" SetFocusOnError=...

.NET C# Socket Concurrency issues

An instance of System.Net.Sockets.Socket can be shared by 2 threads so one use the send() method and another it's receive() method ? Is it safe? Well, I need it to be not only thread-safe, but also that the send/receive methods be non-syncronized, so as to let each thread call them concurrently. Do I have another way of doing it ? T...

Trap error details if a sql connection fails

I am looking for a better means of error trapping my sql connections on connection.open, so that I may log the error better and determine where in my application it is faulting. I am using try catch and logging the exception caught but what I really want is to know which connection is failing. My application is iterating through 70 se...

Type Inference in Extension Method

I'm sure this has been asked before, but my perusal of the search hits for similar questions did not yield an answer. I am tired of checking if Nullable has a value. Why can't I assign myNullable<int> yourAge to int myAge and get an exception if yourAge is null? Furthermore, if either of our damned ages is null, why do I have to do a...

Converting C# knowledge to VB.NET any potential problems?

I have a team with people that are quite comfortable in C# but we got a requirement to write a project in VB.net. How hard would it be to think in C# and on the fly convert to VB? Is that doable? Could you list the issues that we can come across? I heard that VB.net doesn't have closures. Is that still true for .net 3.5? ...

How can I enforce a specific version of the .net framework

We were under the impression that setting the target framework on the properties of a solution would limit that app to using only that framework or below's functionality. We just found out though, that someone can add a reference and start using code from a higher versioned framework and the compiler won't complain one bit. Since we woul...

Implication of redundant code warning

When Visual Studio greys out some code and tells you it is redundant, does this mean the compiler will ignore this code or will it still compile this code? In other words, would this redundant code never be interpreted or will it be? Or does it simply act as a reminder that the code is simply not required? If I leave redundant code in m...

Vertical TextBlock filling verical space

I want to create a TextBlock (or some other element with text in it for display only) that is vertical (-90 transform angle), but I want that element to fill up the vertical space it is contained in, but have a defined horizontal amount (I'm using vertical and horizontal terms instead of height and width since it's swapped when I have th...

Porting VBA to VB.NET: function parameter is possibly multidimensional array

I am porting Excel VBA to VB.NET. I have a function that takes a selection of data, and it may be one dimensional or two. VBA code is quite fluid about using a variable as either a 1-D or 2-D array, but VB.NET marks it as an error. Here is the reduced code: Public Function Stat(ByVal Data As Range) As Object Dim Y() As Object D...

SAML library/component for .NET

Can anyone recommend libraries for generating SAML assertions for a federated sign-on implementation in .NET. It would be ideal if it was integrated with the ASP.NET membership API. ...

vs2005 c# .net 2.0: Short cuts templates for VS2005

I really like the following template to create properties for class in VS2005 Type Prop<tab><tab> and it gives template for writing class property. What are some of the other ones.. Is there a place where I can get list of them. ...

Which is faster: Union or Concat? (C# Linq)

I don't care about the order of the elements. http://msdn.microsoft.com/en-us/library/system.linq.enumerable.union.aspx http://msdn.microsoft.com/en-us/library/bb302894.aspx ...

Maintaining default visual properties with ControlTemplate

In order to apply a triggered animation to all ToolTips in my app, I'm using a ControlTemplate. However, when using a ControlTemplate the ToolTip loses all of its default visual properties as defined, I believe, by the theme. How can I retain all properties except for those that I override? Using the following code <ToolTip Opacity="...

Delay loading expensive fields in Entity Framework v.1

After hunting around the net, and thinking I'd come up with the solution, I seem to have hit another brick wall. I have a table in my database: Photos; containing columns for PhotoID, Caption, Ordering, and four sets of binary data: Original, Large, Medium and Small (yes, it was based on the old ASP.NET starter kit with various fixes, e...