.net

MVP Pattern, n-tier application architecture in .NET

Hello fellow SO-ers. I'm at the beginning of my road concerning Programming and Software Development and Design. I want to develop some applications in .NET(C#) WinForms with a SQL server as back-end (haven't decided yet: PostgreSQL, MSSQL or other). What I want to ask is where do I get information on: How do i structure my SQL tables...

Why does hiding an owned window switches app in WinForms (.NET)?

I have an application window which covers the screen and there are several minor tool windows which are hidden by default and their 'Owner' properties are set to this main window. When I show a tool window and click one of its buttons it hides itself to show another window. When I hide that another tool window Windows switches app just...

What's the best strategy for Equals and GetHashCode?

I'm working with a domain model and was thinking about the various ways that we have to implement this two methods in .NET. What is your preferred strategy? This is my current implementation: public override bool Equals(object obj) { var newObj = obj as MyClass; if (null != newObj) { return ...

Hosting the CLR: IHostAssemblyStore::ProvideAssembly causes exception " exception "The located assembly's manifest definition does not match the assembly reference"

Hi, PostSharp 2.0 includes a CLR host and implements IHostAssemblyStore::ProvideAssembly. From managed code, I invoke: Assembly.Load("logicnp.cryptolicensing, Version=3.0.0.0, Culture=neutral, PublicKeyToken=4a3c0a4c668b48b4") My implementation of IHostAssemblyStore::ProvideAssembly receives the following input for ...

Cancel Unloaded event in a WPF application

I implemented a WPF application which use NavigationService to navigate between pages. When I switch from a page to another one, the Unloaded event is raised for each graphical element that belongs to the former page. Is there a way to cancel that event without having access to the graphical elements but only to the container? ...

WCF: Using Streaming and Username/Password authentication at the same time

Hi, I have a WCF Service with the following requirements: a) The client requests a file from the server which is transferred as a Stream. Files may be 100MB or larger. I need streaming or chucking or whatever to make sure that IIS is not loading the whole package into memory before starting to send it. b) The client will transfer an I...

log4net save buffer from BufferedAppender

Hi, we are using log4net with a AdoNetAppender to write critical logs into an database. Since the AdoNetAppender is a subclass of the BufferedAppender there is a possibility to enable queuing of log events. What I'd like to do is to save the backup & restore the log buffer to a local file, so that no log entry can get lost it the databa...

Deleteing cache upon submit

I have an asp.net web form (c#, .NET framework 3.5) that returns to itself after the user clicks the submit button. I think that some values of the form are cached (some controls in a "placeholder" are out of position... meaning they have moved slightly up or down on the web form). How can I delete the cache after user clicks submit, an...

Is it possible to programatically recurse up a stack trace to a particular calling assembly?

Hi folks, i'm wondering if it is possible to programattically recurse up a stack trace to a particular assembly. I'm using StructureMap and it creates an instance of a particular class, to inject into another class. kewl. When i'm in the constructor of the injected class, i wish to see what was the parent class and the stack trace more...

Finding a Position on a 2D Map that meets several criteria

Hi, as my personal project i develop a game to which users can join at any time. I have a tiled worldmap that is created from a simple Bitmap which has resources at random positions all over the map except for oceans. When a player joins i want to create his starting position at a place that has at least 1 tile of each of the 4 resource...

How to prevent Mono from stretching the windows in a WinForms application vertically (on linux)?

The title is quite descriptive I think. My Winforms applications are running on Mono but there is an annoying problem: all my windows in the application are stretched vertically about 1.5 times. So my square shaped buttons and windows become rectangles. Only the sizes are scretched font sizes are not. So there are big gaps in the layout....

Chaining Observable Subscriptions

Is there a shorthand version of this. I want to call one sequence and then when it is finished call another. var seq1 = Observable.Range(1, 20); var seq2 = Observable.Range(21, 20); seq1.Subscribe( i => Console.WriteLine(i), () => seq2.Subscribe(i => Console.WriteLine(i))); ...

What would be the best way to implement change tracking on an object

I have a class which contains 5 properties. If any value is assingned to any of these fields, an another value (for example IsDIrty) would change tu true. public class Class1 { bool IsDIrty {get;set;} string Prop1 {get;set;} string Prop2 {get;set;} string Prop3 {get;set;} string Prop4 {get;set;} string Prop5 {g...

loading html page as xml

I use this to load html page by xml Dim xmlDoc As New XmlDocument() xmlDoc.Load(Server.MapPath("index.htm")) Or Dim xmldoc As XDocument xmldoc = XDocument.Load(Server.MapPath("index.htm")) but i got some errors like : Expecting an internal subset or the end of the DOCTYPE declaration. Line 2, position 14. '>' is an unexpected to...

Web Site -> Web Application conversion: Can I automate adding the references?

In my company, we've been converting .net "Web Sites" to "Web Applications". I have become the go-to person for this task. In order to accomplish this, I create a new project, copy all the files from the "Web Site" and include them in the project, and run the "Convert To Web Application" tool to create the "design" files. This is tota...

Split sorted collection of numbers by interuption in sequence

How to split a sorted collection of numbers by interruption in sequence ? eg.: List<int> someList = new List<int>{1,2,3,7,8,9} output : someDictionary[0].Key == 1; someDictionary[0].Value == 3; someDictionary[1].Key == 7; someDictionary[1].Value == 9; ...

C# TransactionScope - L2E

Is it worth using System.Transactions.TransactionScope on Linq to Entities? On the MS documentation, it says that SQL calls within ObjectContext.SaveChanges() are all rolled into one transaction internally. We have 1 database connection, that is a local SQLite database on the file system. We just want to make sure all our operations t...

SagePay integration from Windows Forms

I’ve been asked to integrate a windows form application with SagePay to take payments directly from the application. The SagePay documentation talks about ASP.NET so I’m not sure whether this is possible. Has anyone integrated a WinForm application with SagePay before? Is it possible? ...

Why does C# use implicit void Main?

I don't understand why C#'s Main function is void by default (in a console project for example). In C and C++ the standard clearly says main must return int, and using a return value makes sense because we can check that return value from an external program and see if the C/C++ application finished successfully or encountered an error. ...

Can StringBuilder replace one instance?

I've got a chunk of text in a StringBuilder object. I need to replace one substring with another. The StringBuilder Replace method can do this, but it replaces every instance of the substring and I only want to replace the first found instance. Is there a way to tell StringBuilder to only do one replace? I'm sure I could code this up my...