locked
AppDomain ExecuteAssembly method - how to specify an alternate entry point RRS feed

  • Question

  • I can create a new AppDomain and call ExecuteAssembly on said AppDomain with no problems. The thing is, it seems, that the assembly has to be a .exe with an entry point defined.


    What I would like to do is be able to either tell ExecuteAssembly an alternate entry point to use,  or perhaps to be able to specify an entry point in an otherwise normal class library type assembly.  Seems to me like there should be an assembly attribute for that, but I can't find it right now.  The "Startup Object" specified in the C# project properties seems like it would be heading in the right direction, but won't set one for a class library assembly.

    Anyone done something like this?

    Thanks


    roger reynolds
    Monday, April 12, 2010 7:41 PM

Answers

All replies

  • This looks like a CLR question, try the CLR forum under the .Net Development category.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
    Visual C++ MVP
    Monday, April 12, 2010 11:32 PM
  • Hello

    I'm moving the thread to the CLR forum.


    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, April 13, 2010 1:03 AM
  • Hi,

    Even though we can specify "Startup Object" in Visual Studio, there can be only one entry point for an exe assembly, AppDomain.ExecuteAssembly Method will look for the entry point specified in the assembly header and execute the entry point method.

    But, .NET Reflection may help: with reflection, you can dynamically load an assembly, create objects of some types and invoke their methods, this article shows more details on it, hope it can help.


    Sincerely,
    Eric
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com .
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, April 13, 2010 3:45 AM
  • Or you could use AppDomain.CreateInstanceAndUnwrap - see the example there.

    -Karel

    Tuesday, April 13, 2010 5:15 AM
  • Looks like AppDomain.CreateInstanceAndUnwrap will accomplish what I'm after, rather than worrying about the entry point and all of that.

    Thanks to all.


    roger reynolds
    Tuesday, April 13, 2010 3:40 PM