diff --git a/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual.Test/PostSharp.Samples.DependencyResolution.Contextual.Test.csproj b/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual.Test/PostSharp.Samples.DependencyResolution.Contextual.Test.csproj
new file mode 100644
index 0000000..766fe77
--- /dev/null
+++ b/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual.Test/PostSharp.Samples.DependencyResolution.Contextual.Test.csproj
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+ Debug
+ AnyCPU
+ {232F6D41-893E-4526-9C4A-94C57EF12B6F}
+ Library
+ Properties
+ PostSharp.Samples.DependencyResolution.Contextual.Test
+ PostSharp.Samples.DependencyResolution.Contextual.Test
+ v4.7.2
+ 512
+ {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 15.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+ $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
+ False
+ UnitTest
+
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll
+
+
+ ..\..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll
+
+
+ ..\..\packages\PostSharp.Redist.5.0.37\lib\net45\PostSharp.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {9dfd9bdb-fb8b-4066-a62e-670c20ce1213}
+ PostSharp.Samples.DependencyResolution.Contextual
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual.Test/Properties/AssemblyInfo.cs b/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual.Test/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..917667c
--- /dev/null
+++ b/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual.Test/Properties/AssemblyInfo.cs
@@ -0,0 +1,20 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("PostSharp.Samples.DependencyResolution.Contextual.Test")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("PostSharp.Samples.DependencyResolution.Contextual.Test")]
+[assembly: AssemblyCopyright("Copyright © 2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("232f6d41-893e-4526-9c4a-94c57ef12b6f")]
+
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual.Test/TestLogAspect.cs b/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual.Test/TestLogAspect.cs
new file mode 100644
index 0000000..73fc16c
--- /dev/null
+++ b/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual.Test/TestLogAspect.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace PostSharp.Samples.DependencyResolution.Contextual.Test
+{
+ [TestClass]
+ public class TestLogAspect
+ {
+ [TestMethod]
+ public void TestMethod()
+ {
+ // The ServiceLocator can be initialized for each test.
+ using (
+ AspectServiceLocator.AddRule(
+ (type, member) =>
+ type == typeof(LogAspect) && member.Name == "TargetMethod" ? new TestLogger() : null)
+ )
+ {
+ TestLogger.Clear();
+ TargetMethod();
+ Assert.AreEqual("OnEntry" + Environment.NewLine, TestLogger.GetLog());
+ }
+ }
+
+ [LogAspect]
+ public void TargetMethod()
+ {
+ }
+ }
+
+ internal class TestLogger : ILogger
+ {
+ public static readonly StringBuilder stringBuilder = new StringBuilder();
+
+ public void Log(string message)
+ {
+ stringBuilder.AppendLine(message);
+ }
+
+ public static string GetLog()
+ {
+ return stringBuilder.ToString();
+ }
+
+ public static void Clear()
+ {
+ stringBuilder.Clear();
+ }
+ }
+}
\ No newline at end of file
diff --git a/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual.Test/packages.config b/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual.Test/packages.config
new file mode 100644
index 0000000..6dec090
--- /dev/null
+++ b/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual.Test/packages.config
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual/App.config b/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual/PostSharp.Samples.DependencyResolution.Contextual.csproj b/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual/PostSharp.Samples.DependencyResolution.Contextual.csproj
new file mode 100644
index 0000000..72ad117
--- /dev/null
+++ b/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual/PostSharp.Samples.DependencyResolution.Contextual.csproj
@@ -0,0 +1,69 @@
+
+
+
+
+
+ Debug
+ AnyCPU
+ {9DFD9BDB-FB8B-4066-A62E-670C20CE1213}
+ Exe
+ PostSharp.Samples.DependencyResolution.Contextual
+ PostSharp.Samples.DependencyResolution.Contextual
+ v4.7.2
+ 512
+ true
+ true
+
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\..\packages\PostSharp.Redist.5.0.37\lib\net45\PostSharp.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual/Program.cs b/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual/Program.cs
new file mode 100644
index 0000000..fb68253
--- /dev/null
+++ b/DependencyResolution/PostSharp.Samples.DependencyResolution.Contextual/Program.cs
@@ -0,0 +1,120 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using System.ComponentModel.Composition.Hosting;
+using System.ComponentModel.Composition.Primitives;
+using System.Reflection;
+using PostSharp.Aspects;
+using PostSharp.Extensibility;
+using PostSharp.Serialization;
+
+namespace PostSharp.Samples.DependencyResolution.Contextual
+{
+ public interface ILogger
+ {
+ void Log(string message);
+ }
+
+ public static class AspectServiceLocator
+ {
+ private static CompositionContainer container;
+ private static HashSet