I have an ASP.NET Web API hosted in a cloud service web role. I have added a WebRole class extending RoleEntryPoint which is attempting to retrieve an IoC castle Windsor container which has dependencies setup in the StartUp.cs of my web API.I want to then retrieve a logger instance I have registered and use that in my WebRole.
public class WebRole : RoleEntryPoint
{
private ICancellationTokenSourceProvider _cancellationTokenSourceProvider;
public override bool OnStart()
{
try
{
var container = IoC.GetContainer();
_cancellationTokenSourceProvider = container.Resolve<ICancellationTokenSourceProvider>();
}
catch (Exception)
{
throw;
}
return base.OnStart();
}
However when I try to deploy this to the cloud service I get the following exception:
Unhandled Exception: Unable to find assembly 'Castle.Windsor, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc'. at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name) at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable) at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record) at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Bina ry.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream stm) at System.AppDomain.Deserialize(Byte[] blob) at System.AppDomain.UnmarshalObject(Byte[] blob) ' [2020-06-19T16:48:01Z] Last exit time: [2020/06/19, 16:48:05.617]. Last exit code: 0.
I have tried to find the cause and solution to this extensively.
However, I still get this error every time and the web role keeps restarting trying to recover from this exception.
Read your problem description carefully, I think the problem should be in the problem of loading assembly such as MyApi.dll
.
First, because of the limitations of Azure's cloud environment, it may not be possible to load some third-party assemblies. You can refer to this post .
After the Azure Cloud Services service is created, you can get a virtual machine, and you can log in using RDP
. So I suggest that you create your application first, do not contain the code that references the third-party .dll
, to ensure the successful deployment. Then log in with RDP
method to the virtual machine, open cmd
, use the regsvr32 xxx.dll
related command to register the third-party .dll
file in the registry, and then redeploy your complete project now. Check if the problem is solved.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.