Strange error in Quartz: Quartz.XmlSerializers not found - c#

I am getting the following error in Quartz.net
The assembly with display name 'Quartz.XmlSerializers' failed to load
in the 'LoadFrom' binding context of the AppDomain with ID 1. The
cause of the failure was: System.IO.FileNotFoundException: Could not
load file or assembly 'Quartz.XmlSerializers, Version=2.0.1.100,
Culture=neutral, PublicKeyToken=null' or one of its dependencies. The
system cannot find the file specified.
It's very odd since Quartz.XmlSerializers does not exist anywhere in any code I'm using. It's not in the Quartz source code, my code, and none of my dependencies best I can tell. It only occurs when I debug my project, but not when I download the Quartz 2.0.1 source code and run the server from there.
I am using topshelf as the service install library.
It occurs during deserialization on line 226 of XMLSchedulingDataProcessor.cs of the Quartz source.
// deserialize as object model
System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(QuartzXmlConfiguration20));
Any clue to solving this would be helpful as I'm stumped by this error.

In applications that use XmlSerialization, you can get a first-chance exception in outside code when the application looks for a cached serialization assembly. You can find more information in this question.

Related

How do you create a Debugger Visualizer in VS 2019 for .netcore 3.1

I have a debugger visualizer working for my NETFX 4.7.2 code. I am porting it to .netcore 3.1. I try to run the visualizer and I get the following error: Unable to load the custom visualizer
Additional information:
Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. An attempt was made to load a program with an incorrect format.
I have tried porting the visualizer code to .netcore and I hit several problems using System.Windows.Form, using Microsoft.VisualStudio.DebuggerVisualizers no longer work and I don't know what reference to include.
I have looked around but I can't seem to find anything to guide me as to what to do to port my visualizer or get the existing one to work. I'm hoping someone here can give me a thread to pull on.
Thanks,

Could not load file or assembly 'Microsoft.Bot.Builder.Autofac,

My Bot ran fine just yesterday, and without changing anything, for some reason it gives the following error:
Exception while executing function: Functions.messages -> One or more errors
occurred. -> Could not load file or assembly 'Microsoft.Bot.Builder.Autofac,
Version=3.12.2.4, Culture=neutral, PublicKeyToken=31bf3856ad364f39' or one
of its dependencies. The system cannot find the file specified.
I have no idea why it is suddenly happening, without any changes.
Please help..
Assuming you are using Functions v2, this could be the reason for "worked yesterday, not today anymore":
https://github.com/Azure/app-service-announcements/issues/106
This also describes how to revert back to a previous version which should fix it.
Further discussions: https://github.com/Azure/app-service-announcements-discussions/issues/46

Failure compiling Workflow Definition

I'm getting this following error when try to load a workflow from its definition:
Compilation failures occurred:
Line 0: Unable to load assembly 'PI.Shared.WF.Activities.Tests'. Line 581: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Complete results are contained in the Data property of this exception. Please correct the errors in the source and retry the Load.
My code simple loads it from a byte[] memory stream that is the content of the XAML file.
What should it do? This 'PI.Shared.WF.Activities.Tests' project is just a class library that I use to draw the workflows. After that, the file itself is serialized into a byte[] and save on azure storage. When we need to load it, just get the byte[] and pass to:
activity = ActivityXamlServices.Load(new MemoryStream(workflowDefinition.Definition), settings);
Where definition is the byte[] with the file data.
What should I possibly being missing? The 'PI.Shared.WF.Activities.Tests' is not even used anyway inside the Workflow host application.
Thanks
Found the problem. It is the PCL libraries that is using fake/facade assemblies that redirects to mscorlib after 4.5 framework and workflow compiler doesn't know(yet) about this.
Have a look on this issue on MS Connect, and there is a workaround there:
http://connect.microsoft.com/VisualStudio/feedback/details/800070/pcl-reference-in-a-workflow-project-destroys-intellisense

Re-named assembly, application won't build

I renamed my WPF application's assembly from DBce_TEST2 to AMS, then attempted to build it to see what would happen. I ran it, and it wouldn't build for obvious reasons but now after renaming it back to DBce_TEST2 I get the following error:
Managed Debugging Assistant 'BindingFailure' has detected a problem in 'G:\C# Projects\Asset Management System\DBce_TEST2\bin\Debug\DBce_TEST2.vshost.exe'.
Additional Information: The assembly with display name 'AMS' failed to load in the 'Load' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'AMS' or one of its dependencies. The system cannot find the file specified.
The error can be fishy. Use Fusion log viewer to understand what has gone wrong.
How to enable assembly bind failure logging (Fusion) in .NET
Figured it out. Renamed the assembly again to some random text, attempted to run it, then renamed back to original assembly name and the error disappeared. Guess some generated files were messed up by visual studio a little bit, and this fixed it.

ILMerge: How to merge Azure runtime library?

I'm trying to use ILMerge to create a single executable that uses Windows Azure SDK 2.0 including the Microsoft.WindowsAzure.ServiceRuntime.dll, which I added manually because I couldn't find any NuGET package that contains it.
I'm using the following command line on a VS2012 post-build event:
/wildcards /targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0" /log:ILMerge.log /closed Output.exe *.dll /out:Executable.exe
However, I'm getting the following error in ILMerge.log, even though the output window reports no issues at all after building:
The assembly 'Microsoft.WindowsAzure.ServiceRuntime' was not merged in correctly. It is still listed as an external reference in the target assembly.
An exception occurred during merging:
ILMerge.Merge: The assembly 'Microsoft.WindowsAzure.ServiceRuntime' was not merged in correctly. It is still listed as an external reference in the target assembly.
at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)
And then the executable throws the following exception when opened:
System.Reflection.TargetInvocationException: Exception has been thrown by the
target of an invocation. ---> System.IO.FileNotFoundException: Could not load file
or assembly 'msshrtmi, Version=2.0.0.0, Culture=neutral, publicKeyToken=31bf3856ad364e35'
or one of its dependencies.
I have also tested the same output without merging and it works fine.
What am I missing here?
It would seem like this cannot be done, or at least not how I want it done.
Microsoft.WindowsAzure.ServiceRuntime.dll seems to have a dependency on the native library msshrtmi.dll. This means that ILMerge cannot handle it, since unmanaged code cannot be merged with managed code.
According to these two questions there is a way to work around this problem, but it involves packaging the msshrtmi.dllas a resource and unpacking it when it's needed. I feel it's kinda hacky.
So I guess I'll just have to do what I should have done before: remove all references to Microsoft.WindowsAzure.ServiceRuntime.dll from the project that builds the merged, non-Azure version of my WCF service. This might involve using some IoC container and doing some heavy refactoring, which is why I was trying to avoid it at this stage.

Categories