开发者

"Reference required" error when referencing NServiceBus assembly from another project

开发者 https://www.devze.com 2022-12-19 15:01 出处:网络
We are trying to write an application that uses the NServiceBus library in a VB.NET environment. We\'ve been stymied by errors similar to the following:

We are trying to write an application that uses the NServiceBus library in a VB.NET environment. We've been stymied by errors similar to the following:

Reference required to assembly 'NServiceBus, Version=2.0.0.1071, Culture=neutral, PublicKeyToken=9fc386479f8a226c' containing the implemented interface 'NServiceBus.IMessageHandler`1'. Add one to your project.

Our project already includes references to NServiceBus.dll and NServiceBus.Core.dll from the same NServiceBus 2.0 RC2 distribution.


Steps to reproduce:

  1. Create a new VB Class Library Project (.NET 3.5)
  2. Add NServiceBus.dll and NServiceBus.Core.dll as References.
  3. Put the following code in Class1.vb:

    Imports NServiceBus.Sagas.Impl
    Class Test
        Public Function Foo() As SagaMessageHandler
            Return Nothing
        End Function
    End Class
    
  4. You should now see the compiler error 开发者_Go百科mentioned above.

An identical project written in C# has no compile errors.


Any ideas about how to solve this problem? (And, yes, my preferred solution is switching to C#, but no, that's not an acceptable one at the moment.)


On a hunch that it was an ILMerge-related issue, I found this post suggesting that assembly signing might be responsible.

I downloaded the NServiceBus trunk source, opened up src/core/NServiceBus.sln, and set each of the projects in the solution to sign the assembly with NServiceBus.snk from the source tree root. The new DLLS produced after rebuilding NServiceBus fixed the compiler errors from my original post.


The projects are now strong named on both the trunk and the 2.0 branch.

Hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消