This project is read-only.

Problem with Postfix, AutoMapper after converting to .NET 4

Feb 21, 2011 at 12:28 PM

Hi

I'm steadily updating the project to work with the Visual Studio 2010, albeit without the template generation bit which I understand cannot work yet with .NET 4.0.

One problem I've hit the proverbial brick wall with is the following error. I'm struggling to see what part postsharp is playing in order to get to the root cause. any ideas?

I'm guessing this is a red herring. It looks like there's a missing assembly so postsharp then tries the network to find it - I don't think it should even be getting that far.

Here's the error:

Error 3 Unhandled exception: PostSharp.CodeModel.BindingException: Error while loading the assembly "C:\dev\WhoCanHelpMe\Main\Solutions\WhoCanHelpMe.Framework\bin\Debug\AutoMapper.dll": An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.===== PostSharp Assembly Binder =================Resolving the assembly name 'AutoMapper'.Looking in GAC for AutoMapper, Version=0.3.0.54, Culture=neutral, PublicKeyToken=be96cd2c38ef1005.Looking in GAC for AutoMapper, Version=0.3.0.54, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=x86.Looking in GAC for AutoMapper, Version=0.3.0.54, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL.Probing location 'C:\dev\WhoCanHelpMe\Main\ReferencedAssemblies\PostSharp\AutoMapper.exe' because this directory contains an assembly that has already been loaded.Probing location 'C:\dev\WhoCanHelpMe\Main\ReferencedAssemblies\PostSharp\AutoMapper.dll' because this directory contains an assembly that has already been loaded.Probing location 'C:\dev\WhoCanHelpMe\Main\Solutions\WhoCanHelpMe.Web.Controllers\obj\Debug\Before-PostSharp\AutoMapper.exe' because this directory contains an assembly that has already been loaded.Probing location 'C:\dev\WhoCanHelpMe\Main\Solutions\WhoCanHelpMe.Web.Controllers\obj\Debug\Before-PostSharp\AutoMapper.dll' because this directory contains an assembly that has already been loaded.Probing location 'C:\dev\WhoCanHelpMe\Main\Solutions\WhoCanHelpMe.Framework\bin\Debug\AutoMapper.exe' because this directory contains an assembly that has already been loaded.Probing location 'C:\dev\WhoCanHelpMe\Main\Solutions\WhoCanHelpMe.Framework\bin\Debug\AutoMapper.dll' because this directory contains an assembly that has already been loaded.File 'C:\dev\WhoCanHelpMe\Main\Solutions\WhoCanHelpMe.Framework\bin\Debug\AutoMapper.dll' has identity 'AutoMapper, Version=0.3.0.54, Culture=neutral, PublicKeyToken=be96cd2c38ef1005'.Selecting file 'C:\dev\WhoCanHelpMe\Main\Solutions\WhoCanHelpMe.Framework\bin\Debug\AutoMapper.dll'.Loading assembly from file {C:\dev\WhoCanHelpMe\Main\Solutions\WhoCanHelpMe.Framework\bin\Debug\AutoMapper.dll}. System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.   at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence)   at System.Reflection.Assembly.LoadFile(String path)   at PostSharp.CodeModel.AssemblyLoadHelper.LoadAssemblyFromFile(String fileName, Evidence assemblySecurity)
=================================================
       at PostSharp.CodeModel.AssemblyLoadHelper.ManageAssemblyLoadException(String assemblyName, Exception e)   at PostSharp.CodeModel.AssemblyLoadHelper.LoadAssemblyFromFile(String fileName, Evidence assemblySecurity)   at PostSharp.CodeModel.Domain.GetAssembly(IAssemblyName assemblyName, BindingOptions bindingOptions)   at PostSharp.CodeModel.AssemblyRefDeclaration.GetAssemblyEnvelope()   at PostSharp.CodeModel.TypeRefDeclaration.GetTypeDefinition(BindingOptions bindingOptions)   at PostSharp.CodeModel.TypeSpecDeclaration.GetTypeDefinition(BindingOptions bindingOptions)   at PostSharp.Extensibility.Tasks.IndexGenericInstancesTask.Execute()   at PostSharp.Extensibility.Project.ExecutePhase(String phase)   at PostSharp.Extensibility.Project.Execute()   at PostSharp.Extensibility.PostSharpObject.ExecuteProjects()   at PostSharp.Extensibility.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation)   at PostSharp.MSBuild.PostSharpRemoteTask.Execute(PostSharpTaskParameters parameters, TaskLoggingHelper log) WhoCanHelpMe.Web.Controllers

Feb 21, 2011 at 12:51 PM

OK, so the trick was to comment out this line in the Web.Controllers project .csproj file...

<Import Project="..\..\ReferencedAssemblies\PostSharp\PostSharp-1.5.targets" />