|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Assembly.CodeBase // Getting it statically without object instantiationAssembly SampleAssembly; // Instantiate a target object. Int32 Integer1 = new Int32(); Type Type1; // Set the Type instance to the target class type. Type1 = Integer1.GetType(); // Instantiate an Assembly class to the assembly housing the Integer type. SampleAssembly = Assembly.GetAssembly(Integer1.GetType()); // Gets the location of the assembly using file: protocol. Console.WriteLine("CodeBase=" + SampleAssembly.CodeBase); Notice the "new Int32". (aka, an object instantiation) Is there a way to statically get the Assembly.CodeBase ~without instantiating an object ? Take the simple example where you create a new/blank Console.Application. How can I get the .CodeBase of that console app... remembering that I'm in the static world.. as such static void Main(string[] args) { }
Show quote
"sloan" <sl***@ipass.net> wrote in message Console.WriteLine(System.Reflection.Assembly.GetAssembly(typeof(Int32)).CodeBase);news:eJdKV1KwGHA.4416@TK2MSFTNGP03.phx.gbl... > Here is the msdn code for getting the .CodeBase property of an Assembly > > Assembly SampleAssembly; > // Instantiate a target object. > Int32 Integer1 = new Int32(); > Type Type1; > // Set the Type instance to the target class type. > Type1 = Integer1.GetType(); > // Instantiate an Assembly class to the assembly housing the Integer type. > SampleAssembly = Assembly.GetAssembly(Integer1.GetType()); > // Gets the location of the assembly using file: protocol. > Console.WriteLine("CodeBase=" + SampleAssembly.CodeBase); > > > Notice the "new Int32". (aka, an object instantiation) > > Is there a way to statically get the Assembly.CodeBase ~without > instantiating an object ? > > Take the simple example where you create a new/blank Console.Application. > How can I get the .CodeBase of that console app... remembering that I'm in > the > static world.. as such > static void Main(string[] args) > > { > > David> > } > > I couldn't see the trees for the forest.
Thanks David. Show quote "David Browne" <davidbaxterbrowne no potted m***@hotmail.com> wrote in Console.WriteLine(System.Reflection.Assembly.GetAssembly(typeof(Int32)).Codemessage news:eZU%23cYLwGHA.4920@TK2MSFTNGP06.phx.gbl... > > "sloan" <sl***@ipass.net> wrote in message > news:eJdKV1KwGHA.4416@TK2MSFTNGP03.phx.gbl... > > Here is the msdn code for getting the .CodeBase property of an Assembly > > > > Assembly SampleAssembly; > > // Instantiate a target object. > > Int32 Integer1 = new Int32(); > > Type Type1; > > // Set the Type instance to the target class type. > > Type1 = Integer1.GetType(); > > // Instantiate an Assembly class to the assembly housing the Integer type. > > SampleAssembly = Assembly.GetAssembly(Integer1.GetType()); > > // Gets the location of the assembly using file: protocol. > > Console.WriteLine("CodeBase=" + SampleAssembly.CodeBase); > > > > > > Notice the "new Int32". (aka, an object instantiation) > > > > Is there a way to statically get the Assembly.CodeBase ~without > > instantiating an object ? > > > > Take the simple example where you create a new/blank Console.Application. > > How can I get the .CodeBase of that console app... remembering that I'm in > > the > > static world.. as such > > static void Main(string[] args) > > > > { > > > Base); Show quote > > > > > > > } > > > > > > David > > |
|||||||||||||||||||||||