Hello,

I reproduced my problem by these steps (version 4.3.1 build 5680):

  1. Xtensive.Storage.Samples.Upgrade.Version1 = is signed with "Delay sign only"
  2. Xtensive.Storage.Samples.Common = is signed without "Delay sign only"
  3. Build or run

You obtain this exception:

Error   3   PostSharp.Sdk.CodeModel.AssemblyLoadException: Error while loading the assembly "C:\Users\Public\Documents\DataObjects.Net\Samples\Xtensive.Storage.Samples.Upgrade.Version1\obj\Debug\Before-PostSharp\Xtensive.Storage.Samples.Upgrade.Version1.exe": Could not load file or assembly 'Xtensive.Storage.Samples.Upgrade.Version1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=52fa04a277708b7a' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)
===== Start of PostSharp Assembly Binder ===========================
LOG: (ClrHost) GetAssemblyName: {C:\Users\Public\Documents\DataObjects.Net\Samples\Xtensive.Storage.Samples.Upgrade.Version1\obj\Debug\Before-PostSharp\Xtensive.Storage.Samples.Upgrade.Version1.exe}
LOG: Loading assembly from file {C:\Users\Public\Documents\DataObjects.Net\Samples\Xtensive.Storage.Samples.Upgrade.Version1\obj\Debug\Before-PostSharp\Xtensive.Storage.Samples.Upgrade.Version1.exe}.
LOG:    NativeDotNet20Platform.LoadAssemblyFromFile: C:\Users\Public\Documents\DataObjects.Net\Samples\Xtensive.Storage.Samples.Upgrade.Version1\obj\Debug\Before-PostSharp\Xtensive.Storage.Samples.Upgrade.Version1.exe.
LOG:    (ClrHost) GetAssemblyName: {C:\Users\Public\Documents\DataObjects.Net\Samples\Xtensive.Storage.Samples.Upgrade.Version1\obj\Debug\Before-PostSharp\Xtensive.Storage.Samples.Upgrade.Version1.exe}
LOG:    Assembly identity returned by the host: xtensive.storage.samples.upgrade.version1, version=1.0.0.0, culture=neutral, publickeytoken=52fa04a277708b7a, processorarchitecture=msil.
LOG:    Assembly 'xtensive.storage.samples.upgrade.version1, version=1.0.0.0, culture=neutral, publickeytoken=52fa04a277708b7a, processorarchitecture=msil' is not yet loaded in the AppDomain.
LOG:    Invoking Assembly.Load({xtensive.storage.samples.upgrade.version1, version=1.0.0.0, culture=neutral, publickeytoken=52fa04a277708b7a, processorarchitecture=msil})
LOG:    (ClrHost) ProvideAssembly: "xtensive.storage.samples.upgrade.version1, version=1.0.0.0, culture=neutral, publickeytoken=52fa04a277708b7a, processorarchitecture=msil".
LOG:    Finding the assembly with binding identity 'xtensive.storage.samples.upgrade.version1, version=1.0.0.0, culture=neutral, publickeytoken=52fa04a277708b7a, processorarchitecture=msil'.
LOG:    Location found from cache: 'C:\Users\Public\Documents\DataObjects.Net\Samples\Xtensive.Storage.Samples.Upgrade.Version1\obj\Debug\Before-PostSharp\Xtensive.Storage.Samples.Upgrade.Version1.exe'.
LOG:    (ClrHost) ProvideAssembly: "xtensive.storage.samples.upgrade.version1, version=1.0.0.0, culture=neutral, publickeytoken=52fa04a277708b7a, processorarchitecture=msil": assembly found in search path.
LOG:    (ClrHost) ProvideAssembly: "xtensive.storage.samples.upgrade.version1, version=1.0.0.0, culture=neutral, publickeytoken=52fa04a277708b7a, processorarchitecture=msil": located in "C:\Users\Public\Documents\DataObjects.Net\Samples\Xtensive.Storage.Samples.Upgrade.Version1\obj\Debug\Before-PostSharp\Xtensive.Storage.Samples.Upgrade.Version1.exe".
LOG:    (ClrHost) ProvideAssembly: "xtensive.storage.samples.upgrade.version1, version=1.0.0.0, culture=neutral, publickeytoken=52fa04a277708b7a, processorarchitecture=msil": returned successfully.
LOG:    AssemblyLoadException: Could not load file or assembly 'Xtensive.Storage.Samples.Upgrade.Version1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=52fa04a277708b7a' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)
LOG:    Loaded: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' from 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll'.
LOG:    Loaded: 'PostSharp.Hosting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'C:\Program Files (x86)\DataObjects.Net\Lib\PostSharp\Release\PostSharp.Hosting.dll'.
LOG:    Loaded: 'PostSharp.Sdk, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'C:\Program Files (x86)\DataObjects.Net\Lib\PostSharp\Release\PostSharp.Sdk.dll'.
LOG:    Loaded: 'PostSharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'C:\Program Files (x86)\DataObjects.Net\Lib\PostSharp\Release\PostSharp.dll'.
LOG:    Loaded: 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' from 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'.
LOG:    Loaded: 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' from 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'.
LOG:    Loaded: 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' from 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'.
LOG:    Loaded: 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' from 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'.
LOG:    Loaded: 'PostSharp.Sdk.XmlSerializers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'C:\Program Files (x86)\DataObjects.Net\Lib\PostSharp\Release\PostSharp.Sdk.XmlSerializers.dll'.

