Mindscape.Raygun4Net.Signed vs. Mindscape.Raygun4Net.Core

David Peden

Posted on
Jan 31 2015

I recently updated my Raygun packages (Mindscape.Raygun4Net.Mvc and Mindscape.Raygun4Net.WebApi) to latest (4.2.0 as of this post). I then discovered (happily) that there is a Raygun sink for Serilog (https://github.com/serilog/serilog/tree/dev/src/Serilog.Sinks.Raygun). I installed this package as well.

I have an app hosted in Azure. Upon deployment, my worker role started recycling. I finally discovered that the reason was because I was getting an assembly load failure:

System.IO.FileLoadException: Could not load file or assembly 'Mindscape.Raygun4Net, Version=2.0.4.0, Culture=neutral, PublicKeyToken=f5cf1837249ec424' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I checked the app.config in my worker role and noticed that there was not a binding redirect which explained why I am getting the exception. At first I thought it might be an issue with Serilog. I looked at their source and see that they are properly referencing Mindscape.Raygun4Net.Signed. Interestingly (and confusingly), Mindscape.Raygun4Net.Mvc and Mindscape.Raygun4Net.WebApi do not.

The implication is that NuGet doesn't know that it needs to create a binding redirect because the referenced assemblies are not the same.

What is the reasoning behind this?

Also, I tried to manually add a binding redirect to point at Mindscape.Raygun4Net.Signed but it failed because the PublicKeyToken is obviously not the same.

How do I resolve this issue?


Jason Fauchelle

Raygun

Posted on
Feb 04 2015

Hi David,

I see that you've updated the Serilog Raygun sink to the latest version of Raygun. Did this solve the issue? On that note, The dependency listed in the NuSpec may also need to be updated: https://github.com/serilog/serilog/blob/dev/src/Serilog.Sinks.Raygun/Serilog.Sinks.Raygun.nuspec#L15 I installed the NuGet package which installed version 2.0.4 of Raygun, and then complained that it couldn't find version 4.2.0

The Raygun4Net.Signed package is just a strong-named signed version of the standard Raygun4Net package. The Mvc, WebApi and Signed packages are top level packages that should not depend on each other. They each provide Raygun support for the different .NET platforms (Mvc, WebApi, and just about everything else).

If the issue that you posted is still a problem, it is most likely because the Signed (and standard) Raygun4Net packages are not compatible with the Mvc package. This is because they have a couple of classes with the same name and namespace. This is something that we are currently looking at resolving in version 5.

Please let me know if you have questions about any of this.

-Jason Fauchelle


Mike

Posted on
Apr 06 2015

I have the same problem like the OP . Only I'm using ver 5.0.0 of raygun client. Serilog still wants version 4.2.0 and I can't config binding redirect because the public token of ver 4.2.0 is different from version 5.0.0 . I think it's the fault of serilog though


andrewjknox

Posted on
Apr 13 2015

@Mike - had the same issue but simply running

Install-Package Mindscape.Raygun4Net.Signed -Version 4.2

sorted it out for me by removing v5 and installing the 4.2

Cheers, Andrew


Rodh257

Posted on
Jun 11 2015

I'm having an issue now on the latest versions

Could not load file or assembly 'Mindscape.Raygun4Net4, Version=5.0.1.0, Culture=neutral, PublicKeyToken=002e1b57394fa9b9' or one of its dependencies. The system cannot find the file specified.

Versions I've got installed:

package id="Mindscape.Raygun4Net" version="5.0.2" targetFramework="net451" /> package id="Mindscape.Raygun4Net.Core" version="5.0.2" targetFramework="net451" /> package id="Mindscape.Raygun4Net.Signed" version="5.0.2" targetFramework="net451" /> package id="Mindscape.Raygun4Net.WebApi" version="5.0.2" targetFramework="net451" /> package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" /> package id="OctoPack" version="3.0.42" targetFramework="net451" /> package id="Serilog" version="1.5.6" targetFramework="net451" /> package id="Serilog.Sinks.Raygun" version="1.5.6" targetFramework="net451" />

I have the binding redirect:

  <dependentAssembly>
    <assemblyIdentity name="Mindscape.Raygun4Net4" publicKeyToken="002e1b57394fa9b9" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.0.2.0" newVersion="5.0.2.0" />
  </dependentAssembly>

Any ideas?


Jamie Penney

Posted on
Jun 11 2015

Hey Rod,

Don't install Raygun4Net.Core directly - it's a common package that has base classes the others pull from. It should be marked as private (not directly installable) but due to a bug in NuGet 3.0 we had to make it visible to search.

You probably want to install Raygun4Net, Raygun4Net.MVC, or Raygun4Net.WebApi.

Cheers, Jamie


Rodh257

Posted on
Jun 11 2015

Hi Jamie,

I haven't installed core directly, I've only installed WebAPI and also Serilog.Sinks.Raygun (which is what caused this problem).

No matter what bindings, specific version installations etc I try, I just can't get the serilog sink to work. There's always some compilation or binding error. Latest one is: Error 4 The type 'Mindscape.Raygun4Net.RaygunClientBase' is defined in an assembly that is not referenced. You must add a reference to assembly 'Mindscape.Raygun4Net, Version=5.0.2.0, Culture=neutral, PublicKeyToken=null'.

Which is weird as I have Version 5.0.2.0 installed.

Think I'll just bail out on the serilog sink for now.


Jamie Penney

Posted on
Jun 11 2015

If you uninstall Serilog.Sinks.Raygun and just run Raygun4Net.WebApi, do you still get the error? Just wondering where the broken binding is coming from.


Rodh257

Posted on
Jun 11 2015

Raygun works fine without the serilog sink, might be because of the signed package? Not sure, but perhaps this isn't the best place to ask about serilog sink errors, I just found this thread and replied to it :)


Jamie Penney

Posted on
Jun 11 2015

Hmmm, I guess if Serilog.Sink is built against the signed package it might not work with the binding redirect? Honestly I've not dealt with Signed packages for a while, I'll have a chat to Jason when he gets in tomorrow and see if he knows what might be going wrong.


Mike

Posted on
Jun 12 2015

At one point my solution was to recompile the serilog sink against the proper raygun/serilog core versions. I've submitted a PR for the serilog sink and it was accepted after a while, but in the meantime I think that a new version of serilog was released so it might not work properly. I'll give it a try these days and if it doesn't work, then it's back to maintaining my own branch of serilog.raygun .


Jamie Penney

Posted on
Jun 12 2015

Right, looks like they're building signed a package. I'm guessing that it's running into problems because the WebApi package pulls down the unsigned version of Raygun4Net, and the signed version has everything in one assembly instead of using Core.

I think you should see if the Serilog.Sinks team will create an unsigned version of their package that depends on the regular Raygun4Net package. That would solve this issue.


Nick Dunets

Posted on
Jun 30 2015

Same problem with most recent 5.1.0:

<package id="Mindscape.Raygun4Net.Core" version="5.1.0" targetFramework="net45" />
  <package id="Mindscape.Raygun4Net.WebApi" version="5.1.0" targetFramework="net45" />
  <package id="Mindscape.Raygun4Net.Signed" version="5.1.0" targetFramework="net45" />

gives : Could not load file or assembly 'Mindscape.Raygun4Net, Version=5.1.0.0, Culture=neutral, PublicKeyToken=20dddfb3684a7aa5' or one of its dependencies.

I need both WebApi and Signed in one API project - because Signed is needed for another strong-name assembly shared with other parts of the application, i.e. can't simply use unsigned Raygun4Net and Visual Studio package manager won't remove Core because WebApi depends on it.

DLL hell 2.0 ? :)

