It would be similar to internal but with the ability to specify which
classes could access this method.
I know this doesn't exist but a declaration like:
[InternalTo(A.dll, C.dll)]
internal static Method()...
I guess i could check the call stack in Method for callers that are at
the top of the stack are a.dll or c.dll. Is there a better way?
dan
Why? It seems like the easiest way to do what you want is just
duplicate the code as private in the two spots that need it. I hate
duplicating code, but you've got some pretty strict requirements that,
in this case, are easily solved with a copy/paste of the one method.
--
Patrick Steele
http://weblogs.asp.net/psteele
>It would be similar to internal but with the ability to specify which
>classes could access this method.
There's the InternalsVisibleToAttribute, but it applies only to
assemblies. There's nothing as granular as what you're asking for.
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
http://msdn2.microsoft.com/en-us/library/system.reflection.assembly.getcallingassembly.aspx
Regards
John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Dan Holmes" <danh...@bigfoot.com> wrote in message
news:OjFIpPjS...@TK2MSFTNGP03.phx.gbl...
[assembly:
InternalsVisibleTo("Coversant.SoapBox.Services.SomeService,PublicKey=....")]
This has worked very well so far. It's not quite what you're looking for,
but it's close.
--
Chris Mullins, MCSD.NET, MCPD:Enterprise, MVP C#
http://www.coversant.net/blogs/cmullins
"Dan Holmes" <danh...@bigfoot.com> wrote in message
news:OjFIpPjS...@TK2MSFTNGP03.phx.gbl...
You can use CAS.
Sign all of your assemblies with the same strong-name, then Demand the
StrongNameIdentityPermissionAttribute attribute on your public, static
methods with your assembly signature's public key so they cannot be called
from other assemblies.
The PublicKey value must be a hexadecimal string. You can use the Strong
Name utility (sn.exe) to create the key with which you'll sign your assembly
(although Visual Studio can be used to perform this operation for you).
The -k switch will create the public/private key pair. If you use -k to
create a file named, "key.snk" then use that file as input to the -p switch.
The file output from the -p switch can then be used as input to the -tp
switch to produce the hexadecimal representation of the public key that you
can assign to the PublicKey property of the
StrongNameIdentityPermissionAttribute attribute. Make sure you use the full
public key and not just the token.
--
Dave Sexton
http://davesexton.com/blog
http://www.codeplex.com/DocProject (Sandcastle in Visual Studio 2005)
"Dan Holmes" <danh...@bigfoot.com> wrote in message
news:OjFIpPjS...@TK2MSFTNGP03.phx.gbl...
thanks
dan