.net

How to draw selected text

I am writing a custom replacement for the Textbox/Label controls. It needs to provide similar functionality but will be optimized and (hopefully) much quicker in the context of my application. It needs to be able to support multi-line text selection. I'm wondering if there is a simple way to draw selected text? Right now it looks like th...

How can I cast an Interface as it's type in c#?

Hello Everyone, I have a property that returns an interface. During debugging I can break on what was returned and while it is the interface, Visual Studio is smart enough to know the derived type that it actually is. I assume it's using reflection or something. I'm not sure. My question is, can I have that same info avaialble to me at r...

Blocking TCP socket write then immediatelly close - is it a problem?

I have a sender that TCP-connects, sends block of data, and closes the socket. I'd like to write the simplest, but reliable program that does the above. The first thing comes into mind (e.g. in .NET, although the question relevant to sockets in general): // assuming LingerOption(false), NoDelay set to whatever var client = new TcpClient...

Need help creating control to display data

I am writing a .NET WinForms application that needs to display a list of results in a nice formatted user-friendly fashion. Here's how I'm hoping to display the data. The table must support a decent amount of data(>= 200 individual "data blocks"), and needs to be fairly fast. I'm unsure of the easiest way to accomplish this and I was ...

.NET - ORMs and all possible combinations - ViewModel?

How would you approach this problem with an ORM? This is a hypothetical (simplified) example: I have a table of cities: 1 - New York 2 - London 3 - San Francisco 4 - New Orleans I have a table of scores: (first column Unique Primary Key, second Month Code, third FK to City, fourth Score (int)) 1 - 352 - 1 - 9 2 - 352 - 2 - 10 Fo...

Should I unit test event handlers

I tend to veer towards the opinion that only public interfaces should be tested, thereby covering testing of private procedures. However, an interesting question arose yesterday - should one test event handlers? My gut instinct is that logic should be stored in self-contained procedures invoked by the handlers themselves, but this is sub...

Why does adding StructLayout attribute to a WCF MessageContract cause the type to not load?

I'm running into an issue adding a StructLayout attribute to a MessageContract class, for example: [MessageContract(...)] [StructLayout(LayoutKind.Sequential)] public class Foo { ... } This causes a nasty error when trying to generate the WSDL from WCF: Could not load type 'Test.Foo' from assembly 'Test, Version=1.0.0.0, Culture=n...

Pass collections of data to PL/SQL Package Procedure or Function from .NET?

I have a table that I need to insert a set of records into based on user input. IE: Selection from a list of items to choose from. For this example, let's just say it's a collection of int's. Not a lot of good examples on the internet. There's only one related question here on SO, but it lends no answers either (both answers are dead en...

How to insert a new line into a Sharepoint multiple line field?

I am inserting items into a Sharepoint list using C# and accessing the lists.asmx web service. One of the fields in the list is a multiple line text field (rich text), and I want to insert line breaks into the field. What characters do I put in the XML request to insert a line break? Thanks. ...

How to draw in C#/WinForms with decent speed?

I'm trying to visualise a graph and allow people to play with it. I found the excellent Graph# library that can create an initial layout so that part is covered. Now I need to make a control that actually draws it and provides the necessary interactivity. Graph# comes with a nice visualiser itself, however I don't like it because it is ...

Visible='<%# UserCanEdit %>' – if set to true inside Page_Load, then control isn't visible

hi User control defines a property named UserCanEdit: private bool _userCanEdit=false; public bool UserCanEdit { get { return _userCanEdit; } set { _userCanEdit = value; } } This User Control also contains the following GridView: <asp:GridView ID="GridView1" runat="server"> <Columns> <asp:TemplateF...

How do I handle null nested objects in RDLC report that is bound to custom assembly object datasource?

I have an RDLC report that I am rendering directly to the Response Stream as PDF (rather than using the ReportViewer). In the code that renders the report, it's DataSource is bound to a List(Of ClassA) objects defined in a custom assembly. This seems to work for the most part. My problem is that I can't seem to handle the situation wh...

opening an mdb access file without access

i dont have microsoft access but would like to open an mdb file, is there any way to do this? the mdb file contains SQL code that i need. it is just a file that connects to a remote database. i need to view the sql code i did try openoffice base, but it only showed me some tables. i dont see where the sql code is? ...

Picking a port for listening to a response/keeping socket open?

I've got a client app which has to connect to a server and register for waiting, that is, it wants to be notified when the server is done with some processing. Ideally, I want to keep this client as simple as possible, but the question is, how to "register for waiting". I could keep the socket open and do a blocking read, and as soon as ...

Reducing memory usage of .NET applications?

I was wondering if anyone had any tips to reduce the memory usage of .NET applications. Consider the following simple C# program: class Program { static void Main(string[] args) { Console.ReadLine(); } } Compiled in release mode for x64 and running outside visual studio, the task manager reports the following: Wor...

Environment.CurrentDirectory is yielding unexpected results when running installed app

Background: I built an installer for my app, and all my dll's and content files are getting correctly copied to the C:\Program Files\MyCompany\MyApp directory. When I run my app from Visual Studio, everything works great. When I run the installed version of my app, however, I get a DirectoryNotFoundException. The problem seems to be wit...

Using CallExternalMethodActivity/HandleExternalEventActivity in StateMachine

I'm attempting to make a StateMachine execute some database action between states. So I have a "starting" state that uses CallExternalMethodActivity to call a "BeginExecuteNonQuery" function on an class decorated with ExternalDataExchangeAttribute. After that it uses a SetStateActivity to change to an "ending" state. The "ending" state...

.Net patterns vs. GOF

Since the GOF book was put together well before .Net came into being, are there any specific patterns described in GOF that are not appropriate for .Net? And if so, for what reason? This is a question relating to a recent bounty discussion. ...

EntityFramework .net 4 Update entity with a simple method

I was looking at this SO question: http://stackoverflow.com/questions/1168215/ado-net-entity-framework-update-only-certian-properties-on-a-detached-entity. This was a big help for me. I know now that I need to attach an entity before making my changes to it. But how can do I do this: I have an MVC website, a Customer Update Page with fi...

Shared Interface and ReaderWriterLockSlim

I am using log4net in a class with multiple threads and I had a simple question. Do I need to enter readlock/writelock when checking properties and calling methods on the log4net.ILog interface? I am using the suggested method from the log4net examples so at the top of said class I have: Private Shared ReadOnly log As log4net.ILog = ...