======Exception Details ============================================
System.IO.FileLoadException: Could not load file or assembly 'Xtensive.Storage.Samples.Upgrade.Version1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=52fa04a277708b7a' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)
File name: 'Xtensive.Storage.Samples.Upgrade.Version1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=52fa04a277708b7a' ---> System.Security.SecurityException: Strong name validation failed. (Exception from HRESULT: 0x8013141A)
The Zone of the assembly that failed was:
MyComputer
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at PostSharp.Hosting.NativeDotNet40Platform.LoadAssemblyImpl(IAssemblyName assemblyName)
   at PostSharp.Hosting.NativeDotNetPlatform.LoadAssemblyImpl(String fileName, IAssemblyName assemblyName)
   at PostSharp.Hosting.NativeDotNetPlatform.LoadAssemblyFromFile(String fileName)
   at PostSharp.Sdk.CodeModel.AssemblyLoadHelper.LoadAssemblyFromFile(String fileName)

====================================================================

Server stack trace: 
   at PostSharp.Sdk.CodeModel.AssemblyLoadHelper.^sl7vYpr7(String _0, Exception _1)
   at PostSharp.Sdk.CodeModel.AssemblyLoadHelper.LoadAssemblyFromFile(String fileName)
   at PostSharp.Sdk.Extensibility.ModuleLoadReflectionFromFileStrategy.LoadAssembly()
   at PostSharp.Sdk.Extensibility.ModuleLoadReflectionStrategy.Load(Domain domain)
   at PostSharp.Sdk.Extensibility.Project.^LvMUl75+(ModuleLoadStrategy _0)
   at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at PostSharp.Hosting.IPostSharpObject.InvokeProject(ProjectInvocation projectInvocation)
   at PostSharp.Hosting.Program.ExecuteImpl()   C:\Users\Public\Documents\DataObjects.Net\Samples\Xtensive.Storage.Samples.Upgrade.Version1\POSTSHARP   Xtensive.Storage.Samples.Upgrade.Version1

Any suggestions how to fix it?

Have a nice day.

Tomas Bako


Updated at 29.07.2010 6:24:32

Hi.

Analogy of my problem:

In other forum thread i had problem with signing assemblies http://forum.x-tensive.com/viewtopic.php?f=29&t=5991. In this posts you suggested me to sign assemblies with delayed sign only.

I have two developer computers:

  1. At home : Signing delayed or not is not working. Both types of signing throw exceptions when I try to build the model assembly. Therefore I'm forced to use DO without any signing.

