CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 8/21/2004 8:02:26 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 12 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
SkySigal
Asp.Net User
Help: How to reuse code when building controls? With no Dependancies?8/21/2004 8:02:26 PM

0/0

I am having a lot of trouble trying to wrest from the IDE the flexibility I want so that I can build assemblies that have only one control -- or several ...

Can someone help?

Desired Result
There are two goals:
a) The base idea is to write lots of controls that share a common set of methods/functions, in order to not cut/paste a lot of repetition code.
b) Be able to write controls so that they can be compiled as one unit (ie 10 or so controls to one assembly) or publishable to the web as single control assemblies.
I've written several controls that people may like, and I would like to publish them. For my own use, I prefer working with one big "MyControls.dll" -- but for articles, it would be best that the reader has to deal with only one at a time....

In other words, I need to be able to build for both worlds...
I have tried several approaches -- none seem satisfactory:


Copy CommonCode to each assembly:
Lets say I make a common class of Helper functions that each control may use (probably will). Might even have a common ControlBase that all controls can enherit from.
If it were just one big assembly with the *.cs files of the controls actually in the assembly, the control does not grumble.
But life is generally not that nice and I end up with website structures that look much more like:

*WebSiteAsssemblyWith5orSoSpecificControls
*GeneralPackageOf20ControlsMadeInJune
*AnotherPackageWith10MoreControlsMadeInJuly
*ASingleControl
*AnotherSingleControl

What happens is that yes, the Compiler accepts it -- but it flags every single ref to the use of such common code with a warning saying -- watch out -- the same exact method exists in 5 different assemblies.... In other words, it doesn't seem to be a very happy Compiler...


Keep CommonCode in a separate Dll?
This solution is, in other words, based on the control having a dependancy...
I tried at first keeping the code in a common dll (called it Common.dll) and wire it in to each DLL, and the Compiler grumbles a bit as it multicopies the Common.dll from the bin of each Control.dll each time I rebuild the project.
This works in RunTime -- but it fails in DesignTime in the IDE, because the ControlBuilder tries to instantiate a control that doesn't have the right Common.dll build (The build num of the control the IDE is running will be looking for a Common.dll with a different build num...Got that?!?!) What I am saying is that DesignTime IDE does not accept to use controls that have dependancies -- it appears that it accepts to work with Controls that have no dependancies only.

GACL?
Sortof...I read that this could be resolved by giving Common.dll a Strong name and putting the Common.dll in the GACL...
But then we are right back to DLL hell. Plus, do website designers who have their sites hosted, have access to the GACL? Probably not, right? So not a good solution for sure.


