-
-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InternalsVisibleTo #258
Comments
There is an message "Type to mock must be an interface or an abstract or non-sealed class" in exception details. Do thing that you are trying to mock is interface or non-sealed class? |
@ramtinkermani, can you please provide a short but complete example code that reproduces this issue? |
I am closing this for the moment, since no code for reproducing this issue has been provided so far. @ramtinkermani: Feel free to report back with repro code, we can reopen this issue anytime. |
@ramtinkermani - I'm just doing some repo housecleaning and came across this old issue of yours again:
This is due to a somewhat hard-to-understand feature of Castle DynamicProxy. Depending on whether your own client code is signed (i. e. strong-named) or not, it puts generated proxies in a strong-named or weak-named assembly. (Sometimes it even splits generated types across both.) By including or omitting the public key in the above attribute, you're either referring the strong-named or weak-named dynamic assembly. From the perspective of Moq and DynamicProxy, things work best if you sign your own client code assembly (if that is an option). If you don't want to do that, you can also try including both |
Moq throws an ArgumentEception when trying to use the mocked method that is Internal to the SUT project, even though the following attribute is set in the main project.
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2,PublicKey=002400000..<TRUNCATED>..5cc7")]
Interestingly when I remove the public key, all works fine and no exceptions are thrown. I checked the public key from the source code and it is correct (Originally copied from the Quick Start page, verified later from the source).
Any ideas what is wrong?
Here is the Exception:
The text was updated successfully, but these errors were encountered: