I reposted my question to the VC group because I beleive what I want is a
module initializer. The reason for the assembly.dll.config is because my
application is plugin based and I want to keep the configuration settings
with the plugin w/o having to merge them with application.exe.config.
Thanks
"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in
message news:uM2IK3zfGHA.4276@TK2MSFTNGP03.phx.gbl...[color=blue]
> Brian,
>
> Why do you have an assembly.dll.config? You should take your config
> settings and place them in the config file for the application that is[/color]
using[color=blue]
> the assemblies. This is the recommended way of doing it, and the way the
> config classes have been set up.
>
> But in regards to your question, if you want code to run in an[/color]
assembly[color=blue]
> when loaded, you will have to execute the code manually.
>
> My recommendation is to create an attribute which takes a type. The
> assemblies would then apply the attribute on the assembly level, and you
> would get the attribute in your calling code through reflection. Then,[/color]
you[color=blue]
> can get the type.
>
> Now, you can either call a static method with a known signature on the
> type, or (and I would do this), create an interface that the type will
> implement, and then create an instance of that type.
>
> Then, you execute the methods on the interface implementation, and you
> are done.
>
> You might want to keep a flag indicating that the code was run as[/color]
well.[color=blue]
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> -
mvp@spam.guard.caspershouse.com
>
> "Brian Richards" <brichards@gmail.com> wrote in message
> news:eYCFOWzfGHA.4004@TK2MSFTNGP04.phx.gbl...[color=green]
> > Is it possible to run code in an assembly when it's loaded? In my case I
> > have an assembly that requires that the users path be setup correctly or
> > GetTypes() will throw an exception. Looking for a work around to just
> > requiring the user to have the Path environment setup in the calling
> > application.
> >
> > class MyAssemblyLoader
> > {
> > public Type[] GetTypes(String assemblyName)
> > {
> > Assembly assembly = Assembly.Load(assemblyName); //causes code in
> > assemblyName to run and set Environment path from Assembly.dll.config
> >
> > return assembly.GetTypes();
> > }
> > }
> >
> >[/color]
>
>[/color]