Click here to Skip to main content
15,889,565 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Nested Components - Winforms Pin
Midi_Mick11-Oct-16 0:24
professionalMidi_Mick11-Oct-16 0:24 
QuestionLife of IDisposable object members Pin
Midi_Mick2-Oct-16 7:25
professionalMidi_Mick2-Oct-16 7:25 
AnswerRe: Life of IDisposable object members Pin
Nathan Minier3-Oct-16 1:28
professionalNathan Minier3-Oct-16 1:28 
GeneralRe: Life of IDisposable object members Pin
Midi_Mick3-Oct-16 1:41
professionalMidi_Mick3-Oct-16 1:41 
GeneralRe: Life of IDisposable object members Pin
Nathan Minier3-Oct-16 1:46
professionalNathan Minier3-Oct-16 1:46 
QuestionControl Designers Pin
Midi_Mick27-Sep-16 4:02
professionalMidi_Mick27-Sep-16 4:02 
AnswerRe: Control Designers Pin
Gerry Schmitz28-Sep-16 13:26
mveGerry Schmitz28-Sep-16 13:26 
Questioninteroperation / Loading and unloading WPF assembly from arbitrary path Pin
achimschoen22-Sep-16 5:44
professionalachimschoen22-Sep-16 5:44 
I've put this question in the .NET folder since I guess this question is more related to the .NET framework than to C# or C++/CLI.

I'm currently struggling to find a way to load and unload a WPF assembly from an arbitrary path (not a sub directory of the base path) from a C# console application.

I was exploring codeproject for a couple of days (as I have done with some other forums), but I can't actually find a way how to get the console application loading the WPF assembly and instantiating an object from the assembly.

Starting point is the following example as C# console application:


C#
using WPFLibrary;

namespace Caller
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            SampleWindow wnd = new SampleWindow();
            wnd.ShowDialog();
        }
     }
 }


and the following code as WPF assembly:

C#
namespace WPFLibrary
{   
    public partial class SampleWindow : Window
    {       
        public SampleWindow()
        {
            InitializeComponent();
        }
   }
}



I found various similar questions and suggestions to use:

- Reflection via: Assembly.Load();
- Using Activator.CreateInstance();
- Using a different AppDomain with CreateInstanceAndUnwrap
- Using AssemblyResolve for the AppDomain etc.
- etc

But I could never get my simple example above working if the WPFLibrary is not in a sub directory of the base path of the Caller console application. Since I'm new in this field I may just have missed a simple thing or this scenario may be completely impossible.... Any help would be appreciated.

Background of this question:



In case you are not interested to understand my motivation for this question just skip the remaining of this post. We are developing an c++ dll application for a commercial CAD system. The interface for this system is c/c++ only so there no way to change the complete code to a C# application. This application includes a simple scripting language which also allows to define and execute a graphical user interface. Currently this is encoded in a win32 / MFC way, but since it includes a self build layout manager it is obviously a good idea to think about other alternatives. A perfect match seems to be use use WPF, but that requires to use .NET and to allow XAML definitions a C# library connected by a C++/CLI dll seems to be a good setup.

Some major requirements are:

- The WPF dll must be able to be load from the installation of the application.
- It is required to stop and restart the application (so also the WPF assembly needs to be removed and reloaded).
AnswerRe: interoperation / Loading and unloading WPF assembly from arbitrary path Pin
NotPolitcallyCorrect22-Sep-16 6:29
NotPolitcallyCorrect22-Sep-16 6:29 
GeneralRe: interoperation / Loading and unloading WPF assembly from arbitrary path Pin
achimschoen22-Sep-16 6:44
professionalachimschoen22-Sep-16 6:44 
GeneralRe: interoperation / Loading and unloading WPF assembly from arbitrary path Pin
NotPolitcallyCorrect22-Sep-16 7:02
NotPolitcallyCorrect22-Sep-16 7:02 
GeneralRe: interoperation / Loading and unloading WPF assembly from arbitrary path Pin
achimschoen22-Sep-16 22:09
professionalachimschoen22-Sep-16 22:09 
AnswerRe: interoperation / Loading and unloading WPF assembly from arbitrary path Pin
#realJSOP22-Sep-16 6:41
mve#realJSOP22-Sep-16 6:41 
AnswerRe: interoperation / Loading and unloading WPF assembly from arbitrary path Pin
Gerry Schmitz22-Sep-16 7:12
mveGerry Schmitz22-Sep-16 7:12 
GeneralRe: interoperation / Loading and unloading WPF assembly from arbitrary path Pin
achimschoen22-Sep-16 22:17
professionalachimschoen22-Sep-16 22:17 
GeneralRe: interoperation / Loading and unloading WPF assembly from arbitrary path Pin
Gerry Schmitz24-Sep-16 6:16
mveGerry Schmitz24-Sep-16 6:16 
AnswerRe: interoperation / Loading and unloading WPF assembly from arbitrary path Pin
Bernhard Hiller22-Sep-16 21:02
Bernhard Hiller22-Sep-16 21:02 
AnswerRe: interoperation / Loading and unloading WPF assembly from arbitrary path Pin
Pete O'Hanlon22-Sep-16 21:41
mvePete O'Hanlon22-Sep-16 21:41 
GeneralRe: interoperation / Loading and unloading WPF assembly from arbitrary path Pin
achimschoen22-Sep-16 21:57
professionalachimschoen22-Sep-16 21:57 
GeneralRe: interoperation / Loading and unloading WPF assembly from arbitrary path Pin
Pete O'Hanlon23-Sep-16 2:29
mvePete O'Hanlon23-Sep-16 2:29 
QuestionTcpClient timeout delay Pin
Member 1263260115-Sep-16 19:50
Member 1263260115-Sep-16 19:50 
QuestionRe: TcpClient timeout delay Pin
Richard MacCutchan15-Sep-16 22:38
mveRichard MacCutchan15-Sep-16 22:38 
AnswerRe: TcpClient timeout delay Pin
Member 1263260115-Sep-16 22:50
Member 1263260115-Sep-16 22:50 
GeneralRe: TcpClient timeout delay Pin
Richard MacCutchan15-Sep-16 23:18
mveRichard MacCutchan15-Sep-16 23:18 
AnswerRe: TcpClient timeout delay Pin
Bernhard Hiller16-Sep-16 0:16
Bernhard Hiller16-Sep-16 0:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.