One solution I can think of is to have signed Core/WebApi packages. What's the reason to have signed and unsigned packages? Why not just sign all of them?


Nick Dunets

Posted on
Jun 30 2015

Or if there's a valid reason to have signed and unsigned versions then why not give different names to dll files

Mindscape.Raygun4Net.dll vs Mindscape.Raygun4Net.Signed.dll

P.S. my issue is not related to Serilog. But I reckon it's a Raygun's and not Serilog's problem that different packages with same version number can't coexist in one project


Jamie Penney

Posted on
Jul 01 2015

Hey Nick,

We can't have different names for the assemblies without changing all our setup instructions to differentiate between the signed and unsigned Raygun4Net assembly - the RaygunSettings configSection class needs to be referenced by fully qualified name, so that would mean having to specify which one you are using. Doesn't sound like much but we already get quite a few support requests around the configSection bit - you'd be surprised how many people don't actually know how it works.

We created a signed version because people asked for it - Signed assemblies can only rely on other signed assemblies, so anyone who was signing their own assemblies was unable to use Raygun4Net. We will look at adding signed versions of the other projects.

Probably another thing to add is that Core is a cut down version of the main Raygun4Net assembly that lets us share code that both WebApi and MVC use so you can install both at once. However to pull that off, Raygun4Net.Core presents itself as Mindscape.Raygun4Net (so setup instructions are the same between all project types). There's a bit of legacy around the assemblies we generate here that we're slowly cleaning up unfortunately we're left with issues like this while it happens.

Cheers,
Jamie


Nick Dunets

Posted on
Jul 01 2015

Makes sense. Didn't think about config section


Reply