question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fsunit assembly is not signed with a strong name

See original GitHub issue

In using fsunit from a strongly-named assembly I get the folllowing error

1) Test Error : TryFsunit.lib1.hello System.IO.FileLoadException : Could not load file or assembly 'FsUnit.NUnit, Version=1.3.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HR ESULT: 0x80131044) at TryFsunit.lib1.hello()

Nunit works fine. It’s just FSunit that isn’t signed. There are many ways to sign an assembly in the FSUnit build process – see msdn article

To reproduce

  1. create a small library project. See (1)
  2. add fsunit from nuget to the project
  3. add any test
  4. sign that library with a strong name. (There are many ways to do that. I used the <OtherFlags>--keyfile:SomeSignature.snk</OtherFlags> method in the .fsproj). See (2)
  5. build with msbuild
  6. run from command line “nunit-console.exe”
  7. you will see the above error “Could not load file or assembly ‘FsUnit.NUnit’…A strongly-named assembly is required.”

(1) Sample library1.fs fragment

let add a b = a + b
// this fails at test runtime
[<Test>] 
let hello2() = add 2 3 |> should equal 5
// This works, which means: nunit is strong signed. But fsunit is not. 
[<Test>] 
let hello() =
    let n = add 2 3
    Assert.That(n,Is.EqualTo(5))

(2) Sample .fsproj file fragment with <OtherFlags>

<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <OutputType>Library</OutputType>
  ....
  <OtherFlags>--keyfile:SignKeyLifeQuest.snk</OtherFlags>
</PropertyGroup>

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sergey-tihoncommented, Aug 18, 2016

As workaround you can include FsUnit.fs or FsUnitTyped.fs file to your test project and do not reference FsUnit package.

1reaction
jwittnercommented, Aug 17, 2016

In order to expose internal types for testing to assemblies via the InternalsVisibleTo attribute from a signed assembly, those assemblies must also be signed. Right now I can’t do that =(.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix "Referenced assembly does not have a strong ...
If you don't find the .snk-file: Open the project properties (of the project using the project with the "strong name" error), tab Signing....
Read more >
How to: Disable the strong-name bypass feature | ...
Strong-name bypass skips signature validation in fully trusted domains in .NET. You can override this feature for a single application or ...
Read more >
Create and use strong-named assemblies
This article shows you the process of signing an assembly in .NET with a strong name and later referencing it by that name....
Read more >
How to Assign a Strong Name to Unsigned 3rd-party ...
This will allow you to reference and use NuGet packages with assemblies which are not strong named from your projects that do use...
Read more >
What is FsUnit?
FsUnit is a set of libraries that makes unit-testing with F# more enjoyable. It adds a special syntax to your favorite .NET testing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found