Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Could not load file or assembly 'PresentationCore, Version=4.0.0.0,...
Dirk Maegh
#1 Posted : Thursday, January 23, 2020 1:34:18 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 11/30/2016(UTC)
Posts: 48
Location: Belgium

Thanks: 6 times
Was thanked: 7 time(s) in 7 post(s)
Hi I got the following problem, and it seems related to another forum post, but I didn't want to hijack that post, because I don't know it's exactly the same issue.

Exception is
System.IO.FileNotFoundException: Could not load file or assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

It is triggered as soon as I want to instantiate a viewmodel, that manages some properties of type Visibility.
Another failed test in the same solution is when I try to load some resources to verify they are correctly loaded.

It's about a unittest/integration test that references a WPF desktop project, and needs some presentationcore to instantiate a viewmodel (to support Visibility).
The unittest could not load PresentationCore as it is not directly referenced.

I have tried to modify the unittest project to UseWPF and Sdk="Microsoft.NET.Sdk.WindowsDesktop". Thought that would help, to no avail though.

I have a small custom solution for you to check out.
I just don't know where to post it. Can I send it to you directly ?

Thx,
Dirk
Remco
#2 Posted : Thursday, January 23, 2020 10:12:14 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Dirk,

Thanks for sharing this issue.

We've been on a bit of a roller coaster with these sorts of issues over the last couple of months.

Would you be interested in trying the build below to see if this solves the issue for you?

NCrunch_Console_4.3.0.10.msi
NCrunch_Console_4.3.0.10.zip
NCrunch_GridNodeServer_4.3.0.10.msi
NCrunch_GridNodeServer_4.3.0.10.zip
NCrunch_LicenseServer_4.3.0.10.zip
NCrunch_VS2008_4.3.0.10.msi
NCrunch_VS2010_4.3.0.10.msi
NCrunch_VS2010_4.3.0.10.zip
NCrunch_VS2012_4.3.0.10.msi
NCrunch_VS2012_4.3.0.10.zip
NCrunch_VS2013_4.3.0.10.msi
NCrunch_VS2013_4.3.0.10.zip
NCrunch_VS2015_4.3.0.10.msi
NCrunch_VS2015_4.3.0.10.msi.7z
NCrunch_VS2015_4.3.0.10.zip
NCrunch_VS2017_4.3.0.10.msi
NCrunch_VS2017_4.3.0.10.msi.7z
NCrunch_VS2017_4.3.0.10.zip
NCrunch_VS2019_4.3.0.10.msi
NCrunch_VS2019_4.3.0.10.msi.7z
NCrunch_VS2019_4.3.0.10.zip

If the above build doesn't fix it, you're most welcome to ZIP up your test solution and submit it through the contact form. We'll then take a deep look at it and figure out what's going wrong with the runtime resolution.
Dirk Maegh
#3 Posted : Monday, January 27, 2020 6:58:03 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 11/30/2016(UTC)
Posts: 48
Location: Belgium

Thanks: 6 times
Was thanked: 7 time(s) in 7 post(s)
I have installed this build, but the tests still fail.

