UnityContainer.Resolve crashes when .NET Native tool chain is enabled - c#

We have a Windows 10 UWP app that runs fine under Debug builds and crashes under Release builds. What it is about release builds that makes it crash is that .NET Native tools chain is enabled - disabling that allows the app to run. But that's not a real fix as it needs to run with .NET Native tool chain if you intend to publish to the store.
We use Microsoft.Practices.Unity for DI. Here's an example of how we register some classes:
container.RegisterType<IBoardView, BoardView>();
And then, in our app we resolve it as follows:
container.Resolve<IBoardView>();
It works fine unless I run it with .NET Native, in which case I get the following exception:
An exception of type 'Microsoft.Practices.Unity.ResolutionFailedException' occurred in Microsoft.Practices.Unity.dll but was not handled in user code
Additional information: Resolution of the dependency failed, type = "WindowsUniversal.ViewModels.Interfaces.IBoardViewModel", name = "(none)".
Exception occurred while: while resolving.
And in the output window I get:
Exception thrown: 'System.NullReferenceException' in System.Linq.Expressions.dll
Exception thrown: 'System.NullReferenceException' in Microsoft.Practices.Unity.dll
Exception thrown: 'Microsoft.Practices.Unity.ResolutionFailedException' in Microsoft.Practices.Unity.dll
An exception of type 'Microsoft.Practices.Unity.ResolutionFailedException' occurred in Microsoft.Practices.Unity.dll but was not handled in user code
Additional information: Resolution of the dependency failed, type = "WindowsUniversal.ViewModels.Interfaces.IBoardViewModel", name = "(none)".
Exception occurred while: while resolving.
Exception is: NullReferenceException - Object reference not set to an instance of an object.
At the time of the exception, the container was:
Resolving WindowsUniversal.ViewModels.Interfaces.IBoardViewModel,(none)
All this works under Debug or Release when .NET Native is disabled. Now I know .NET Native has it's limitations, reflection being one of them. I guess I'm asking how to get around this?
Any insights would be greatly appreciated, thanks.

Related

'System.IO.EndOfStreamException' in JetBrains.ReSharper.TaskRunnerFramework.dll

When trying to run a very basic xunit test in debugging mode my test project throws several exceptions which seems to come from ReSharper.
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Could not find file 'C:\Temp\test\TestProjekt\TestProjekt\bin\Debug\TestProjekt.xunit.runner.json'.
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Could not find file 'C:\Temp\test\TestProjekt\TestProjekt\bin\Debug\xunit.runner.json'.
Managed Debugging Assistant 'LoadFromContext'
The assembly named 'xunit.runner.utility.net452' was loaded from 'file:///C:/Program Files (x86)/JetBrains/Installations/ReSharperPlatformVs15_0a4dd3ad/xunit.runner.utility.net452.dll' using the LoadFrom context. The use of this context can result in unexpected behavior for serialization, casting and dependency resolution. In almost all cases, it is recommended that the LoadFrom context be avoided. This can be done by installing assemblies in the Global Assembly Cache or in the ApplicationBase directory and using Assembly.Load when explicitly loading assemblies.
testException thrown: 'System.Threading.ThreadAbortException' in xunit.execution.desktop.dll
Thread was being aborted.
Exception thrown: 'System.Threading.ThreadAbortException' in xunit.execution.desktop.dll
Thread was being aborted.
Exception thrown: 'System.Threading.ThreadAbortException' in mscorlib.dll
Thread was being aborted.
Exception thrown: 'System.UnauthorizedAccessException' in mscorlib.dll
Access to the path 'TestProjekt.PDB' is denied.
[...]
Exception thrown: 'System.UnauthorizedAccessException' in mscorlib.dll
Access to the path 'TestProjekt.PDB' is denied.
Exception thrown: 'System.IO.EndOfStreamException' in JetBrains.ReSharper.TaskRunnerFramework.dll
Attempted to read past the end of the stream.
The program '[14628] JetBrains.ReSharper.TaskRunner.CLR45.x64.exe: Program Trace' has exited with code 0 (0x0).
The program '[14628] JetBrains.ReSharper.TaskRunner.CLR45.x64.exe' has exited with code 0 (0x0).
What I have tried so far:
Moved Project away from Default Profile Folder to c:\temp...
Starting Visual Studio 2017 with local admin rights
Updating ReSharper to the latest Version currently available (2018.2.1)
Clearing ReSharper Cache
Clean entire solution
Create new empty class library Project and pull in xunit nuget packages afterwards (.NET Framework 4.7.2)
Downgrading solution to .NET Framework 4.7
Reinstall ReSharper and choose "Install for all users" instead of my user only, to ensure there are no left Overs in my Profile...
It seems that the same test project can be debugged without any issue on the Workstation of a Team mate... so there must be something wrong with my Installation.
What am I doing wrong here? Any ideas?
Enabling Just my Code in Visual Studio at least stops this first Chance exceptions from cluttering my Output. So thats Kind of a Workaround...

