ArxOne / MrAdvice

.NET aspect weaver (build task under NuGet package)
MIT License
311 stars 45 forks source link

build error in x64 with IMethodWeavingAdvice #167

Closed dayang closed 4 years ago

dayang commented 4 years ago

I write a class which implements IMethodWeavingAdvice,when I build to x64,I get error as follow,but it's ok in x86 and anycpu。I can't figure out why,please help me

public class Command : Attribute, IMethodWeavingAdvice
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): warning : Can't load SunFlow.Cgns, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: System.BadImageFormatException: Could not load file or assembly 'SunFlow.Cgns, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. This assembly was compiled for a different processor.
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): warning :    at System.Reflection.RuntimeAssembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection, Boolean fSkipIntegrityCheck, SecurityContextSource securityContextSource)
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): warning :    at System.Reflection.Assembly.Load(Byte[] rawAssembly)
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): warning :    at ArxOne.MrAdvice.MrAdviceStitcher.LoadWeavedAssembly(AssemblyStitcherContext context, IAssemblyResolver assemblyResolver)
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): warning : Can't load MonitoredUndo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: System.BadImageFormatException: Could not load file or assembly 'MonitoredUndo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. This assembly was compiled for a different processor.
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): warning :    at System.Reflection.RuntimeAssembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection, Boolean fSkipIntegrityCheck, SecurityContextSource securityContextSource)
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): warning :    at System.Reflection.Assembly.Load(Byte[] rawAssembly)
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): warning :    at ArxOne.MrAdvice.MrAdviceStitcher.LoadWeavedAssembly(AssemblyStitcherContext context, IAssemblyResolver assemblyResolver)
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): error : Internal error during Methods weaving advice: System.BadImageFormatException: Could not load file or assembly 'SuFlow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. This assembly was compiled for a different processor.
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): error :    at System.Reflection.RuntimeAssembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection, Boolean fSkipIntegrityCheck, SecurityContextSource securityContextSource)
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): error :    at System.Reflection.Assembly.Load(Byte[] rawAssembly)
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): error :    at ArxOne.MrAdvice.MrAdviceStitcher.LoadWeavedAssembly(AssemblyStitcherContext context, IAssemblyResolver assemblyResolver)
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): error :    at ArxOne.MrAdvice.MrAdviceStitcher.<>c__DisplayClass1_1.<Process>b__0()
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): error :    at ArxOne.MrAdvice.Reflection.TypeLoader.GetType(ITypeDefOrRef typeReference)
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): error :    at ArxOne.MrAdvice.Weaver.AspectWeaver.RunWeavingAdvices(MarkedNode markedMethod, WeavingContext context)
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): error :    at ArxOne.MrAdvice.Weaver.AspectWeaver.<>c__DisplayClass24_1.<Weave>b__2(MarkedNode i)
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): error :    at ArxOne.MrAdvice.Utility.EnumerableExtensions.ForAll[TItem](IEnumerable`1 enumerable, Action`1 action)
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): error :    at ArxOne.MrAdvice.Weaver.AspectWeaver.Weave(ModuleDefMD moduleDefinition)
7>D:\work\cgns\suflow\代码\su-flow-framework\packages\MrAdvice.2.8.11\build\MrAdvice.targets(10,5): error : Please complain, whine, cry, yell at https://github.com/ArxOne/MrAdvice/issues/new
picrap commented 4 years ago

Hi, yes, this is a limitation becaure mr advice loads the assembly in its own space, in order to invoke the weaving advices. Right now the only solution is to switch to Any CPU, but since you haven’t I guess this is not possible in your case?

dayang commented 4 years ago

Thanks,my project has to invoke native c dlls,so I'll try to find how to load different platform dlls with Any CPU.