.net

Stored IEnumerable dissapears on restart debug, but recreating IObjectServer and IObjectClient in one unit test is ok

I'm storing an IUser object in a Db4o database as follows (client is an IObjectClient): public Guid AddUser(IUser user) { lock (userLock) { user.Id = Guid.NewGuid(); client.Store(user); client.Commit(); } return user.Id; } The implementation of IUser that is used here has the field that is discr...

WPF WebBrowser: How I do access progress and new window events

I'm building an a WPF app that uses the WebBrowser control. I'm struggling on a couple of points: How to get the current progress of a download from the control. The WinForms WebBrowser control raises ProgressChange events - how can I relicate this feature with the WPF variant? How to capture links that are trying to open in a new w...

Beginning VSTO Development

I'm quite confused with what are the necessary tools for VSTO develpment. Specifically I want to manipulate Excel 2003/2007 documents programmatically. I did quite a lot of VBA before, if you want to relate any answer to that. Few questions I have about VSTO: Can I use Visual Studio 2008 Express Edition C#/C++ for this? Do I need to h...

HttpWebRequest.GetResponse() hangs the second time it is called

I'm trying to fetch a series of files via HTTP, using HttpWebRequest. The first request goes through fine, but the second time through the same code GetResponse() hangs and times out. WireShark shows that no HTTP traffic is being sent for the second request, so it would appear that it's an API problem. After some investigation, I've dis...

App crash when calling MessageBox

Hello i call up a MessageBox when validating some data, if the data is wrong I message the user with a MessageBox with following code: private void button1_Click(object sender, EventArgs e) { if (textBox_name.Text.Trim() != "" || textBox_X.Text.Trim() != "" || textBox_Y.Text.Trim() != "") { if (grap...

Merge cells in datagridview

Is there a way to merge cells in datagridview of .net in winforms .I would like to merge two or more cells of a row . ...

how to Close a Class to accept only specific Typed Object

Hello Friends, I have this Class which is accepting a Dictionary<string,object> which is been invoked from different places in the code. Dictionary concept is making things untyped and difficult to figure out what to pass the class to function otherwise it throws run-time exception. As this Dictionary<string,object> is a contract defini...

Convert enum from object to long without a try block?

Follow along in my test source. What is a good way to get a value from a enum object? Must support long. I am attempting without a try/catch block. enum ELong: long { a = 0x100000000 }; enum ENormal { a = 25 } var l = (object) ELong.a; var n = (object)ENormal.a; //will cast into the correct size int ii =...

Microsoft.Office.Interop.MSProject - why are my files always locked (by me!) when I try to open them?

Hi all, I'm trying to use Interop to manipulate MS Project 2003 (MPP) files. My problem is that MS Project reports that the files is already opened by another user (me!) and that I can open it only as read-only. Obviously, I've tried to restart studio, then windows (xp) but with no effect. The file attribute for Readonly is cleared on...

Data Binning with SQL or Linq

I am creating a custom reporting app in C# and need to aggregate some data. Let's make it simple. Say I have 10,000 sales for a year, I need a generic way to bin the data by say, month, day or hour. Each bin would therefore sum all the sales within that period. Has anyone ever written a query like this in either SQL or Linq? ...

Interprocess communication between C# and C++

I'm writing a bit for a game, which has a C++ API interface (ie. methods in a Cpp dll get called by the game when events occur, the dll can call back methods in the game to trigger actions). I don't really want to write my bot in C++, I'm a fairly experience C# programmer but I have no C++ experience at all. So, the obvious solution is ...

Dictionary value c#

A dictionary cannot be changed if we are looping over it in .Net. But why is the value in a dictionary read only. Any one has any ideas ?. Why .Net team decided on not changing the value when looping over dictionary. I can understand if the key cannot be changed but why value ?. Also if you are using LINQ and getting the keys back in fo...

How to find references to an object in C#

Given a collection with an object in it - I need a way to find out if this object is also member of some other collection. I.E in some sort of pseudo code object o; Collection<object> col1; col1.Add(o); Collection<object> col2; col2.Add(o); MagicWords.GetTheReferingCollectionsTo(o); Where GetTheReferingCollectionsTo should return ...

Controlling user workflow in Winforms

I'm building a Winforms application in C# and I have added a tab control that has three tabs. I want to restrict user's ability to access the second tab page until user fills out the first tab. I have a submit button the first tab, I want the second tab to be able to be accessed when the user clicks on the submit button. How can I ac...

Short method to retrieve NeutralResourcesLanguageAttribute searched

Is there a better (shorter) method to retrieve the NeutralResourcesLanguageAttribute of an assembly than using reflection as implemented below? Public Function GetNeutralResourcesLanguage() As String Dim assembly = System.Reflection.Assembly.GetExecutingAssembly Dim attributes = assembly.GetCustomAttributes(GetType(System.Resour...

Intelligent file copy algorithm (os independent)

Hi, I'm trying to create, a fast and somewhat intelligent file copy algorithm (in c# but platform independent). My goals: I don't want to use any platform specific code (no pinvokes or anything) I'd like to take advantage of multiple cores but this seems stupid since doing simultaneous reads/writes would seem slower right? (correct ...

ASP.NET Site Templates

Are there any good ASP.NET site templates out there? I am looking for something with some very basic features: Reusable layout Navigation already built in Admin Section Login Page I was going to build a template that meets my needs exactly, but thought I would scour around a bit first. If I don't find something that does what I ne...

analyze SQL Server performance issue?

Hello everyone, I am developing using VSTS 2008 + C# + .Net 3.5 + ASP.Net + SQL Server 2008 Express. I am working on 32-bit platform with Windows Server 2003. The issue I find is simple SQL statement like select/create a simple table is very small from SQL Server Management Studio. BTW: I think it should be machine specific issue since...

Isn't 'int GetHashCode' a bit short-sighted?

Given that .Net has the ability to detect bitness via IntPtr (looking through reflector a good amount of it is marked unsafe, though - shame) I've been thinking that GetHashCode returning an int is potentially short-sighted. I know that ultimately with a good hashing algorithm the billions of permutations offered by Int32 are absolutely...

Is there a WebSocket client implemented for .NET?

I would like to use WebSockets in my Windows Forms or WPF-application. Is there a .NET-control that is supporting WebSockets implemented yet? Or is there any open source project started about it? An open source solution for a Java Client supporting WebSockets could also help me. ...