Copy/Paste common code
Right now, I am copying common helper code from control to control. In other words, if there is a bug, I am copying to every other control. Total nightmare to track/repair.
This is making my code larger than necessary -- for dumb controls, some of the helper functions used for embedding resources, is larger than the actual control ! :-(((



Please! This issue has driven me nuts... It's got to be a common problem/solution... Just that I don't have enough experience with Compilers versus Interpreters to know how to organize my files correctly...no?

Thank you,
Sky
SkySigal
Asp.Net User
Re: Help: How to reuse code when building controls? With no Dependancies?9/23/2004 3:24:32 PM

0/0

For those who may be looking for an answer to this -- it turns out that there is a way to have common code shared between control projects -- but not the way I was looking at first.

The alternate (only one I've found) solution is to use the very easy to miss 'Link' option when adding a file to a project.

Lets say you create a Common.dll assembly project:

MyCommon.csproj
- MyCommonCode.cs

And you want to use that in a second control:
MyControl1.csproj
- MyControl1.cs
- ...

And you want to include MyCommonControlCode.cs into it , but virtually linked, rather than copied, so that if you edit the file in either project it updates the other (debug once), you must do it this way:

a) From MyControl1.csproj project, click the Add existing file.
b) Find the file, but instead of clicking Ok, click the Arrow beside the Ok button...and you see an option to Link the file file rather than Open/Copy, which is the default... Voila. Linked file comes in with a little arrow symbol to indicate linking rather than separate copy.

For coders
What is happening in fact is that if you open the MyControl1.csproj file you will see that the file that is included looks like this instead of normal
<File RelPath="MyCommonCode.cs" Link="..\CommonCode\MyCommonControlCode.cs"
BuildAction="Compile"/>

Notice the Link attribute that it added.

Gotchas.
This may only be a bug in VS2002 -- don't know about VS2003 -- but if you drag ONE linked file to another project (eg from MyControl1 to MyControl2 project) then the link will stay correct. But if you drag a Folder that contains links (eg contains CommonCode1.cs and CommonCode2.cs) the results are unpredictable. Seems that it gets the first one or two correctly linked -- but that the rest don't. In other words, drag/drop with linking has a bug in VS2002.
I solved the problem by making a quick console script that modifies the XML of the csprojs and add links to any RelPath= that starts with "LinkedFiles\\"-- but its scary to do so....as you muck up a lot of projects fast with scripts like that... The plus side of such scripting solutions is that it has forced me to get very very organized when laying out my controls -- same dir rather than all over the place, same naming conventions throughout, etc....


Hope this helps someone else.
Sky


2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Building Tightly Integrated Software Development Environments: The IPSEN Approach Authors: Manfred Nagl, Pages: 709, Published: 1996
Macromedia Coldfusion MX Web Application Construction Kit: Web Application Construction Kit Authors: Ben Forta, Nate Weiss, Leon Chalnick, Angela C. Buraglia, Pages: 1500, Published: 2002
Handbook of Industrial Engineering: Technology and Operations Management Authors: Gavriel Salvendy, Pages: 2796, Published: 2001
Pro ASP. Net 3. 5 Server Controls and AJAX Components Authors: Rob Cameron, Dale Michalk, Pages: 740, Published: 2008
Advanced Object Oriented Programming with Visual FoxPro 6.0 Authors: Markus Egger, Pages: 416, Published: 1998
Expert SQL Server 2005 Integration Services Authors: Brian Knight, Erik Veerman, Pages: 404, Published: 2007

Web:
David Walend's Blog: Design for Reuse: Source Directory Structures ... I've found I want to reuse code from almost every project I've ever ... There's no shared common source root, so javac can enforce the dependency rules I've ...
Reusing Internet Explorer and the WebBrowser Control: An Array of ... Why would anybody building a non-Internet application want to reuse Internet ... Advantages to Using the WebBrowser Control. Streamline dependencies within ...
CodeProject: Coding in Tiers - Part I. Free source code and ... Building applications without a good strategy for dependency management leads to ... This problem can be solved by extracting the reusable code out into a ...
.NET HITMAN: Unity - Dependency Injection and Inversion of Control ... Unity has no dependency on Enterprise Library core and can be used without .... The above code tells Unity that whenever someone asks for type Database give ...
Building custom user control in Silverlight 2.0 + how to build ... Building custom user control in Silverlight 2.0 how to build code sn ... With the latest version of Silverlight your control no longer loads on this page. ...
In Defense of Not-Invented-Here Syndrome - Joel on Software Code Reuse is:. a) Good b) Bad. 2. Reinventing the Wheel is: ... Without direct control over customer service, you're going to get nightmarishly bad ...
Linux.com :: A 'Linux Desktop Base' could help solve dependency ... The open source culture of reusing code also contributes to the .... If the package has no dependencies other than libraries in the LDB core ...
Monitoring and Enforcing Design Dependencies with Verifydesign Feb 13, 2007 ... Or when trying to reuse code, you find an exisiting component with functionality ... The phone's API has no dependencies, and the phone's ...
Inversion of control - Wikipedia, the free encyclopedia In practice, Inversion of Control is a style of software construction where reusable, generic code controls the execution of problem-specific code with the ...
Building Reusable Oracle SQL and PL/SQL Database Utilities Using ... you have toyed with the idea of using some kind of source code control .... Building Reusable Code for e-Business. The importance of reusable code has never ...




Search This Site:










side by side execution of .net v1.1 and .net v2.0 (continued)

login control

help moving from system to server

copying dnn 3.0.12 from local host to another server

how to strip source of embedded files from deployed folder

asset management module?

dnn developer skills group

how to change the logo at ibuyspy top banner

blowery compression affecting invetua href exchanger

run as server control

2.1 issue message tags not being replaced in e-mails

new web control designers

tree view sitemap nodes

ecommerce sdk tutorial

nunit testing on bll classes...

el jan 06: the value can not be null or an empty string.

sharing users in portals, here's how.

update - visual studio templates for dotnetnuke 3

how to create .sql files?

duh...sorry

menu tool, tables and css

custom sitemapprovider that should get fresh data when parameters changes

use of reserved word for control property

access form authentication cookie

user impersonation to allow setpassword

permission required to start/stop system services

timeclock module

starter kits with sql server 2005 dev not express

add a page.. get an error

dodgey formatting

 
All Times Are GMT