How to Create WinForms client and ClassLib server as one assembly?

  • Thread starter Thread starter Joseph Geretz
  • Start date Start date
J

Joseph Geretz

I'd like to break up my aplication into a WinForm executable, plus a class
library containing application utility functions. But I don't want any
client other than my own application to have access to my application
library. Isn't this the point of an 'assembly'? So how can I generate these
two artifacts as belonging to the same assembly? Is this possible with
Visual Studio 2005?

Thanks!

- Joe Geretz -
 
I'd like to break up my aplication into a WinForm executable, plus a class
library containing application utility functions. But I don't want any
client other than my own application to have access to my application
library. Isn't this the point of an 'assembly'? So how can I generate these
two artifacts as belonging to the same assembly? Is this possible with
Visual Studio 2005?

Use different assemblies and CAS (Code Access Security). There was an
overview posted in the newsgroups about a week ago:

http://tinyurl.com/2nwefz
 
I'm not sure how and why you see CAS as preventing the access. Were you
thinking programmatically? The way I read the question seemed to imply it
was other than programmatically. Perhaps OP can clarify.

As a suggestion, why not use a windows control library?

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
 
"Alvin Bruney said:
I'm not sure how and why you see CAS as preventing the access. Were you
thinking programmatically? The way I read the question seemed to imply it
was other than programmatically. Perhaps OP can clarify.

To me, it sounded like he wanted to break his "utility functions" into a
separate assembly, but only wanted his WinForms app to be able to access
that assembly. The link I posted was to a similar question and showed
how to use strong keys and attributes to control who could make calls
into an assembly.

But perhaps the OP could clarify exactly what they want? ;)
 
Hi Patrick,

Yes, you state the case correctly; this is exactly what I'd like to do. I
see how CAS can acheive this, however CAS seems more of an administrative
tool than a development option. For a commercial product which will be
installed all over the place, I don't see how CAS can be a viable solution
unless CAS rules can be manipulated programmatically, or via our installer.
Would this be possible?

Thanks,

- Joseph Geretz -
 
Hi Patrick,

Yes, you state the case correctly; this is exactly what I'd like to do. I
see how CAS can acheive this, however CAS seems more of an administrative
tool than a development option. For a commercial product which will be
installed all over the place, I don't see how CAS can be a viable solution
unless CAS rules can be manipulated programmatically, or via our installer.
Would this be possible?

I believe the link I posted suggested that you simply strong-name your
assemblies that want to call your utility assembly. Then, your utility
assembly methods (or maybe the whole assembly?) has an attribute to
demand a specific strong-name public key from all callers. Since only
your assemblies are signed with the proper key, they will be the only
ones allowed to call the utility assembly.

I don't think you'll need to manipulate any CAS rules for that.
 
Back
Top