2. At work : Signing without delayed sign works perfectly without problems. When I try delayed signing, exception is thrown from previous posts.

I would like to be able build same project on both computers. In actual situation i must switching between signing according to where I'm actually developing.

It doesn't matter if I'm big company or freelancer developer, I just want to my assemblies be signed.

That's all.

Tomas B.

This thread was imported from our support forum. The original discussion may contain more detailed answer. Original topic by bakotomas.

asked Jul 28 '10 at 11:49

Editor's gravatar image

Editor
46137156157

edited Sep 03 '10 at 15:43

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

Do you get this exception during its processing by PostSharp? If so, this is probably a PostSharp issue. I'll forward this issue to PostSharp team.

(Jul 28 '10 at 11:49) Alex Yakunin Alex%20Yakunin's gravatar image

One Answer:

psulek wrote:

Alex, even if this error occurs when postsharp processing you need to take care of it, because yours product (DO4) uses this PostSharp and this error occurs when DO4 model library is compiled. I think if SharpCrafters have some recommendations in some special situations like this (signing with keys) you should mention it somewhere in manual of DO4, dont you think?


psulek wrote:

Okay then, because lets image one real-life situation (not my situation). Company trying your product, run yours sample, reading manual, etc... Then decide that DO4 is good product to use in company product. Creating new projects with 'DO4 data model' libraries, etc... Running new projects and everything works perfect. And then, hey turn on projects to sign with strong keys and booo it does not even compile project. Company spent money on DO4 licence, on time when building new projects upon DO4 (data model) and now all is lost because with strong key signing it does not work and company rules does not allow to have projects without sign libraries. I know you have too many other problems, but i think this problem with signing assemblies is BIG problem also for new customers of DO4.


Alex (Xtensive) wrote:

Wait, signatures work (e.g. our own assemblies are signed).

The issue is related to usage of "delay sign" option - AFAIK, it is used much more rarely. So it's a problem, but not a big one:

  • Gael already published a solution for PostSharp CLI. But I'm waiting for a solution for our own case (we use PostSharp.targets).

  • There is a set of other workarounds. You can use e.g. http://signer.codeplex.com/ (Googled this almost immediately).


psulek wrote:

Wait, signatures work (e.g. our own assemblies are signed). The issue is related to usage of "delay sign" option...

I dont think this is related only to "delay sign", errors was there before enabling "delay sign" as i remember. Must create some sample for your if this is true.


Alex (Xtensive) wrote:

Sorry, initially I haven't understood the problems are related. Anyway, Gael fully explained the solution. You should invoke Sn.exe tool once to disable verification for your assembly with delay sign:

sn –Vr myAssembly.dll

See also: http://msdn.microsoft.com/en-us/library/t07a3dye.aspx

answered Jul 28 '10 at 18:17

Editor's gravatar image

Editor
46137156157

Update: we'll wait while Gael will try to reproduce the issue. If this won't help, we'll try to reproduce the problem by our own.

(Jul 28 '10 at 18:17) Alex Yakunin Alex%20Yakunin's gravatar image

Actually, I was not aware about this issue at all... Yes, we should - the only problem is time. I agree we must build something like FAQ in Manual - at least, with links to this forum.

(Jul 28 '10 at 18:17) Alex Yakunin Alex%20Yakunin's gravatar image

To fully clarify this: we care about all the interaction with PostSharp team in each case - i.e. I didn't try to say "ask them by your own".

I gave the link here mainly to allow the author to get the information faster.

(Jul 28 '10 at 18:17) Alex Yakunin Alex%20Yakunin's gravatar image

Please notify us, if the proposed solution helped...

(Jul 28 '10 at 18:17) Alex Yakunin Alex%20Yakunin's gravatar image

bakotomas wrote: Hello,

sorry for long response. Your suggested steps didn't solve the problem. Same exception was thrown.

Tomas

(Jul 28 '10 at 18:17) Editor Editor's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA