Postsharp get "Ambiguous assembly binding policies" error [closed] - unity-container

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
When I add Postsharp (5.0.44) to one of my project, I get this error when compile it, after checking I see Postsharp has problem with Unity (v4.0.30319), updated Unity to version 5 and problem solved, but another problem is my other project using Prism.Wpf (v6) and this lib is not compatible with Unity v5, so I get deadlock now.
Actually I got same error ("Ambiguous assembly binding policies") before with Prism.Core (v6) but solved with v7.
Because I'm using 3 libs and they don't work together so I don't know where I should raise issue ticket, then I just ask if there is any workaround.
By the way, my projects use .Net Framework 4.6.1.
Here is full log
Severity Code Description Project File Line Suppression State
Error Unhandled exception (postsharp-net40-x86-srv.exe release | .NET Framework 4.7.1): PostSharp.Sdk.CodeModel.BindingException: Ambiguous assembly binding policies: Assembly 'system.runtime, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a' redirects both to 'system.runtime, version=4.1.2.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a' and 'system.runtime, version=4.0.20.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a'.
at PostSharp.Sdk.CodeModel.AssemblyBindingPolicyManager.EvaluatePolicy(IAssemblyName assemblyName, Boolean evaluateSystemPolicies)
at PostSharp.Sdk.CodeModel.CompareExtensions.^4+F3cylo(IAssemblyName _0, IAssemblyName _1, AssemblyBindingPolicyManager _2, BindingOptions _3, Boolean _4)
at PostSharp.Sdk.CodeModel.ModuleDeclaration.FindAssembly(IAssemblyName assemblyName, BindingOptions bindingOptions)
at PostSharp.Sdk.CodeModel.ModuleDeclaration.^nQbUijLO(String _0, IAssemblyName _1, BindingOptions _2)
at PostSharp.Sdk.CodeModel.ModuleDeclaration.FindType(Type reflectionType, BindingOptions bindingOptions)
at PostSharp.Sdk.CodeModel.DeclarationCache.^pFnf8wEt()
at PostSharp.Sdk.CodeModel.TypeRefDeclaration.get_TypeIdentifier()
at PostSharp.Sdk.CodeModel.CompareExtensions.DefinitionMatchesReference(INamedType definition, INamedType reference, BindingOptions options)
at PostSharp.Sdk.CodeModel.TypeRefDeclaration.^A9yFoe2uB3TC(ITypeSignature _0, BindingOptions _1)
at PostSharp.Sdk.CodeModel.TypeRefDeclaration.MatchesReference(ITypeSignature reference)
at PostSharp.Sdk.CodeModel.Collections.CustomAttributeDeclarationCollection.Contains(IType type)
at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.^SgrhoGlQ(AssemblyRefDeclaration _0)
at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.^+GwnKh4ZYHu3()
at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.Execute()
at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)
at PostSharp.Sdk.Extensibility.Project.Execute()
at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation).

Related

Could not load file or assembly Microsoft.VisualStudio.DevOps.Contract

I'm trying to publish a .NET Core (3.1) Web Application for the first time in Visual Studio 2019 and I get the error:
System.BadImageFormatException: Could not load file or assembly 'Microsoft.VisualStudio.DevOps.Contract, Version=15.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The module was expected to contain an assembly manifest.
File name: 'Microsoft.VisualStudio.DevOps.Contract, Version=15.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.BadImageFormatException: Could not load file or assembly 'Microsoft.VisualStudio.DevOps.Contract, Version=15.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The module was expected to contain an assembly manifest.
File name: 'Microsoft.VisualStudio.DevOps.Contract, Version=15.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
at Microsoft.Publish.Framework.ViewModel.ProfileSelectorViewModel.FetchContinuousDeliveryService()
at Microsoft.Publish.Framework.ViewModel.ProfileSelectorViewModel.InitializeContinuousDelivery()
at Microsoft.Publish.Framework.ViewModel.ProfileSelectorViewModel..ctor(IThreadSwitcher threadSwitcher, IPublishServiceProvider serviceProvider, IVsHierarchy hierarchy, ITelemetryProvider telemetryProvider, IVsWrappersFactory vsWrappersFactory, IReadOnlyList`1 providers, IFeatureManager featureDetectionManager, IProfileController profileController, IDependenciesManagerProvider dependenciesManagerProvider)
at Microsoft.Publish.Framework.Provider.DefaultPublishTabProvider.CreateViewAsync(IVsHierarchy project, IAsyncServiceProvider serviceProvider, CancellationToken cancellationToken)
at Microsoft.Publish.Framework.Provider.PublishProjectDesignerTabProvider.<CreateViewAsync>d__7.MoveNext()
The publish window seems to not be fully drawn out in VS 2019 afterward. Any ideas out there?
I've found an answer to this issue and I'm posting it here. I reinstalled VS2019. I may have missed installing key components during original installation, such as Azure, I'm uncertain on that detail.

ThinkTecture.IdentityModel "The type 'System.IdentityModel.Tokens.SecurityToken' is defined in an assembly that is not referenced

I start using ThinkTecture.IdentityModel in my project and I am facing a serious issue. Please help me on the same.
Error 1 "The type 'System.IdentityModel.Tokens.SecurityToken' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Try manually adding the System.IdentityModel dll reference from the assemblies. This is what worked for me.
-Right click project, add reference
-Assemblies, Framework, System.IdentityModel v4.0.0.0

How can I find out why an assembly is required in ASP.Net MVC4 project?

I am trying to deploy my ASP.Net MVC4 application to Azure but it is crashing during deployment. Apparently this is because something is requesting assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' . This all works perfectly locally and is a nightmare to debug on Azure as deployment takes 25-30 minutes for me.
I had thought I had configured CLR to not require MVC3 even if something wanted it by using:
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
If I look at the ObjectBrowser nothing seems to be requiring MVC3. What is the best way to figure out what is requesting it? I have various Nuget packages in the project. I guess one of them is requesting MVC3? Is there anyway to see a list of all dependencies etc?
I get:
CLR exception type: System.Reflection.ReflectionTypeLoadException
"Unable to load one or more of the requested types. Retrieve the
LoaderExceptions property for more information."
Microsoft.WindowsAzure.ServiceRuntime Critical: 201 : ModLoad:
000007fc906a0000 000007fc907a9000
D:\Windows\Microsoft.NET\Framework64\v4.0.30319\diasymreader.dll Role
entrypoint could not be created: System.TypeLoadException: Unable to
load the role entry point due to the following exceptions:
-- System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040) File name:
'System.Web.Mvc, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'
WRN: Assembly binding logging is turned OFF. To enable assembly bind
failure logging, set the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There
is some performance penalty associated with assembly bind failure
logging. To turn this feature off, remove the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog].
---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property
for more information. at
System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at
System.Reflection.RuntimeModule.GetTypes() at
System.Reflection.Assembly.GetTypes() at
Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly
entryPointAssembly) --- End of inner exception stack trace ---
at
Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly
entryPointAssembly) at
Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CreateRoleEntryPoint(RoleType
roleTypeEnum) at
Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType
roleTypeEnum) ModLoad: 000007fca2f00000 000007fca2f96000
D:\Windows\SYSTEM32\clbcatq.dll ntdll!ZwTerminateProcess+0xa:
000007fc`a2fa2eaa c3 ret
and
Exception object: 00000000017e0070 Exception type: System.TypeLoadException Message: Unable to load the role
entry point due to the following exceptions:
-- System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040) File name:
'System.Web.Mvc, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'
WRN: Assembly binding logging is turned OFF. To enable assembly bind
failure logging, set the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There
is some performance penalty associated with assembly bind failure
logging. To turn this feature off, remove the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog].
InnerException: System.Reflection.ReflectionTypeLoadException, Use
!PrintException 00000000017dcf08 to see more. StackTrace (generated):
StackTraceString: HResult: 80131522
You can use Reflector to load the Nuget packages and look at their dependencies. Should be fairly easy to spot whether one is dependent upon MVC3. Your assembly binding looks fine though. Do you have multiple projects in your solution? Could one of those be taking a dependency on a Nuget package that depends on MVC3?
This post may help: How can I build a 'dependency tree diagram' from my .NET solution

Could not load file or assembly 'MySql.Data, Version=6.3.6.0

I'm at a COMPLETE loss - I'm having super wierd issues with what I still really dont even understand... I'm running Entity Framework 4.1, MySql 5.xx and my MySql Connector is v 6.4.4 - everything works beatifully locally however whenever I upload to the server I receive:
Could not load file or assembly 'MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
Line 48: /// Initializes a new proventradesEntities object using the connection string found in the 'proventradesEntities' section of the application configuration file.
Line 49: /// </summary>
Line 50: public proventradesEntities() : base("name=proventradesEntities", "proventradesEntities")
Line 51: {
Line 52: this.ContextOptions.LazyLoadingEnabled = false;
Source File: e:\web\proventrade\htdocs\App_Code\ProvenTrades.Designer.cs Line: 50
Assembly Load Trace: The following information can be helpful to determine why the assembly 'MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
I am SO confused, I am positive that I have MySql 6.4.4 dll's in my Bin directory, also my Web.config makes ZERO references to version 6.3.6 - I've searched my entire project (using global find) for 6.3.6 and even just for MySql to see if I can find ANY random references to this rogue 6.3.6 version but I find nothing!
I'm so lost and am getting no where. I would GREATLY appreciate any guidance on this, thanks so much in advance.
You must add provider library to bin directory in your web application and register provider in your web.config
Then You must download Connector .Net Mono here.
And put Dlls into bin folder.

Issue when running a newly created project in siteinfinity 4.4 project manager

I am facing an issue when running a newly created project in siteinfinity 4.4 project manager :
Issue log :
Could not load file or assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Stack trace:
at Telerik.Utilities.Cassini.Server.<>c__DisplayClass2.<Start>b__1(Object )
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWork Item()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Any idea will be appreciated?
Comment if any detail is required.
Do you have the full asp.net installed and registered? Even though it is self-contained, I believe that Cassini still requires that the full framework be installed to run.

Resources