dotnet / dotnet/wpf

Application class can't instantiate again

Open
#3,744 1 comment 0 reactions 0 assignees View on GitHub
.NET Framework Enhancement Requested
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity2.visualstudio.com/t/Application-class-cant-instantiate-agai/653931)._

---

Hi everbody, espacially .NET developers,

I developing an add on in WPF from an native application. Because I have to loaded the application as COM add on, I provide a .dll. Inside I create a application object manually (because for a global Application.Current pointer and resources). This works fine.

The problem begins, if you close the add on and restart it again. In this case I ran (or better the instruction pointer) into following problem:

if (_appCreatedInThisAppDomain == false)

{
...
}
else
{
//lock will be released, so no worries about throwing an exception inside the lock
throw new InvalidOperationException(SR. Get(SRID. MultiSingleton));
}

(code from c'tor of Presentation.Application / https://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/Application.cs,cf9c51e402f97b05 - line 140)


_appCreatedInThisAppDomain is still set and an exception is thrown. In my opinion this member should also set to false (reset) in DoShutdown().

_appIsShutdown = true; // mark app as shutdown

(line 1762)

Or is there an another solution?

Thanks

Michael

---
### Original Comments

#### Feedback Bot on 7/22/2019, 04:05 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

#### Feedback Bot on 10/8/2019, 05:22 PM:

I have detected that for the last 35 days, this issue didn't have any product team activity and a very small amount of new votes or comments. Based on this, its severity, and affected area, it’s my experience that this issue is very unlikely to be fixed.

---
### Original Solutions
(no solutions)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.