Click here to Skip to main content
15,891,675 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
What is the best practice for placing general-purpose routines which will be widely used? To date, I've tended to simply have a ModGlue.vb file in each project, where I throw any that I need, but moving classes between projects requires locating and copying in the appropriate stuff from ModGlue, which is somewhat tedious and will become moreso the longer I go without a better strategy.

Some of the general-purpose routines are things like:
Function Byt(ByVal v as Integer) As Byte<br />  Return CByte(v and 255)<br />End Function<br /><br />Function HexArr(ByVal dat() as Byte) As String  ' Returns hex representation of array<br /><br />Function ByteString(ByVal dat() as Byte, ByVal Length As Integer) As String ' Converts bytes to string (by character code)<br /><br />Sub Zap(ByRef it as iDisposable)<br />  Dim oldIt as iDisposable<br />  oldIt = it<br />  If oldIt IsNot Nothing then<br />    oldIt.Dispose<br />    Threading.Interlocked.CompareExchange(it, Nothing, oldIt)<br />  EndIf<br />End Sub


In many cases, things that sorta should have been part of the .Net framework, but aren't. What's the best way to make sure that the necessary functions get brought in when copying a class from one project to another, without ending up with extraneous or duplicated methods?
Posted

1 solution

Build a dll you import into all your projects.

 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900