Moq in Silverlight 4. "Unable to create proxies for types that are not available."

I am trying to mock the backend in Silverlight 4 using moq-silverlight 4.0.10827.0.

I get the error "Unable to create proxies for types that are not available." in the lock .DynamicProxy.Generators.GeneratorException.

I have [assembly: InternalsVisibleTo ("DynamicProxyGenAssembly2")] in the assembly information of the assembly under test. I have no signed assemblies.

+4
source share
2 answers

Try enabling the public key:

[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] 

And make sure that you also make the internals visible for the unit test assembly (if they are in a different assembly).

+4
source

The InternalsVisibleTo switch only works in this scenario: you must apply it in an assembly containing the internal elements that you want to see on another assembly. If this works when you specify it in an assembly that wants to consume these internal components, it will be a big security leak!

+1
source

Source: https://habr.com/ru/post/1382447/


All Articles