Daily Archives

Articles indexed Thursday April 1 2010

Page 17/126 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • VS2008: File creation fails randomly in unit testing?

    - by Tim
    I'm working on implementing a reasonably simple XML serializer/deserializer (log file parser) application in C# .NET with VS 2008. I have about 50 unit tests right now for various parts of the code (mostly for the various serialization operations), and some of them seem to be failing mostly at random when they deal with file I/O. The way the tests are structured is that in the test setup method, I create a new empty file at a certain predetermined location, and close the stream I get back. Then I run some basic tests on the file (varying by what exactly is under test). In the cleanup method, I delete the file again. A large portion (usually 30 or more, though the number varies run to run) of my unit tests will fail at the initialize method, claiming they can't access the file I'm trying to create. I can't pin down the exact reason, since a test that will work one run fails the next; they all succeed when run individually. What's the problem here? Why can't I access this file across multiple unit tests? Relevant methods for a unit test that will fail some of the time: [TestInitialize()] public void LogFileTestInitialize() { this.testFolder = System.Environment.GetFolderPath( System.Environment.SpecialFolder.LocalApplicationData ); this.testPath = this.testFolder + "\\empty.lfp"; System.IO.File.Create(this.testPath); } [TestMethod()] public void LogFileConstructorTest() { string filePath = this.testPath; LogFile target = new LogFile(filePath); Assert.AreNotEqual(null, target); Assert.AreEqual(this.testPath, target.filePath); Assert.AreEqual("empty.lfp", target.fileName); Assert.AreEqual(this.testFolder + "\\empty.lfp.lfpdat", target.metaPath); } [TestCleanup()] public void LogFileTestCleanup() { System.IO.File.Delete(this.testPath); } And the LogFile() constructor: public LogFile(String filePath) { this.entries = new List<Entry>(); this.filePath = filePath; this.metaPath = filePath + ".lfpdat"; this.fileName = filePath.Substring(filePath.LastIndexOf("\\") + 1); } The precise error message: Initialization method LogFileParserTester.LogFileTest.LogFileTestInitialize threw exception. System.IO.IOException: System.IO.IOException: The process cannot access the file 'C:\Users\<user>\AppData\Local\empty.lfp' because it is being used by another process..

    Read the article

  • How should I handle this Optimistic Concurrency error in this Entity Framework code, I have?

    - by Pure.Krome
    Hi folks, I have the following pseduo code in some Repository Pattern project that uses EF4. public void Delete(int someId) { // 1. Load the entity for that Id. If there is none, then null. // 2. If entity != null, then DeleteObject(..); } Pretty simple but I'm getting a run-time error:- ConcurrencyException: Store, Update, Insert or Delete statement affected an unexpected number of rows (0). Now, this is what is happening :- Two instances of EF4 are running inthe app at the same time. Instance A calls delete. Instance B calls delete a nano second later. Instance A loads the entity. Instance B also loads the entity. Instance A now deletes that entity - cool bananas. Instance B tries to delete the entity, but it's already gone. As such, the no-count or what not is 0, when it expected 1 .. or something like that. Basically, it figured out that the item it is suppose to delete, didn't delete (because it happened a split sec ago). I'm not sure if this is like a race-condition or something. Anyways, is there any tricks I can do here so the 2nd call doesn't crash? I could make it into a stored procedure.. but I'm hoping to avoid that right now. Any ideas? I'm wondering If it's possible to lock that row (and that row only) when the select is called ... forcing Instance B to wait until the row lock has been relased. By that time, the row is deleted, so when Instance B does it's select, the data is not there .. so it will never delete.

    Read the article

  • Tips for transitioning from Visual Basic to Xcode

    - by Cyclone
    I've been programming in VB.net for a while now, and I finally got access to a mac to make ipod apps. What are some useful sites, videos, etc. that could help me get used to Objective C and the Xcode IDE? I've stumbled upon the samples on the apple dev site, but none of them really give good examples which I could learn the syntax of the language from. Thanks for the help, Objective C is really a big change from VB.net!

    Read the article

  • Laplacian of Gaussian

    - by Don
    I am having trouble implementing a LoG kernel. I am trying to implement 9x9 kernal with theta = 1.4 as shown in this link http://homepages.inf.ed.ac.uk/rbf/HIPR2/log.htm. However, I am having difficulty with the formula itself.For whatever values I input into the formula, I don't get any of the values in a 9x9 LoG kernel with theta = 1. 4. If someone can provide an example of how they got one of the big values ie -40 or -23, or the code to implement it, It'd be greatly appreciated. Thank you

    Read the article

  • Can I create an ASP.NET MVC 2 project with multiple areas without referencing each Child in the pare

    - by No Refunds No Returns
    This is a follow-up question to my original query: http://stackoverflow.com/questions/1791605/how-can-i-use-multiple-projects-to-separate-a-large-asp-net-mvc-site-into-departm Now that I have this working, is there a way to still have multiple project but not have to reference each child area from the parent project? Ideally I'd like to be able to have multiple, separate and distinct projects that only come together on the production/test machines. I should be able to build and test each "area" separately.

    Read the article

  • Oracle: error while trying to use formulas

    - by Yazeed
    I created an element with an input value of type "Day" , when i write a formula i get this error. Any idea what's wrong? APP-FF-33232: EATC_EXTRA_DAYS_ENTRY_EFFECTIVE_DATE_ENTRY_VALUE has null or not found allowed, but no default set specified. Cause: If a Database Item has null allowed, or not found allowed, then the item must also specify a default set to be used to provide default values in the event of these occurring. The item named has one of these conditions allowed, but the default set column in the FF_DATABASE_ITEMS table is null. Action: Please refer to your local support representative. -

    Read the article

  • Bazaar + CruiseControl.Net

    - by Chris Gill
    I want to setup CruiseControl.Net at my company. We currently have several .net solutions stored in a Bazaar repository and I want to use MSBuild to build each solution. This didn't seem too controversial, but I can't see an easy way of binding CruiseControl.Net to Bazaar. There seems to have been a plugin to do this at http://www.sorn.net/projects/bazaar-ccnet but this link no longer works and I cant seem to find the plugin anywhere else I was going to use the External source control type, but bazaar seems to bork at the GETMODS parameter being passed to it My current thought now is to create a separate project to pull modifications from bazaar using an Exec task, then create another project to run a FileSystem source control check on that directory. I'm moderately sure I can get this to work, but it seems a bit hacky. I don't mind writing a new Bazaar plugin for CruiseControl.Net but I cant find where to start with this. My questions are do you run these two in combination, if so how do you do it? If you don't run these together, do you have any recommendations on a good approach? Is there any documentation or good starting point that I could use to write a bazaar plugin? Am I an idiot for trying to use CruiseControl.Net? Should I be using something else?

    Read the article

  • Get correct output from UTF-8 stored in VarChar using Entity Framework or Linq2SQL?

    - by jasonpenny
    Borland StarTeam seems to store its data as UTF-8 encoded data in VarChar fields. I have an ASP.NET MVC site that returns some custom HTML reports using the StarTeam database, and I would like to find a better solution for getting the correct data, for a rewrite with MVC2. I tried a few things with Encoding GetBytes and GetString, but I couldn't get it to work (we use mostly Delphi at work); then I figured out a T-SQL function to return a NVarChar from UTF-8 stored in a VarChar, and created new SQL views which return the data as NVarChar, but it's slow. The actual problem appears like this: “description†instead of “description”, in both SSMS and in a webpage when using Linq2SQL Is there a way to get the proper data out of these fields using Entity Framework or Linq2SQL?

    Read the article

  • Creating transparent background in WPF

    - by Vinjamuri
    I have a button with a backgroun image of color white. My button is sitting on the toolbar which has a bacground color of Blue. When the button is sitting on the toolbar, the button looks white, however I want it to look like blue as the the background color of toolbar is Blue. How should I achieve this in WPF.. Please let me know.

    Read the article

  • How much power supply does a typical PC build need?

    - by Wesley
    I am building a system for a friend. The potential specs are like this so far: ASUS A8N-VM motherboard AMD Athlon 64 3200+ @ 2.0 GHz Any 7200RPM SATA HDD Palit GeForce 8800GT 512MB GDDR3 PCIe One DVD/CD combo drive Creative SB Live! 5.1 sound card I was wondering what wattage of power supply would be able to support this hardware. I had a 350W in mind... would that do?

    Read the article

  • UINavigationController (drawRect:)

    - by ludo
    Hi, I created an application with a TabBarController, 4 TabBarItems and every TabBarItem have is own NavigationController file (everything created in IB). I'm using the drawRect function to design my navigationBar: @implementation UINavigationBar (customImage) -(void)drawRect:(CGRect)rect { UIImage *image = [UIImage imageNamed:@"MyImage.png"]; [image drawInRect:CGRectMake(0,0, self.frame.size.width,self.frame.size.height)]; } @end The problem is that the NavigationBar change for every ViewController inside my app, what I want is only draw the NavigationBar for one TabBarItem only and use the default navigationBar for other controller. How to do that? Thanks,

    Read the article

  • How do people manage changes to common library files stored across mutiple (Mercurial) repositories?

    - by mckoss
    This is perhaps not a question unique to Mercurial, but that's the SCM that I've been using most lately. I work on multiple projects and tend to copy source code for libraries or utilities from a previous project to get a leg up on starting a new project. The problem comes in when I want to merge all the changes I made in my latest project, back into a "master" copy of those shared library files. Since the files stored in disjoint repositories will have distinct version histories, Mercurial won't be able to perform an intelligent merge if I just copy the files back to the master repo (or even between two independent projects). I'm looking for an easy way to preserve the change history so I can merge library files back to the master with a minimum of external record keeping (which is one of the reasons I'm using SVN less as merges require remembering when copies were made across branches). Perhaps I need to do a bit more up-front organization of my repository to prepare for a future merge back to a common master.

    Read the article

  • Document Based Application, preinitialize window (enter serial, buy, trial)

    - by Remizorrr
    I need to create several windows before NSDocument is loaded, or create a window that blocks NSDocument window and top menu. I tried several solutions - but they didn't work right. modal window, one after another. there were some problems with Async URLConnection, and some other problems with my NSDocument content. I created custom MainMenu.xib with no menu, that opens my preinitialize windows. here i found some other problems, when a file(associated with my application) is opened - the Document Window initializes. Here i tried to subclass NSDocumentController, but i found no way to pause the "open document". (i want the document to be opened anyway, but only after the preinitalize windows would be closed). So what is the right way to do this?

    Read the article

  • Formatting address of different types

    - by mickyjtwin
    I have various classes which all contain address details, i.e. AddressLine1, AddressLine2, AddressLine3, Suburb, Town, etc. On the front end, I need to format the address in a particular way, i.e. AddressLine1<br /> AddressLine2<br /> Suburb State Postcode If AddressLine2 does not exist or empty, don't show it. Quite straight-forward. I am trying to determine the best way to show this info. At the moment, the Address property of each class calls a FormatAddress method which writes out the html string. This exists as a method of the class. My opinion is that any formatting should exist from the front-end control i.e. ascx etc. However, if these DetailClasses need to format the same address info, what would be the best option, also making it easier to maintain?

    Read the article

  • Polling duplex does not scale... what's the alternative?

    - by user80855
    Our tests showed that the polling duplex binding simply does not scale and can not be used on a service within a web-farm or even a web garden. We have looked at TCP/IP sockets for a client push method, but the firewall issue is does allow us to use sockets. I was wondering what is the alternative "free" solution to this problem? allowing us to scale and allowing us to push data to client... I have also tried the solution in this article http://tomasz.janczuk.org/2009/09/scale-out-of-silverlight-http-polling.html but at the end, there was too much polling on a database, and performance was affected. Our Silverlight application need a pub/sub design, but it needs to be reliable and scalable... any ideas?

    Read the article

  • C# string equality operator returns false, but I'm pretty sure it should be true... What?!

    - by Daniel Schaffer
    I'm trying to write a unit test for a piece of code that generates a large amount of text. I've run into an issue where the "expected" and "actual" strings appear to be equal, but Assert.AreEqual throws, and both the equality operator and Equals() return false. The result of GetHashCode() is different for both values as well. However, putting both strings into text files and comparing with DiffMerge tells me they're the same. Additionally, using Encoding.ASCII.GetBytes() on both values and then using SequenceEquals to compare the resulting byte arrays returns true. The values are 34KB each, so I'll hold off putting them here for now. Any ideas? I'm completely stumped.

    Read the article

  • .NET immutable object usage best practices? Should I be using them as much as possible?

    - by Daniel
    Say I have a simple object such as class Something { public int SomeInt { get; set; } } I have read that using immutable objects are faster and a better means of using business objects? If this is so, should i strive to make all my objects as such: class ImmutableSomething { public int SomeInt { get { return m_someInt; } } private int m_someInt = 0; public void ChangeSomeInt(int newValue) { m_someInt = newvalue; } } What do you reckon?

    Read the article

  • An error has occurred opening extern DTD (w3.org, xhtml1-transitional.dtd). 503 Server Unavailable

    - by Cheeso
    I'm trying to do xpath queries over an xhtml document. The document looks like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> .... </head> <body> ... </body> </html> Because the document includes various char entities (&nbsp; and so on), I need to use the DTD, in order to load it with an XmlReader. So my code looks like this: var reader = XmlReader.Create(sr, new XmlReaderSettings { ProhibitDtd = false }); But when I run this, it returns An error has occurred while opening external DTD 'http://www.w3.org/TR/xhtml1-transitional.dtd': The remote server returned an error: (503) Server Unavailable. Now, I know why I am getting the 503 error. W3C explained it very clearly. But I still want to validate the document. How can I validate with the DTD, and get the entity definitions, without hitting the w3.org website? related: - java.io.IOException: Server returned HTTP response code: 503

    Read the article

  • Performance penalty of typecasting and boxing/unboxing types in C# when storing generic values

    - by kitsune
    I have a set-up similar to WPF's DependencyProperty and DependencyObject system. My properties however are generic. A BucketProperty has a static GlobalIndex (defined in BucketPropertyBase) which tracks all BucketProperties. A Bucket can have many BucketProperties of any type. A Bucket saves and gets the actual values of these BucketProperties... now my question is, how to deal with the storage of these values, and what is the penalty of using a typecasting when retrieving them? I currently use an array of BucketEntries that save the property values as simple objects. Is there any better way of saving and returning these values? Beneath is a simpliefied version: public class BucketProperty<T> : BucketPropertyBase { } public class Bucket { private BucketEntry[] _bucketEntries; public void SaveValue<T>(BucketProperty<T> property, T value) { SaveBucketEntry(property.GlobalIndex, value) } public T GetValue<T>(BucketProperty<T> property) { return (T)FindBucketEntry(property.GlobalIndex).Value; } } public class BucketEntry { private object _value; private uint _index; public BucketEntry(uint globalIndex, object value) { ... } }

    Read the article

  • What Visual Studio add-ins do you use for C++ refactoring?

    - by Minyu
    I have just started using Visual Assist X for C++ refactoring in Visual Studio 2008. It is quite good, but IMO, not to the same level as what ReSharper has for C#. I am wondering what people are using for C++ refactoring, especially for larger code base. Here are the add-ins that I have tried so far: * Visual Assist X * Refactor! Pro Meanwhile, does anyone know if Visual Studio 2010 will have any real C++ refactoring tool built in? Many Thanks! Minyu

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >