.net

How to get folder path for ClickOnce application

I need to write a file in the same folder where a console ClickOnce .application (executable file) resides. The folder where it launches from. I tried using Application.StartupPath & Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) but the path is pointing to a subfolder under c:\Documents & Settings. How do I get the pat...

Is there a free implementation of printf for .net?

The problems: I can't use string.Format, I have C style format strings; I can't call the native printf (no P/Invoke); I can't use http://www.codeproject.com/KB/printing/PrintfImplementationinCS.aspx because of the license, I need something GPL-compatible. Is there a free implementation of printf/sprintf for the .net framework? Other ...

DataGridView throwing "InvalidOperationException: Operation is not valid..." when adding a row

I want an OpenFileDialog to come up when a user clicks on a cell, then display the result in the cell. It all works, except that the DataGridView displays an extra row, for adding values to the list it's bound to. The row shows up if dataGridView.AllowUserToAddNewRows == true, which is what I want. What I don't want is for the applica...

ASP.NET Client Id's not being generated for loaded control

I have a UserControl ('AddressInfoGroup') within an updatepanel that dynamically loads user controls ('AddressInfo') via the loadControl method. I have two other such controls on the same page, both of which function correctly. When the AddressInfoGroup control renders an AddressInfo control to the page, the text boxes in AddressInfo h...

Access the value returned by a function in a finally block

I'd like to know if it is possible to get the return value of a function inside a finally block. I have some code that is like this. try { return 1; } finally { //Get the value 1 } I know it's possible by adding a variable that can hold the returned value. But I was wondering if it was possible to get the value in any way. T...

Why is performance on a webpage so different between IE and a WebClient? (TREEVIEW!!!)

I've seen some similar posts, but nothing quite like this... I have a website (Sharepoint). When I access a particular page that has many custom-coded webparts on it, the page takes ~30 seconds to load. I've used Firebug and confirmed that the long load time is the server working (in the "Net" tab the webpage timeline shows ~30 seconds ...

Anyone know of a class that implements ISelectionService and/or IComponentChangeService

In creating my own custom ParentControlDesigner, my public override void Initialize( IComponent component ) processes these interfaces for working with the designer window ISelectionService service = (ISelectionService)this.GetService( typeof( ISelectionService ) ); if ( service != null ) service.SelectionChanged += new EventHan...

Is it bad to not use a DB but use in memory objects?

I've been tasked to write a small app to be used by a single user. This app will pull in ~500 employee names/departments from our master employee DB. Then the user will enter like 5 fields for each employee. Those 5 fields will typically only change once a year, but could be once a month worst case. I only am supposed to keep track of 2 ...

Starting multiple gui (WinForms) threads so they can work separetly from one main gui in C#?

I've one MainForm window and from that user can press 3 buttons. Each of the button starts new Form in which user can do anything he likes (like time consuming database calls etc). So i decided to put each of the forms in it's own threads: private Thread subThreadForRaportyKlienta; private Thread subThreadForGeneratorPrzelewow; ...

How to connect signals into complex circuits in .NET?

For some concurrent code, I want to connect a bunch of signals together like a circuit. In .NET we can do a WaitAll or WaitAny on a collection of signals. I want to do something like this: WaitAny ( WaitAll (c1, c2), WaitAll (c3, c4) ) ; Unfortunately, the library doesn't support composing these operations into more complex trees. My ...

Form not showing after Invalidate()

For some reason, this code does not actually draw my bitmap file... or show the form. namespace GraphicsEngine { public partial class Form1 : Form { Bitmap[] dude = new Bitmap[3]; Bitmap dude0 = new Bitmap(@"C:\Directory.bmp"); Point renderpoint = new Point(1, 1); public Form1() { dude[0] = new Bitmap(@"C:...

What does Socket.ReceiveMessageFrom()'s endpoint parameter?

I am writing a proxy application for iSCSI to do some diagnostic work (think Fiddler for iSCSI) - I'm trying to capture data one packet at a time, I don't want to read arbitrary sizes and end up getting all of one iSCSI packet and half of another - I really want to see the same kind of data as Wireshark would display for example. In doin...

ADO.net entity framework - Custom code

I am investigating some OR/M's and have been unable to find an answer to this question. I am currently looking at Microsoft's ADO .net entity framework. Can I override (or use partial classes) to insert custom code into the entities that are created from the database? It appears that the entities are generated using Xml (not my favour...

Windows Service Webbrowser object invalid cast exception error

Hi all, I'm having a bit of trouble with a Windows Service webbrowser object. It's attempting to load in values of username and password to a site but keeps failing and throwing the following error: System.InvalidCastException: Specified cast is not valid. at System.Windows.Forms.UnsafeNativeMethods.IHTMLDocument2.GetLocation() a...

Configuration file 'C:\my\App.Config' is being used to configure all executables

I have a Visual Studio setup project that installs an application into the task scheduler and also installs a GUI application to manage some configuration parameters in the registry. This being the case, the setup project installs two different primary outputs (.exe's) as part of the process. I am getting the following warning when I r...

How to fix flicker in a WinForms form?

I am constantly drawing frames, and I need the form to not flicker. How do I accomplish this? namespace GraphicsEngine { public partial class Form1 : Form { Image[] dude = new Image[3]; static int renderpoint = 0; int lastimage = 0; public Form1() { dude[1] = new Bitmap(@"C:\Documents and Settings\Boys\...

Digit Grouping in .NET

How do we input digit grouping in C#? My code works but only for one instance. I have to constantly click it to group every number in the calculator. How do we do group it so that if we click it, it groups every number (not only the number presented), and if we uncheck the checkbox, it doesn't? This is the current code: NumberFormatInf...

Sending content as it's loads in .Net

I'm creating a simple ajax call to retrieve a list of user reviews. I want to have my aspx page output the content for each review item as it is processed. For example, lets say I had 100 reviews to show, how would I send the markup as it processes on the server end? In PHP I can do this with the flush() or ob_flush() function. What is t...

What is the cleanest way to define this generic interface so it compiles?

Since, two methods with the same parameters but different return values will not compile. What is the best way to define this interface without loosing clarity? public interface IDuplexChannel<T, U> { void Send(T value, int timeout = -1); void Send(U value, int timeout = -1); bool TrySend(T value, int timeout = -1); ...

[Dependency walker] Some terminologies to clarify

Hi guys: What delay-load dependencies\functions are meant for in the following document? http://www.dependencywalker.com/faq.html Thanks ...