.net

XDocument Attribute Performance Concerns

I have a loaded XDocument that I need to grab all the attributes that equal a certain value and is of a certain element efficiently. My current IEnumerable<XElement> vm; if (!cacher2.TryGetValue(name,out vm)) { vm = project.Descendants(XName.Get(name)); cacher2.Add(name, vm); } XElement[] abdl = (vm.Where(a => a.Attribute(at...

Read and write from a byte stream if the endianess of the data is different from that of the current machine.

I have a stream of bytes which contains a flag which identifies the endianness of the data in the header. I want to read the doubles from the stream, which will presumably need to be different if the endianness of the data in the header is different? I am currently using a BinaryReader and calling ReadDouble to read the data from the s...

Speed up login to StarTeam?

I'm working on a program that accesses StarTeam using the StarTeam SDK for .NET. And I've noticed that it takes about 10 seconds to login to the StarTeam server. I'm wondering if there's anything I can do to speed that up. Edit I used this command to run the StarTeam Cross Platform client with debugging output: stjava.exe StarTeamCP.stj...

System.Diagnostics.Process - Del Command

I'm trying to start the del command using System.Diagnostic.Process. Basically I want to delete everything from the C:\ drive that has the filename of *.bat System.Diagnostics.Process proc = new System.Diagnostics.Process(); string args = string.Empty; args += "*.bat"; proc.StartInfo.FileName = "del"; proc.StartInfo.WorkingDirectory =...

Implement System.Web.Caching.Cache Object in a controller to cache specific query

Is it correct to implement my caching object like this in my controller : public class HomeController : BaseController { public static Cache cachingControl = new Cache(); ... And I Use it like this : public ActionResult Home() { IndexViewData view = new IndexViewData(); view.UserId = UserId; if (cachingControl.Get("view...

WinForms TabControl: How to avoid tab-rendering on DrawMode=OwnerDrawFixed?

I extended the (WindowsForms) built-in TabControl so that users can close tabs right on the tab itself ("x" image on the right like in Webbrowsers). The inherited control renders the text and images. Also, it uses visual styles on hover etc. All works very well, but I have one problem I can't solve. When the tabs are rendered, I cannot ...

Can I set text box to readonly when using Html.TextBoxFor?

I have the following tag with a Html.TextBoxFor expression and I want the contents to be read only, is this possible? <%= Html.TextBoxFor(m => Model.Events.Subscribed[i].Action)%> ...

iBatis.net and IOC DI

Hey all, I'm using iBatis.net as my ORM and Structuremap for my IOC library. I'm currently trying to figure out how to get iBatis to use the IOC container to create objects instead of relying on the default constructor. Is there a way that anyone knows of to enhance iBatis in such a way? Currently as a work around I'm doing a hack of a...

OpenXML SDK How to position an image in MS Word ?

I did insert an image using the OpenXML SDK API .. however i can not figure out how to position the image to appear on any part of the page (probably using anything similar to (x,y) co-ordinates)? ...

Inconsistency in passing objects from VBA to .NET via COM

I have the following interface defined to expose a .NET class to COM: [InterfaceType(ComInterfaceType.InterfaceIsDual)] [Guid("6A983BCC-5C83-4b30-8400-690763939659")] [ComVisible(true)] public interface IComClass { object Value { get; set; } object GetValue(); void SetValue(object value); } The implementation of this int...

LINQ - array property contains element from another array

I have a object (product), with a property of type 'array' e.g. product.tags = {"tag1","tag2","tag9"} I have an array of input tags to filter on. ... but this is not quite working: List<string> filterTags = new List<string>() { "tag1", "tag3" }; var matches = from p in products where p.Tags.Contains(filterTags) select p; Any re...

Best way to move files of varying sizes across slow network using .NET

I'm building a .NET remoting client/server that will be transmitting thousands of files, of varying sizes (everything from a few bytes to hundreds of MB), and I'd like some feedback on the best method for achieving this. As I see it, there are a couple of options: Serialize the entire file into my remoting object and transmit at all at...

settings file vs app.config

I'm not really understanding the interaction/differences between settings and config files. If I add an entry to the settings file, it gets added to the app.config as well. Does this mean that changing the value in the app.config will update the settings? If not, how do I update settings in a live application? What's the general purpose ...

Code Contracts: Do we have to specify Contract.Requires(...) statements redundantly in delegating methods?

I'm intending to use the new .NET 4 Code Contracts feature for future development. This made me wonder if we have to specify equivalent Contract.Requires(...) statements redundantly in a chain of methods. I think a code example is worth a thousand words: public bool CrushGodzilla(string weapon, int velocity) { Contract....

Is there a way in .Net to get a string value for an int's word?

For example: (1).SomeFunction().Equals("one") (2).SomeFunction().Equals("two") I really only need it for digits 1-9 in the case I'm working with, should I just use a switch/select case? Update I won't need localization in this case either. Update 2 Here's what I ended up using: Private Enum EnglishDigit As Integer zero one ...

Umbraco CMS - keep getting logged out in ie, safari, chrome but not ff

I have a few Umbraco sites running on my server - but i'm getting logged out when using everything else than Firefox when using umbraco. I'm able to log in and after 10-15 sec's i'm being automatically logged out again. How can that be and how do i fix it? :( It's a win 2008 server using MSSQL database and umbraco 4.0.3 btw is runnin...

How to manage and capture database changes across several developers?

We have three developers and one tester all working against the same database. We change the schema of the database quite often, and every time we do it tends to have a ripple effect of headaches for everyone else. Are there good practices in place for .NET oriented development against MS SQL Server 2008 for managing this? I am thinkin...

TFS and team project portal question

The team explorer for my project looks like this: mytfsserver\mycollection -- Project 1 solution -- Project 2 solution -- Project 3 solution When I right click on one of the solutions and do a "Show Project Portal", I see the following hierarchy: mycollection - WSS site Project 1 site with dashboard (appears to be a MOSS site) Projec...

Dependency injection: How to pass the injection container around?

(This question does not rely on a specific IoC framework, so the interfaces and types in my samples are meta-types. Just replace them with the appropriate types for your favorite IoC framework in your head.) In my main methods, I typically set up my container doing something like this: static void Main() { IInjector in = new Inject...

Convincing Management to use WCF

I asked another question stating that the I am unable to use WCF in a new Web Service project and have come to see that it seems to be the technology to use in regards to extensibility and security. My question is a simple one: How can I persuade management (and developers for that matter) to move over to using WCF as opposed to other ...