Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to merge assembly containing PostSharp aspects in Smart Assembly
    primarykey
    data
    text
    <p>I am having issues merging an assembly containing my PostSharp aspects into my project via SmartAssembly and was wondering if any one can help.</p> <p>The main assembly is fairly simple and looks like:-</p> <pre><code> class Program { static void Main(string[] args) { var doer = new Doer(); doer.Do(); Console.WriteLine("press any key to continue"); Console.ReadKey(); } } [MethodDebugLogging(AttributeTargetElements = MulticastTargets.Method)] public class Doer { public void Do() { Console.WriteLine("stuff and nonesense"); } } </code></pre> <p>The MethodDebugLogging aspect works fine provided it's in the same assembly but adding it to it's own assembly and then merging via SmartAssembly results in:-</p> <pre><code>System.TypeInitializationException: The type initializer for '&lt;&gt;z__Aspects' thre w an exception. ---&gt; System.TypeInitializationException: The type initializer fo r '&lt;&gt;z__AspectsImplementationDetails762586886' threw an exception. ---&gt; System.I O.FileNotFoundException: Could not load file or assembly 'Aspects, Version=1.0.0 .0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String cod eBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark&amp; stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppre ssSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName as semblyRef, Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean forIntr ospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evid ence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at PostSharp.Aspects.Serialization.BinaryAspectSerializationBinder.BindToType (String assemblyName, String typeName) at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Bind(String as semblyString, String typeString) at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(Binary AssemblyInfo assemblyInfo, String name) at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String obje ctName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInf ormationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, Bi naryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable) at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWi thMapTyped(BinaryObjectWithMapTyped record) at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(He aderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAp pDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCr ossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallM essage methodCallMessage) at PostSharp.Aspects.Serialization.BinaryAspectSerializer.Deserialize(Stream stream, IMetadataDispenser metadataDispenser) at PostSharp.Aspects.Serialization.AspectSerializer.Deserialize(Assembly asse mbly, String resourceName, IMetadataDispenser metadataDispenser) at &lt;&gt;z__AspectsImplementationDetails762586886..cctor() --- End of inner exception stack trace --- at Obfuscation_Spike1.Doer.&lt;&gt;z__Aspects..cctor() --- End of inner exception stack trace --- at Obfuscation_Spike1.Doer.Do() at Obfuscation_Spike1.Program.Main(String[] ) </code></pre> <p>And the aspect itself is fairly simple:-</p> <pre><code> [Serializable] public class MethodDebugLogging : OnMethodBoundaryAspect { public override void OnEntry(MethodExecutionArgs args) { Console.WriteLine("Entering: {0}.{1}", args.Method.DeclaringType, args.Method.Name); } public override void OnExit(MethodExecutionArgs args) { Console.WriteLine("Exiting: {0}.{1}", args.Method.DeclaringType, args.Method.Name); } } </code></pre> <p>From the exception it looks to me as if the aspects namespace of the Postsharp Distributable gets stripped out when I merge the assembly containing the aspect, is anyone able to shed some light on this?</p> <p>Thanks</p> <p>Paul</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload