Interesting fluent interface for specifying pre and post conditions. Read MSDN article:
http://msdn.microsoft.com/en-us/magazine/ee335714.aspx
download here, free open source:
http://conditions.codeplex.com/
update:
alternatives are
http://research.microsoft.com/en-us/projects/contracts/
http://research.microsoft.com/en-us/projects/specsharp/
Monday, 31 January 2011
Friday, 28 January 2011
Running mixed mode assemblies
If your running .net 4.0 and you have a dependency on a lower version assembly (in my case 2.X) you might get this error
FileLoadException was unhandled
Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
This can be fixed obviously by building the dependency to 4.0 or with this config (if you don't have control of the assembly as in my case)
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
<startup/>
key config is useLegacyV2RuntimeActivationPolicy="true"
(under <configuration> )
FileLoadException was unhandled
Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
This can be fixed obviously by building the dependency to 4.0 or with this config (if you don't have control of the assembly as in my case)
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
<startup/>
key config is useLegacyV2RuntimeActivationPolicy="true"
(under <configuration> )
.NET Framework 4 Client Profile
I had a problem where I was referencing Microsoft.IdentityModel, and using this as a using statement such as
using Microsoft.IdentityModel.Protocols.WSTrust;
but got the complier error 'the type or namespace name ... could not be found'. This was completely driving me nuts - lost 0.5 days on this. When I include the reference initially, intellisense would pick it up, but on compiling it failed with that error, then intellisense stopped picking it up.
It turns out that I was using '.NET Framework 4 Client Profile' as the target framework, on changing to '.NET Framework 4', it fixed the problem.
using Microsoft.IdentityModel.Protocols.WSTrust;
but got the complier error 'the type or namespace name ... could not be found'. This was completely driving me nuts - lost 0.5 days on this. When I include the reference initially, intellisense would pick it up, but on compiling it failed with that error, then intellisense stopped picking it up.
It turns out that I was using '.NET Framework 4 Client Profile' as the target framework, on changing to '.NET Framework 4', it fixed the problem.
Thursday, 27 January 2011
XML from WIF SecurityToken
If you ever need to see the XML in a SecurityToken (in my case a SamlSecurityToken) then you have to write it out using a XmlWriter:
var sth = new Microsoft.IdentityModel.Tokens.Saml11.Saml11SecurityTokenHandler();
var ms = new MemoryStream();
var writer = XmlWriter.Create(ms);
sth.WriteToken(writer, token);
writer.Flush();
ms.Seek(0, SeekOrigin.Begin);
var xml = new StreamReader(ms).ReadLine();
where token is a SecurityToken object (System.IdentityModel.Tokens).
var sth = new Microsoft.IdentityModel.Tokens.Saml11.Saml11SecurityTokenHandler();
var ms = new MemoryStream();
var writer = XmlWriter.Create(ms);
sth.WriteToken(writer, token);
writer.Flush();
ms.Seek(0, SeekOrigin.Begin);
var xml = new StreamReader(ms).ReadLine();
where token is a SecurityToken object (System.IdentityModel.Tokens).
WCF Logging
WCF Logging - put this code block in under <configuration>
<system.diagnostics>
<sources>
<source propagateActivity="true" logKnownPii="true" name="System.ServiceModel"
switchValue="Warning">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="traceListener">
<filter type="" />
</add>
</listeners>
</source>
<source name="Microsoft.IdentityModel" switchValue="Warning, ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="traceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="c:\logs\log.svclog" type="System.Diagnostics.XmlWriterTraceListener"
name="traceListener" traceOutputOptions="None">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
<system.diagnostics>
<sources>
<source propagateActivity="true" logKnownPii="true" name="System.ServiceModel"
switchValue="Warning">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="traceListener">
<filter type="" />
</add>
</listeners>
</source>
<source name="Microsoft.IdentityModel" switchValue="Warning, ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="traceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="c:\logs\log.svclog" type="System.Diagnostics.XmlWriterTraceListener"
name="traceListener" traceOutputOptions="None">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
Introduction
Hello,
this is my blog mainly for keeping notes to myself - if anyone else finds it useful than great.
this is my blog mainly for keeping notes to myself - if anyone else finds it useful than great.
Subscribe to:
Posts (Atom)