Posts

Showing posts with the label internalsvisibleto

Dynamic Assembly/Types With ReflectionPermissionFlag.RestrictedMemberAccess

Dynamic Assembly/Types With ReflectionPermissionFlag.RestrictedMemberAccess My FlatFiles project uses System.Reflection.Emit to generate deserializers/serializers at runtime to read/write CVS files, etc. Until recently, I was able to simply use DynamicMethod passing in true for the restrictedSkipVisibility constructor parameter. System.Reflection.Emit DynamicMethod true restrictedSkipVisibility New features I am working on require I build a class at runtime instead of a simple method. I was able to implement the new logic using AssemblyBuilder / ModuleBuilder / TypeBuilder /etc. However, I ran into issues whenever I needed to access internal project classes. For that, I added the [InternalsVisibleTo] attribute to my Assembly.cs file, giving visibility to my dynamic assembly. AssemblyBuilder ModuleBuilder TypeBuilder internal Assembly.cs When I look at projects like Castle.DynamicProxy.Core, I see they are relying on [InternalsVisibleTo] , as well. Looking at other projects using ...