Reloading will definitely cause a problem.

According to MS docs:

"Only one instance of the Application class can be created per
AppDomain, to ensure shared access to a single set of application-
scope window, property, and resource data. Consequently, the default
constructor of the Application class detects whether the instance
being initialized is the first instance in an AppDomain; if it is not,
an InvalidOperationException is thrown.

"The Application object for the current AppDomain is exposed from the
static Current property."

Thus:


(import 'System.Reflection.Assembly)
(Assembly/LoadWithPartialName "PresentationFramework")
(import 'System.Windows.Application)


Application/Current   ;=> nil
(Application.)            ;=> #<Application
System.Windows.Application>
Application/Current   ;=> #<Application System.Windows.Application>
(Application.)
InvalidOperationException Cannot create more than one
System.Windows.Application instance in the same AppDomain.
System.Windows.Application..ctor (:0)


I don't know why you'd need the app atom since you can just use
Application/Current.  Similarly, you could check Application/Current
before doing (Application.)

I suppose if you really wanted to get fancy, you could create the WPF
application in other AppDomain and then wipe it.  Not sure why.

NB: I've not done any WPF work, just working from general principles.

-David


On Apr 13, 6:48 am, kjeldahl <mariusauto-googlegro...@kjeldahl.net>
wrote:
> Following up on my own subject, I've created an updated gist to run on
> recent builds of clojure-clr (1.3.0-master-SNAPSHOT) based on another
> gist I found.
>
> It's not the prettiest of code I've found, but I guess CLR's
> abstractions and threading models can be blamed for a lot of it.
> What's more annoying though is that while the gist below runs fine
> when pasted into a running repl, it only does so the first time. Close
> the window and paste it once more, and nothing appears.
>
> There may be an issue with the CLR AppDomain model only allowing one
> instance of an Application object or similar (based on messages I've
> encountered while exploring), but I don't really know and I haven't
> managed to get everything to completely "unload" so that the code
> would work when invoked repeatedly within a running repl.
>
> If anybody knows how this can be fixed (without restarting the repl
> environment), please chime in. I like the statelessness offered by
> clojure and a running repl, but the code as it currently exist doesn't
> really support this model.
>
> The updated gist can be found here:
>
> https://gist.github.com/917391
>
> Thanks,
>
> Marius K.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to