Hello,
I’m developing a CodeActivity wrapper for a UriBuilder. I created a new .NET Framework 4.5.2 library and added the System.Activities
and System.ComponentModel
references as specified in the guide.
Now that I have a functional class, which I named UrlBuilder
so as to avoid a namespace collision, I created an xUnit test library and created a simple test as follows:
[Theory]
[InlineData("www.google.com")]
[InlineData("www.duckduckgo.com")]
public void NoOverridesTest(string website)
{
var activity = new UriBuilderActivity();
var input = new Dictionary<string, object>
{
{ nameof(UriBuilderActivity.Url), website }
};
var output = WorkflowInvoker.Invoke(activity, input);
Assert.Equal(website, output.Host);
Assert.Equal("/", output.PathAndQuery);
}
When executing this unit test, it throws the following exception:
Test Name: UrlBuilder.Tests.UriBuilderActivityTests.NoOverridesTest(website: "www.duckduckgo.com")
Test FullName: UrlBuilder.Tests.UriBuilderActivityTests.NoOverridesTest
Test Source: C:\Users\me\source\repos\UrlBuilder.Tests\UriBuilderActivityTests.cs : line 14
Test Outcome: Failed
Test Duration: 0:00:00.001
Result StackTrace:
at UrlBuilder.Tests.UriBuilderActivityTests.NoOverridesTest(String website)
----- Inner Stack Trace -----
Result Message:
System.BadImageFormatException : Could not load file or assembly 'System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
---- System.BadImageFormatException : Cannot load a reference assembly for execution.
As you can see, it’s not a very useful stacktrace. Line 14 is merely the method declaration for my unit test, so it’s failing fairly early or else the exception isn’t bubbling up properly. I’d initially taken this to a chat group where I’d discussed my issues with a Microsoft developer who was surprised anyone was using WWF. He was unsure how to resolve my issue besides potentially changing .NET versions. I tried 4.6.1 but this saw no change.
Where can I go from here? StackOverflow is devoid of similar issues and there is one similar issue here but it’s unanswered and deals with a different part of the workflow.
Any ideas would be appreciated.
Thank you,
Devin