.net

What's the best practice for getting a random date-time between two date-times?

Hi folks, I'm trying to randomize the value for a simple DateTime datafield. I wish to get a random date/time between two date/times (e.g. min date/time and max date/time). So lets imagine I'm after a random date/time between 1/1/2000 10am and 1/1/2000 5pm. Also, this code will be used in a for loop, with 100 items .. meaning all 10...

How do I play a mp3 using c# ... with no 3rd dll

/want to put a musical easter egg into my app The SoundPlayer code below seems to only like mp3s :-( Stream stream = new MemoryStream(Properties.Resources.MyMp3, false); using (SoundPlayer player = new SoundPlayer(stream)) { player.PlaySync(); } Thanks ...

Is this mbunit test really doing anything significant?

[Test] public void TestUserProfileInsert() { using (new TestBindingsWrapper("TestBindings", "", new TestModule())) { // Setup the mock the dataprovider MyMocks.MockDataProvider.Setup(x => x.InsertUserProfile(It.IsAny<IUserProfile>())).Returns(1); IUserProfile up = new UserProfile(); IUserProfileManager manager =...

ADO.Net DataReader timeout issue

Hello everyone, I am using ADO.Net + C# + VSTS 2008 + ADO.Net to connect to SQL Server 2008 Enterprise. I am using almost the same pattern/sample mentioned here -- using ADO.Net DataReader to retrieve data one entry (row) by one entry (row). http://msdn.microsoft.com/en-us/library/haa3afyz.aspx My question is, if I set the SqlCommand ...

NT SQL Connecting

how can i connect win nt sqlexpress? i am using this code to connect.it works with any version and kind of sql. internal string GetConnectionString() { return "Data Source=" + "MyPC\SQLExpress" + ";Initial Catalog=Master;User ID=" + username + ";Password=" + password; } when connectiong with expr...

Fluent NHibernate Default Conventions

I'm trying to find a resource that shows what default conventions Fluent NHibernate uses with no custom (user) conventions applied. Thanks! ...

Interacting with a form without it activating

Hello. I'm trying to implement code-completion popup window in my project. The window is derived from Form. It contains two controls: custom list derived from UserControl (it shows completion possibilities with icons) and a VScrollBar. When the popup appears, it doesn't steal focus from the editor (form's ShowWithoutActivation is overri...

I managed to break DebuggerNonUserCodeAttribute, anyone experienced this?

Look at the following program. The comments show the order of execution when I use Visual Studio 2008, and start, and step through the program only hitting the F11 (Step Into) debugging hotkey. The first column is what I actually experience now, the second column is what I expected to happen. Note that the method in the class marked wi...

How should I refactor a long chain of try-and-catch-wrapped speculative casting operations

I have some C# code that walks XML schemata using the Xml.Schema classes from the .NET framework. The various simple type restrictions are abstracted in the framework as a whole bunch of classes derived from Xml.Schema.XmlSchemaFacet. Unless there is something I've missed, the only way to know which of the derived facet types a given fac...

What is the advantage of using a DataRelation?

I'd like to know what the advantage of using a DataRelation in .NET is, as opposed to crafting the relationship in the data layer itself? Or is this largely a decision by the developer about which tier to place their logic in? ...

Using structs in C# for simple domain values

I am writing a financial application where the concept of 'Price' is used a lot. It's currently represented by the C# decimal type. I would like to make it more explicit and be able to change it to maybe double in the future, so I was thinking of creating a 'Price' struct that would basically act exactly the same as the decimal type (may...

Why doesn't System.Windows.Forms.Clipboard.GetData/SetData work?

I'm trying to add copy/paste to an application that edits items. Having a copy of the data for a set of selected items, should enable duplicating them or transporting them to another instance of the program. I've tried this: const string MyClipboardFormat = "MyClipboardFormat" private void copyToolStripMenuItem_Click(object sender, Eve...

Does one need to manually create a Windows event log source when installing a Windows service.

I have developed a Windows service in C#. I have created a installer with Visual Studio 2008, which installs the Windows service. Everything is good so far. I want to make sure that the event source has been created at install time, so that any error/exception conditions at runtime are correctly logged to the Windows event log. Does the...

Question about an application not getting focus in XP/W2K3

I have an application written in .NET. The previous version had no problems: you double-click on the icon or run it from a command line and when it starts up, it's the main window and has focus as you'd expect. The latest version displays a splash screen before the main window and now the splash screen comes to the foreground ok but th...

How do I start using Crystal Reports?

I need a link for some good tutorials about crystal report using C# If there was also a free ebook or other resources that would also be great. ...

Experiences of Mono web development in OSX

Hey guys I'm a .NET web developer and just bought a new Mac. I'm interested in developing, and debugging .NET in OSX, but I'm not interested in deploying to OSX. Although, in the future, I will be interested in deploying to Linux. What are your experiences with Mono web development in OSX? In particular, how does it compare in terms ...

.NET Web Services without ASP.NET/IIS?

I'm implementing a server component that needs to expose a web-service interface, but there is no application need for it to run with ASP.NET on IIS. Is there a straightforward way to implement Web Services in .NET without ASP.NET/IIS? (I'm using .NET 3.5 / C# 3.0) ...

Would you trust mono as a platform to build an startup?

I got "The question you're asking appears subjective and is likely to be closed." but you can answer YES or NO. -- edit: Subjective questions are those typically answered with an opinion, so what's so bad about asking the opinion of the community? Also BTW, I'm asking for your opinion, your opinion doesn't depend on the nature of my pro...

How to make a windows form to come front in windows application done in c# ?

I have done a global mouse event in my windows application. When i click the center button of my mouse, i want to make a particular form topmost... There are some applications which runs in the full screen mode, so i need to do this, in order to make my form visible to the users, because this is the only way to view it. Since Alt + Tab...

NHibernate Proxy Validator changes in 2.1

Can someone please help me understand the following: In the previous version of NHibernate (2.0.1) the following property will validate and is compatible with the Castle Proxies: internal virtual BusinessObject Parent { get { /*code*/ } } However, in 2.1 it errors saying that the types should be 'public/protected virtual' or 'prote...