Exposing selected parts of C# Assemblies

J

J L

I'm trying to expose only a limited set of method calls from a C#
program to someone using my dll.

The entire application is written in C# and my first attempt has been to
try and write a COM object/interface.
However, since the COM object references parts I don't want exposed, in
order to use the DLLs in a new C# project the other .dlls must be added
as references.
Is there any way to prevent the methods in these other DLLs from being
seen by another developer (in other words, forcing them to only use the
methods in the "API DLL")?

Thanks.
 
V

VJ

Just curious why can't you declare the method & properties as private?, or
did I miss something in your question?

VJ
 
B

Bob Grommes

Your question is not clear. Exposing "... method calls from a C# program"
sounds like using a running program being used as a server in some way. But
then you say "...to someone using my dll". Which sounds like you want to
allow others to use routines in a DLL that your application uses.

If you simply want to allow another program to call certain library routines
in a DLL that's part of your application, you can control the visibility of
any method, property or field using private, protected, internal or public
declarations as desired.

--Bob
 
J

J L

I will clarify, but I think I've figured out some things.

I have an application that is made up of a set of assemblies.
Unfortunately as things are structured, classes in one assembly need to
see others in other assemblies.

I'm trying to create another assembly that is an "API Assembly" that
will expose certain parts to a programmer.
I only want an outside programmer to be able to use this assembly to
extend the application.

The problem I'm having is that I want one of the classes in this
assembly to inherit from a type in one of the assemblies I want to hide.
It seems that this is not possible, because once I inherit, VS.NET
forces you to reference the other assembly if you were to reference the
API assembly (i.e. I have something like this:

class APIClass : InternalClass
{
...
}

where InternalClass is defined in another assembly.
Is there any way I can prevent a programmer from seeing that
class/assembly?

I realize that its probably not a good idea to inherit from a class I'm
trying to hide, so any suggestions on better methodologies would be
appreciated too.
I'm sort of a C# newbie (done mostly C/C++ in the past)

Thanks.
 
V

VJ

I think you are looking to write a SDK of sort for your application if I am
correct? Let me know

VJ
 
V

VJ

umm... its really a challenge, not that simple techinquies..., you have to
go through a design phase.. & provide phased implementation of interfaces &
abstract classes.., not much different from what you would do in C/C++..
expect there is some syntax variations..., don't think C# provides anything
new or a shortcut for SDK development. From your situation point, looks like
you might have to do some re-writing or restructure of classes & Yes you
don't inherit from classes you want to hide, speically if there are in
separate assemblies. One thing would be to have the code in the same
assembly, if you still have to inherit from a class you want to hide.

You may also want to look at securities concept
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/THCMCh07.asp)
in .NET, it provides a way sheilding copy protection or usage of assemblies.
That is pretty length one,... but helps a lot, we started from there & can
say have some amount of structure & a very good protection to our code.

HTH
VJ
 
J

Jon Shemitz

J said:
I have an application that is made up of a set of assemblies.
Unfortunately as things are structured, classes in one assembly need to
see others in other assemblies.

I'm trying to create another assembly that is an "API Assembly" that
will expose certain parts to a programmer.
I only want an outside programmer to be able to use this assembly to
extend the application.

You say "a set of assemblies" but my guess would be that you mean a
set of .dll files, with each library file constituting one assembly.

I'm not sure - because I haven't done this - but you should be able to
bundle all these library files into a multi-file assembly. Then, you
could use "internal" access for cross-library inheritance &c, and
"public" access for third-party access.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top