Search code examples
.netcastlecastle-dynamicproxy

Turn off signing for Castle DynamicProxy


I am having problems when trying to use a TypedFactoryFacility in Castle.

I'm using Castle v3.0.0 and I've created a ViewFactory, using

injector.AddFacility(Of TypedFactoryFacility)()

and:

container.Register(CMR.Component.For(Of IDialogViewFactory)().AsFactory())

This code all works fine on my machine, but when deploying it to users on VMs (who don't have local admin rights), they get the following error:

Unable to obtain public key for StrongNameKeyPair.

There's various threads around, but nothing that seems to solve my issue - how can I use DynamicProxy on machines who don't / can't have access to C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\

In the stack trace of the error is the line

Castle.DynamicProxy.ModuleScope.CreateModule(signStrongName As Boolean)

Which seems to suggest strong naming can be turned off somehow but I can't figure out how?


Solution

  • in (upcoming) version 3.1 you can do this, right after you've created the container:

    Container.Kernel.ProxyFactory = new DefaultProxyFactory(disableSignedModule: true);
    

    In 3.0 or older you can inherit from DefaultProxyFactory and set the value from there.