Getting Assembly Path from within a UITypeEditor

I have a property in a usercontrol that contains a combination of a user defined form class and the assembly it is contained in. It is formatted like: 
"MyNamespace.MyForm, MyAssembly". 

What I am trying to do is _reliably_ get the path to the assembly depending if we are at design-time or running the app. We can assume that the form assembly is referenced to the project the user control is in. 

Since these paths can vary greatly (Debug, Release, end user runtime), I do not store the path to the assembly but it will be in the applications execution path (all .dlls in same folder).

Question is: How can I get the path to the app the user is building at design-time from within a UITypeEditor for a control (and then at runtime when I need to create the users form) 

I have been working with the Assembly classes with some success, ie:

            AssemblyName an = AssemblyName.GetAssemblyName(assemName);
            Assembly as         = Assembly.LoadFrom(an.CodeBase);

(assemName is parsed from the above formatted property in user control). This doesn't always load. I think the first time it is called it cannot find the file but after that it works. I am looking for a more reliable way to accomplish this task.

Thanks,

Mike


Answer this question

Getting Assembly Path from within a UITypeEditor

  • BlokHead

    application.startuppath
  • BradN

    Sorry for the dup post - I received an error when posting and I thought it didn't go through ..

    Can someone delete   Please refer to the other post:
    http://www.windowsforms.net/Forums/ShowPost.aspx tabIndex=1&tabId=41&PostID=6852

    Thanks!

  • Getting Assembly Path from within a UITypeEditor