Unit Testing ASP.NET? ASP.NET unit testing has never been this easy.
Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle - and for the launch will be giving out FREE licenses to bloggers and their readers.
The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both Typemock Isolator, a unit test tool and Ivonna, the Isolator add-on for ASP.NET unit testing, for a bargain price.
Typemock Isolator is a leading .NET unit testing tool (C# and VB.NET) for many ‘hard to test’ technologies such as SharePoint, ASP.NET, MVC, WCF, WPF, Silverlight and more. Note that for unit testing Silverlight there is an open source Isolator add-on called SilverUnit.
The first 60 bloggers who will blog this text in their blog and tell us about it, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET dedicated blog, you'll get a license automatically (even if more than 60 submit) during the first week of this announcement.
Also 8 bloggers will get an additional 2 licenses (each) to give away to their readers / friends.
Go ahead, click the following link for more information on how to get your free license.
Tuesday, May 19, 2009
Asp.Net Bundle from TypeMock
Tuesday, September 02, 2008
Thursday, August 07, 2008
Writing to Event log with ASP.Net and Enterprise Library
I recently had a problem writing to the event log from my application. I had configured the application to use the Logging Application Block from the 3.1 version of the Microsoft Enterprise Library and followed the walk-through in the documentation to log exceptions to the Application Log, but nothing was appearing.
I had amended the code so that it always through an exception on clicking a test button, and stepping through the code, I could see that Log.Write was being called and no error was raised from this call.
A quick search on Google suggested that this was a permissions issue for the ASP.Net account, so I added the following key:
HKLM\System\CurrentControlSet\Services\EventLog\Application\<my app name>
I granted full control to the ASPNET account to this key and amended the source property of my trace listener to <my app name> using the Enterprise Library Configuration Manager.
I now get events recorded in the Application log and their source is set to <my app name> so it is easy to filter them for the events I want.
Tuesday, March 04, 2008
Code Access Security For Child AppDomain
I recently configured an existing application to use ClickOnce deployment. All seemed to go well until I tried to run the application, whereupon it threw an exception on a line that had previously been working perfectly:
AppDomain childDomain;
childDomain = AppDomain.CreateDomain(ChildAppDomainName);
//Following line throws exception
childDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionHandler);
The exception was:
{"Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."}
The application was configured to run as FullTrust. To cut a long and frustrating story short, It turned out that the security settings were not being propagated to the child AppDomain. I changed the code to the following:
AppDomain childDomain;
Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
Evidence childEvidence = new Evidence(baseEvidence);
childDomain = AppDomain.CreateDomain(ChildAppDomainName, childEvidence, AppDomain.CurrentDomain.SetupInformation);
This allowed the child AppDomain to inherit the settings from the parent domain and everything worked as expected once more.
Friday, February 29, 2008
Check for existence of DB objects
Some queries I find useful to add before the Create/Alter Statements in SQL Server.
--Constraints
IF EXISTS(
SELECT NULL FROM INFORMATION_SCHEMA.Constraint_column_usage
where table_name ='MyTable'
and constraint_name = 'FK_COl1')
--Check existence of stored_proc
IF EXISTS (SELECT NULL
FROM information_schema.routines r
WHERE r.specific_schema = 'dbo'
AND r.specific_name = 'MyProc')
--Check column exists
IF NOT EXISTS (
SELECT NULL
FROM information_schema.columns
where column_name='Col1'
AND table_name ='MyTable'
and table_schema='dbo')
IF not EXISTS(
SELECT NULL from sys.all_objects ao
INNER JOIN sys.extended_properties ep on ao.object_id = ep.major_id and ep.name ='MS_Description'
where ao.name ='FK_key_name')
Friday, January 25, 2008
Disable full screen video on Dual monitor setup
- Bring up display properties from control panel
- Click Settings
- Click Advanced
- Click Quadro NVS 120 M (Nvidia specific)
- Click Start NVidia control panel
- Click Video and Television
- Click Modify full screen options
- Set "When watching video content" to Only show it in my viewing application
Thursday, January 03, 2008
Soap Extensions in web forms client
<system.web>
<webServices>
<soapExtensionTypes>
<add type="myCompany.myProject.WebServices.SoapExtensions.CompressionExtension,myCompany.myProject.CompressionExtensionLib"
priority="3" group="High" />
soapExtensionTypes>
webServices>
system.web>
The first part of the type is the fully qualified class name, the second part is the namespace.
Tuesday, December 11, 2007
Friday, December 07, 2007
XMLSerialization with multiple XMLRoot attributes
sometag
core
object_definitions
object_type type="myType" plugin="myPlugin"
config
moretags
moretags
moretags
config
object_type
sometag
[Haven't worked out how to escape tags quickly, so I've stripped the brackets]
The following code shows how I created a static method in my config class to load this.
8 ///
9 /// Allows definition of all UI properties
10 ///
11 [Serializable]
12 [XmlRoot("config")]
13 public class ConfigureUIObjectConfig : ObjectConfigBase
14 {
15 public static ConfigureUIObjectConfig LoadUIConfig(string filePath)
16 {
17 System.IO.StreamReader sr=null;
18 ConfigureUIObjectConfig conf;
19 try
20 {
21
22 XmlSerializer xs = new XmlSerializer(typeof(ConfigObjects.ObjectTypes.ConfigureUIObjectConfig));
23
24 sr = new System.IO.StreamReader(filePath);
25 conf = (ConfigureUIObjectConfig)xs.Deserialize(sr);
26 }
27 catch (Exception)
28 {
29 throw;
30 }
31 finally
32 {
33 if (sr!=null)
34 sr.Close();
35 }
36
37 return conf;
38 }
I invoke it from what is normally the root class in my hierarchy in the constructor:
52 public ConfigFile()
53 {
54 //Add default object types
55 ConfigureUIObjectConfig uiConf = new ConfigureUIObjectConfig();
56 ObjectType obj = new ObjectType();
57 //obj.Config = uiConf;
58 obj.Config = ConfigureUIObjectConfig.LoadUIConfig("DefaultUIConfig.xml");//uiConf;
59 obj.Plugin = "UiConfiguratorPlugin";
60 obj.Type = "ConfigureUI";
61 this.Core.ObjectDefinitions.ObjectTypes.Add( obj);
62
63 }
The key to getting this to work is to decorate the ConfigureUIObjectConfig class with the [XmlRoot("config")] attribute. If you do not do this you will get an exception:
System.InvalidOperationException: <config xmlns=''> was not expected.
This eluded me at first as I assumed that I could only mark one class with the XmlRoot attribute, however, it appears that this does not matter in this instance.
Wednesday, October 17, 2007
Typed DataSet NullValue behaviour
msprop:nullValue="_empty" -- (Empty)
msprop:nullValue="_null" -- (Nothing)
msprop:nullValue="_throw" -- (Throw exception)
msprop:nullValue="_throw" is the default value and it is not persisted by default.
The xpath queries I used were:
--Find string columns with no null value prop
/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element[(child::xs:simpleType/xs:restriction/@base='xs:string') and (not(@msprop:nullValue))]
and
--Find nodes where value exists and is not '_empty'
xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element[xs:simpleType/xs:restriction/@base='xs:string']/@msprop:nullValue[.!='_empty']
Wednesday, September 12, 2007
Conditional build events
regasm /u $(TargetPath)
However, this fails if the file is not present (after a clean), so I use the following command to only unregister it if it is present.
path= $(TargetDir) for %f in ($(TargetFileName)) do C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe /u %f
Exposing COM events from .Net to Javascript in web browser
COM Interop Exposed - Part 2
HOW TO: Sink Managed C# Events in Internet Explorer Script
This post is about troubleshooting some common mistakes that may occur. The key thing to note is that if you fail to follow the steps listed in these articles:
- you will NOT get a compile time error
- you will NOT get an error when registering the component
- you will NOT get an error at runtime when you attach the event handler.
- Did not put a Dispid attribute on the methods in my event interface.
- Had name mismatches between the events in my main class and the method names in my interface.
Friday, September 07, 2007
COM component not registering properly
>RegAsm assemblyName
but was unable to invoke the component in a web page. When I tried to examine it in OleView it initially seemed to be fine. However, when I tried to expand the class name node (under .Net category) I got the following error:
CoGetClassObject failed.
The system cannot find the file specified.
severity: SEVERITY_ERROR, facility: FACILITY_WIN32 ($80070002)
Registering it with:
>RegAsm assemblyName /codebase
fixed the issue
Regasm /u not working
RegAsm /u assemblyName
will only remove the entries that match the version number of your assembly. If you have been incrementing the version number of your component and registering the new one without unregistering the previous version then you will end up with entries for each version. To clear them out you can just set the version number of the assembly, compile it and then unregister it with RegAsm. Do this for each version that you need to unregister.
Monday, July 23, 2007
What card are you?
You are The Hierophant
Divine Wisdom. Manifestation. Explanation. Teaching.
All things relating to education, patience, help from superiors.The Hierophant is often considered to be a Guardian Angel.
The Hierophant's purpose is to bring the spiritual down to Earth. Where the High Priestess between her two pillars deals with realms beyond this Earth, the Hierophant (or High Priest) deals with worldly problems. He is well suited to do this because he strives to create harmony and peace in the midst of a crisis. The Hierophant's only problem is that he can be stubborn and hidebound. At his best, he is wise and soothing, at his worst, he is an unbending traditionalist.
What Tarot Card are You?
Take the Test to Find Out.
Tuesday, May 22, 2007
Monday, May 14, 2007
Golden compass
Sunday, May 13, 2007
Friday, May 11, 2007
Thursday, May 10, 2007
Prescient
The discovery that has struck the Titmuss philosopy and left it badly holed is that caring for the environment is quite inconsistent with the free-market economy. Green and true-blue are colours that don't, unfortunately, mix. Preserving the countryside, protecting the woodlands, concern for the ozone layer, all demand levels of government intervention unthinkable in the heady days of victory over the miners and the Falklands War. The high spring of laissez-faire economics is over, the bloom is gone and, such is the nature of politics, with the bloom goes Titmuss.
Who will take his place? It seems likely that Conservatism in the Titmuss mould is now out of style, and his successors may be those prepared to revert to the old consensus days of Butler and Harold Wilson. But what of the left? If free-market Toryism has taken a beating it's as nothing to what recent events in Europe have done to the dreams of the Reverend Simcox. The Labour Party seems to have achieved its huge rise in the opinion polls by freeing itself from what are seen as the tentacles of a Socialist octupus. So what is the new, up-and-coming Labour M.P. going to be like? No doubt he will have extinguished the dear old Trades Union dinosaur. Unquestionably he will be outspoken, quick-witted, with a talent for P.R. and a complete freedom from class distinctions. He will, of course, be wearing a blue suit with a discreet tie, own a car phone and a word processor and believe in free enterprise in a mixed economy. Is the stage set, after the next election, for the emergence of the first Labour Titmuss? Whatever happens, of one thing there is no doubt, British politics will remain a fertile ground for comedy.
John Mortimer 1991