I get a different error however.
NCrunch encountered an error while trying to construct an environment to execute this test: nCrunch.TaskRunner.Ipc.IpcConnectionClosedException: The connection has been closed
at nCrunch.Core.ProcessManagement.ExternalProcessManager.(EffectiveProcessorArchitecture , ProcessLoadParameters )
at nCrunch.Core.ProcessManagement.ExternalProcessManager.LoadExternalProcess(ProcessLoadParameters parameters, GridClientId client)
at nCrunch.Core.TestManagement.TestRunnerProcess..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Core.TestManagement.TestRunnerProcess.(Nullable`1 , FilePath , GridClientId , CustomVariable[] )
at nCrunch.Core.TestManagement.TestRunnerProcess..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Core.TestManagement.TestRunnerProcess.LoadTestRunnerProcessForProjectReturningProcessId(SnapshotComponent snapshotComponent, IList`1 componentsInProcess, TestFrameworkDescription[] testingFrameworks, Nullable`1 newProcessTag, FilePath solutionFilePath, GridClientId client, CustomVariable[] customEnvironmentVariables)
at nCrunch.Core.Processing.TestExecutionTaskLogic.DoProcessTaskAndReturnSuccessFlag()

Maybe I am doing something wrong ?

Sample solution sent through the contact form.
Remco
#4 Posted : Monday, January 27, 2020 7:16:54 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Thanks for sending through the sample. We'll take a look at this and will get back to you as soon as we have more information.
1 user thanked Remco for this useful post.
Dirk Maegh on 1/27/2020(UTC)
michaelkroes
#5 Posted : Monday, January 27, 2020 8:49:26 PM(UTC)
Rank: NCrunch Developer

Groups: Registered
Joined: 9/22/2017(UTC)
Posts: 280
Location: Netherlands

Thanks: 124 times
Was thanked: 63 time(s) in 60 post(s)
Dirk Maegh
#6 Posted : Tuesday, January 28, 2020 7:51:13 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 11/30/2016(UTC)
Posts: 48
Location: Belgium

Thanks: 6 times
Was thanked: 7 time(s) in 7 post(s)
Hi, just tested with the new suggested version.

Of the two tests in the sample solution, one ran without problems now - 50% fixed ;)
The other test showed the following exception

System.UriFormatException: Invalid URI: Invalid port specified.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString, UriKind uriKind)
at ...ResourceManager.<>c.<.ctor>b__3_0() in C:\...\ncrunch\...\ResourceManager.cs:line 9 (line abbreviated)
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
...

I get the same error when I just try to instantiate a Uri directly in the test method with the pack syntax like
new Uri(@"pack://application:,,,/Resources/notebook.png", UriKind.Absolute);

Thanks for looking into this.
1 user thanked Dirk Maegh for this useful post.
michaelkroes on 1/28/2020(UTC)
michaelkroes
#7 Posted : Tuesday, January 28, 2020 8:30:35 AM(UTC)
Rank: NCrunch Developer

Groups: Registered
Joined: 9/22/2017(UTC)
Posts: 280
Location: Netherlands

Thanks: 124 times
Was thanked: 63 time(s) in 60 post(s)
Hi,

Thanks for testing this so quickly. Glad 50% works.

I had a look at the failing test to see what the VS runner does in that case. That seems to crash on the whole test set, with a stack overflow exception. The same happens with dotnet test. Does that happen for you too? If it does could you try to generate an example that works in the VS runner, but not in NCrunch?

If it does pass in the VS runner, could you please post what version of VS you are using?
Dirk Maegh
#8 Posted : Tuesday, January 28, 2020 10:07:22 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 11/30/2016(UTC)
Posts: 48
Location: Belgium

Thanks: 6 times
Was thanked: 7 time(s) in 7 post(s)
Hi, I can confirm that the following test fails in VS runner as well. (did not check dotnet test)

[TestMethod]
public void TestUri()
{
new Uri(@"pack://application:,,,/Resources/notebook.png", UriKind.Absolute);
}

with the following exception:
System.UriFormatException: Invalid URI: Invalid port specified.

It is odd, because I run this code from a WPF application, and it is used to get a BitmapImage from this uri. (new BitmapImage(new Uri(...))
And in the WPF application, the bitmap is shown. (no error)

The test in the unittest project fails however, and it seems unrelated to ncrunch because the vs runner has the same "problem".
Thanks for your excellent work !
Dirk Maegh
#9 Posted : Tuesday, January 28, 2020 12:12:16 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 11/30/2016(UTC)
Posts: 48
Location: Belgium

Thanks: 6 times
Was thanked: 7 time(s) in 7 post(s)
I have been trying to fix this.

Debugging through .Net code (not just my code) seems to run fine - odd again.

Then I stumbled on this thread:
https://stackoverflow.co...-invalid-port-specified

All I had to do was to add the following code to fix things with the "Invalid port specified" exception.
[TestInitialize]
public void Initialize()
{
if (!UriParser.IsKnownScheme("pack"))
new System.Windows.Application();
}


Then finally I got the "Cannot locate resource 'resources/notebook.png'" - the error I was going for.
And I then could fix it by correcting the uri itself - I had to include the assembly name where the resource was registered.
as such:
@"pack://application:,,,/MyAssemblyName;component/Resources/notebook.png"

All is well that ends well.
Thanks again for your investigation !

(issue closed)
1 user thanked Dirk Maegh for this useful post.
michaelkroes on 1/28/2020(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.068 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download