.net

Asp.Net Mvc: Cannot access my models namespace from my view

So I have a ViewModel in the 'models' folder of my Mvc project with a namespace of 'Web.Models' (My Mvc project is called 'Web') I think its worth mentioning I have 3 other projects in my solution: Domain, Test, and Tasks. The view model is assigned properties from classes in my Domain.Entities folder. I can create a new instance of my ...

Good start for .Net and c++ to Java transition?

I know the .Net framework very well and know where to find things ie: StreamReader, StreamWriter, Graphics, etc, and I know Java has similar things. The syntax is different but quite similar to c++ which I have a lot of native c++ experience. Therefore, what would you recomend as a good starting point for tutorials and such. Thanks ...

Why does "-less" sort after "hello" instead of before it?

I'm seeing some very strange sorting behaviour using CaseInsensitiveComparer.DefaultInvariant. Words that start with a leading hyphen "-" end up sorted as if the hyphen wasn't there rather than being sorted in front of actual letters which is what happens with other punctuation. So given { "hello", ".net", "-less"} I end up with {".net"...

Add Stylesheet reference to XML Document in Linq?

I create an XML Doc and wanted have a reference to the XSLT file. //<?xml-stylesheet type="text/xsl" href="OBReport.xslt"?> to this XML generation: XElement xml = new XElement("ReportedOn", from dl in EL.DocumentLog.ToList() join o in EL.Organization on dl.OrganizationID eq...

CryptoStream.Close() fails when the disk is full

I am using a CryptoStream for writing encrypted audio data to the file (underlying stream is FileStream). When I try to call CryptoStream.Close() over the full disk, I get an exception. I know that this is because CryptoStream.Close() invokes FlushFinalBlock() during disposing. As a result I get the corrupted data in my encrypted file an...

How to mock everything?

I understand how to mock interfaces or virtual method calls. But frameworks like TypeMock can mock everything in the framework. Which .NET mechanisms are used to provide such functions? ...

Why doesn't C# allow declaring variables with the same number inside different case blocks for switch statements?

Possible Duplicate: Case Statement Block Level Declaration Space in C# For example: string danger; switch ( this.Type ) { case Warfare.Nuclear: case Warfare.Biological: case Warfare.Chemical: danger = "deadly"; break; case Warfare.Air: string threat = "major" ... brea...

Get Absolute URL from Relative path (refactored method)

I am really surprised that there is no native .NET method to get an absolute url from a relative url. I know this has been discussed many times, but never have come across a satisfactory method that handles this well. Can you help fine tune the method below? I think all I need left is to auto choose the protocol instead of hard coding i...

C# Regex need pattern for string match

This is my second attempt to get this answer since I messed it up first time :s As you can guess Im new to regex basically, the string contains lots of words seperated by "\"'s. so for example \gyifgy8i\gyigyi9g\player_0\k1ng*tar%\gp86gg78.\g79g\player_1\th3dadY>\gyigyigiy\huiohgiu\player_2\j0k$r\g68g6o9g\987pgh890\player_3\PLAYERNAME ...

How to verify a Hyperlink exists on a webpage?

I have a need to verify a specific hyperlink exists on a given web page. I know how to download the source HTML. What I need help with is figuring out if a "target" url exists as a hyperlink in the "source" web page. Here is a little console program to demonstrate the problem: public static void Main() { var sourceUrl = "http://dev...

Many IoC dependencies in transaction-script type processes - what are we doing wrong?

We have many long-running processes that each require dozens of steps. Each step is relatively complex in its own right, so we broke those steps into their own classes. We are using DI/IoC (StructureMap) to help us make the whole thing testable. This has been working great, but we find ourselves with oodles of dependencies in our cont...

How do I make a c# exe artificially large?

I have a requirement to make an existing c# app 10MB in size. Making the app is easy, making it large intentionally, not so much. There is the obvious way of adding embedded images, but I want the exe to compress to a small size as well. Any idea? ...

Leveraging ASP.NET machineKey For Encrypting My Own Data

I have some data I want to encrypt in an ASP.NET MVC application to prevent users from tampering with it. I can use the Cryptography classes to do the actual encryption/decryption, no problem there. The main problem is figuring out where to store the encryption key and managing changes to it. Since ASP.NET already maintains a machineK...

One library for deflate, gzip, and zlib in .net

First, let's define some commonly confused terms: deflate = compression_algorithm; zlib = header + deflate + trailer; gzip = header + deflate + trailer; I'm looking for a library that will basically let me do the following: if(method == "gzip"){ Response.Filter = new CompressionLibrary.OutputStream(Response.Filter, CompressionLib...

Direct3D COM interop in C#

Hello, I noticed that Direct3D is COM exposed, but there doesn't seem to be a type library for it. My first question is, what is the point of COM exposure if the infrastructure to use it isn't really there? I've considered that I could write my own COM interfaces in C#. But it makes me somewhat concerned that this hasn't already bee...

WPF - what's wrong with this code (trying to get IsEnabled to bind to dependency property)

Hi, Any idea where I'm going wrong with this code. I wan the TextBox to be Enabled when the associated RadioButton for it is selected, and then when a different radio button is selected want it to be Enabled=False. I created a ProxyMode dependency property and have changed the getter to obtain it's bool value based on whether Proxy i...

wpf - how should I auto-grey-out a textbox when it's associated radiobutton is not selected?

Hi, What's the best approach to auto-grey-out a textbox if it's associated radiobutton is not selected? I've got an open question out re using a dependency property (which I haven't got working) for this, however I'm not sure this is the appropriate approach. So basically when RadioButton 1 is selected the text field is enabled, how...

DateTime loses precision when serialized/deserialized

I'm setting a date on a DateTime type field and I call my web service which is located on the same server using WCF: // on the client myObject.Date = DateTime.Now; myChangedObject = proxy.DoNothing(myObject); // passes back the object // on the server public MyObjectType DoNothing(MyObjectType source) { var obj = new MyObj...

How to encourage myself to switch to ORM?

I'm working with a legacy project of my team-mate (.NET/Oracle). The project is not yet completed, it's under construction and far from production. He followed a "traditional way" to access data, which is creating stored procedures and then use database driver to call them. I want to follow a "modern way" to access data: use an ORM to ab...

WPF element positioning on a Canvas

I have a point on a canvas that I want to place an ellipse. I want the centre of the ellipse to be over this point. At the moment the top left most edge of the ellipse is over this point. I know I can shift the ellipse programmatically on the canvas but I was wondering if there is a way to tell WPF to centre the element over the point i...