Unit test for UWP app failed to run on Visual Studio 2015

I have trouble running unit test on one of my machine, the test app just shut down after few seconds. Here is the output show when debugging the test:
Exception thrown at 0x7525D8A8 in UnitTestProject1.exe: Microsoft C++ exception: EETypeLoadException at memory location 0x0A17C5F0.
Exception thrown at 0x7525D8A8 in UnitTestProject1.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
Exception thrown at 0x7525D8A8 (KernelBase.dll) in UnitTestProject1.exe: 0x40080201: WinRT originate error (parameters: 0x8007274C, 0x000000B9, 0x0EE4F6AC).
Exception thrown: 'System.Exception' in mscorlib.ni.dll
WinRT information: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.ServiceModel.dll
Exception thrown: 'System.Net.Sockets.SocketException' in mscorlib.ni.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in System.Private.ServiceModel.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in mscorlib.ni.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in mscorlib.ni.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in mscorlib.ni.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in mscorlib.ni.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in mscorlib.ni.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in mscorlib.ni.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in mscorlib.ni.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in mscorlib.ni.dll
Exception thrown: 'System.ServiceModel.EndpointNotFoundException' in mscorlib.ni.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.ni.dll
Those exceptions is not related to my app at all, as my app dont need internet and the code in test method is not reached. They are from the test framework.
The same solution run test fine on every other machine (same Windows 10 build). I think the problem is that the system on troubled machine turn off some services required for unit testing. I cant find any thing related anywhere. What should I do to fix that, I dont want to re-install Windows.
Seems like the connection with the Test Emulator can't be established. When you build the TestApp make sure that you have set the Build configuration to Debug - Any CPU (not ARM)
Also, you shouldn't run the test project by hitting F5 but run the tests from the TestExplorer.
I end up reinstall VS 2015 and the problem now gone.

Ranorex System.TypeInitializationException

After I use my code when Ranorex is installed is works fine, but after uninstalled it, I have a library of Ranorex payed version, but I don't install it on my PC, just I need the library. there an exception showed with this line of code
Form form = Host.Local.FindSingle<Ranorex.Form>("form[#processname='" + pr.ProcessName + "']");
On debug Mode shows ;
'Host.Local' threw an exception of type 'System.TypeInitializationException'
Exception :
Exception thrown: 'System.TypeInitializationException' in Ranorex.Core.dll
Additional information: The type initializer for
'Ranorex.Core.ElementEngine' threw an exception.
For Ranorex and it's components to work atleast Ranorex Runtime Licencse is required.

Matlab builder NE 2012A x64 migreting to 2014B X64

I'm trying to convert my system from matlab 2012a x64 to matlab 2014b x64. However I'm getting this error. i'm using .Net 4.5, visual studio 2012 + update 5.
A first chance exception of type 'System.Exception' occurred in MWArray.dll
Additional information: Start-up options discovered in multiple assembiles.
then I hit F5 and I get:
A first chance exception of type 'System.TypeInitializationException' occurred in MWArray.dll
Additional information: The type initializer for 'MathWorks.MATLAB.NET.Utility.MWMCR' threw an exception.
I press F5 again and I get:
A first chance exception of type 'System.TypeInitializationException' occurred in MWArray.dll
Additional information: The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWArray' threw an exception.
here is my code:
private static MWArray ConvertBlackLevelResultsToMWArray(BlackLevelData blackLevelData)
{
var blackLevelResultsGroupedbyExposure = from blResult in blackLevelData group blResult by blResult.ExposureTime;
var exposuresCount = blackLevelResultsGroupedbyExposure.Count();
var blackLevelCells = new MWCellArray(1, exposuresCount); //the exception is here
I have used .net reflector in order to go over all of the dependencies in other DLL files, they all have refernce to the correct MWarray version 2.14.1.0
Can you suggest A way to find out what is my problem?
thanks
You must remove all the attributes
[assembly: MathWorks.MATLAB.NET.Utility.MWMCROption ("- nojit")]
from all places, to which were added for MCR 2012a.

How to download file from SkyDrive on Windows Phone

I am using sample from https://github.com/liveservices/LiveSDK but it isn't working. I managed to run the PhotoSkyOnTheGo project, but after logging in I get 3 exceptions:
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll
A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll
What am I doing wrong or what source code should I use?
Try to change Mobile client app setting to yes in manage.dev.live.com inMy applications > yourApp > API Settings tab

Categories

Resources