Wednesday, 18 November 2009

ASP.net Problems

  1. Starting IIS on Vista for the first time Skype was found to be using port 8080 so stopped Skype and restarted iis without a problem.
  2. Error message CS0016: Could not write to output file 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\etc etc .dll' -- 'Access is denied. 
  3. Add full permissions for 'Network Service' & 'YourComputerName\IIS_IUSERS to:
    • C:\Windows\Temp
    • C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
  4. ASP.net local iis problem when trying to run locally
"Unable to start debugging on the web server. The web server is not configured correctly. See help for common configuration errors. Running the web page outside of the debugger may provide further information."

Error message not very helpfull, eventually fixed by removing directives in the Web.Config for
ScriptModule
WebExtensions
Not 100% sure why though they are probably in the Machine.config file and therefore created a duplicate which was only detected when running outside debug environment

.NET MicroFramework

Microsoft Opensource announcement

Friday, 13 November 2009

C# Constructors

For some reason I always forget how to call one constructor from another. Of course now I've written it down I'll probably never need to refer to it again but anyway:

public Car(string model, int noWheels){}

Car(string model) : this(model,4){}

Thursday, 5 November 2009

WPF: NUnit Testing when using the WPF Dispatcher

I have encoutered problems when using NUnit to test a ViewModel which has ThreadSafeObservableCollection. The thread safety comes about through using the Dispatcher and when you call Dispatcher.BeginInvoke, you are instructing the dispatcher to run the delegates on its thread when the thread is idle.
When running unit tests, the main thread will never be idle. It will run all of the tests then terminate.

To overcome this I have written a trap which looks for the NUnit Thread Name. A true result and the ThreadSafeCollection proceeds without using the Dispatcher.

private bool CheckDispatcherAccess()
{
if (_dispatcher.Thread.Name == "TestRunnerThread")
{
return true;
}
return _dispatcher.CheckAccess();
}
...


Other references to the Dispatcher issue when using NUnit

Using the WPF Dispatcher in NUnit Tests

WPF: MVVM

M-V-VM training day sample application and decks

MVVM

Wizard example

WPF: INotifyPropertyChanged and Delayed Binding

Delayed Binding TextBox

Delayed Binding using MarkupExtension which I couldn't get to work, Good for the MarkupExtension tho

Various Implementations of INotifyPropertyChanged

REPOSITORY PATTERN

Applying Domain-Driven Design and Patterns by Jimmy Nilsson

Repository pattern using LINQ and some IoC, it's really joy to programm

Using the unit of work-per-request pattern in ASP.NET MVC

Monday, 2 November 2009

AGILE : Release Strategies and Software

http://wiki.cantara.no/display/ARS/Agile+Release+Strategies+Home;jsessionid=1032BB46B2781F05A21CF4155A9FBB17

http://wpf-samples.blogspot.com/2007/01/pimp-up-your-radiobutton-sample.html

LINQ: Update Data

var product = (from p in dataContext.Products
where p.ProductID == 1
select p).Single();

product.Name = "New Product Name";

dataContext.SubmitChanges();

Using LINQ with MVC
The following code using the Attach method on the Linq entity will throw an exception as per Stephen Walther's excellent article Stephen Walther blog archive.  This is a concurrency issue and can be remedied in 2 ways as per Stephen's article.
public ActionResult Edit(DxDataBook editedPart)
{
try
{
var originalPart = (from p in dc.DxDataBooks
where p.P_D_Num == editedPart.P_D_Num
select p).First();

if (!ModelState.IsValid)
{
return View(originalPart);
}

dc.DxDataBooks.Attach(editedPart,true);
dc.SubmitChanges();
return RedirectToAction("Index");
}
catch
{
return View();
}
}