Why is it actually impossible to load onnxruntime.dll? - c#

Using the tutorial from the developers at Microsoft, I followed the tutorial created at https://learn.microsoft.com/en-us/dotnet/machine-learning/tutorials/object-detection-onnx.
I made sure to install CUDA V10.1.243 and cuDNN 7.6.5 from Nvidia's site.
Yet somehow, even after copying the entire contents of C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin to my project binary's directory at machinelearning-samples\samples\csharp\end-to-end-apps\ObjectDetection-Onnx\OnnxObjectDetectionApp\bin\Debug\netcoreapp3.0, I keep running into the following error while compiling the example program MS provided: Exception thrown: 'System.DllNotFoundException' in System.Private.CoreLib.dll An exception of type 'System.DllNotFoundException' occurred in System.Private.CoreLib.dll but was not handled in user code Unable to load DLL 'onnxruntime' or one of its dependencies: The specified module could not be found. (0x8007007E).
This should make sure they are accessible from the PATH right? I'm also including their original location in NVIDIA GPU Toolkit in the system PATH as well. I am using the latest version of Visual Studio 2019 to load and compile this solution. Is there anyone out there that has been able to run this code successfully, and if so, how?

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...

Visual Studio UI Testing

I have done some extravagant web searching for a solution to no avail.
I am working with a UI tester written by a man who is no longer with the company.
Currently it is hanging up on opening the browser for testing the website.
I have no idea what I'm doing.
BrowserWindow.CurrentBrowser = "ie";
"An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Microsoft.VisualStudio.TestTools.UITesting.dll
Additional information: Could not load file or assembly 'Microsoft.VisualStudio.TestTools.UITest.WindowsStoreUtility, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."
Figured out what the issue is. I can't run it directly. I have to pass it to MSTest.exe with arguments.
If you don't know where MSTest.exe is, here is where mine is, and most likely yours.
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\MSTest.exe

How to execute with a copied dll from another machine - c#

I am trying to provide a colleague with a dll that is from my build so she can execute with the changes i have made. Unfortunately she gets the following error
The system was unable to launch the requested screen. --->
Unable to display screen.
---> System.IO.FileLoadException: Could not load file or assembly 'file:///name.dll' or one of its dependencies. Operation is not
supported. (Exception from HRESULT: 0x80131515) --->
System.NotSupportedException: An attempt was made to load an assembly
from a network location which would have caused the assembly to be
sandboxed in previous versions of the .NET Framework. This release of
the .NET Framework does not enable CAS policy by default, so this load
may be dangerous. If this load is not intended to sandbox the
assembly, please enable the loadFromRemoteSources switch
Now if she were trying to run it in visual studio i could set the loadFromRemoteSources switch - however this dll is replacing a dll in an install version on a vagrant box. How can i enable the dll to run in this scenario?
Thanks

How to debug a TypeLoadException during ngen

Situation
I'm using ngen to create native images of my assemblies during the installation. This worked fine until recently and I've no idea what broke it. Sadly the ngen output isn't very helpful. It just says that it couldn't find or load a type, but doesn't say which type.
What's very weird is that ngen only fails if my assembly was build with msbuild (either run by the TFS Team Build or by myself in the command line), but if I build it with Visual Studio 2010 ngen works fine! I've tried msbuild from .NET 4.0 (my local machine), .NET 4.5 (TFS 2012 Update 3) and .NET 4.5.1 (TFS 2013), all result in the same error in ngen. It's just the build in the Visual Studio 2010 GUI that works. But the error only occurs in ngen, runtime behavior is the same - it falls back to the IL assembly, but works fine.
I even tried to debug ngen.exe and mscorsvw.exe, but all I could see was that some native exceptions were thrown, one of them was a EETypeLoadException, but I couldn't get additional information about the exceptions. But I'm not experienced at all when it comes to debug native applications.
Questions
Does anyone know how I could get more information about the ngen error? The name of the type which causes the error would be great.
I've already read somewhere that Visual Studio doesn't just invoke msbuild for building, but why are there that big differences?
Additional Information
The TFS runs msbuild during the automated build. No additional msbuild parameters are configured and the build process template is the default one from TFS 2012 Update 3.
When I run msbuild myself I'm using the following command on the same file and folder that is also used in Visual Studio. Configuration and Platform are also the ones active in Visual Studio and chosen in the TFS Build.
msbuild Solutionname.sln /t:Rebuild /p:Configuration=Release /p:"Platform=Mixed Platforms"
The ngen error happens on all machines that I tested, so it's not something specific to my installation.
Here is the full ngen output, even with the verbose switch:
C:\Program Files (x86)\MyProgram>ngen install MyProgram.exe /verbose
Microsoft (R) CLR Native Image Generator - Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
Installing assembly C:\Program Files (x86)\MyProgram\MyProgram.exe
1> Compiling assembly C:\Program Files (x86)\MyProgram\MyProgram.exe (CLR v4.0.30319) ...
1>Error compiling C:\Program Files (x86)\MyProgram\MyProgram.exe: Could not find or load a type. (Exception from HRESULT: 0x80131522)
1> Finished compiling assembly C:\Program Files (x86)\MyProgram\MyProgram.exe ...
1>Ngen failed to generate native code for image C:\Program Files (x86)\MyProgram\MyProgram.exe because of the following error: Could not find or load a type. (Exception from HRESULT: 0x80131522)
1>Ngen will retry compilation of image C:\Program Files (x86)\MyProgram\MyProgram.exe
1> Compiling assembly C:\Program Files (x86)\MyProgram\MyProgram.exe (CLR v4.0.30319) ...
1>Error compiling C:\Program Files (x86)\MyProgram\MyProgram.exe: Could not find or load a type. (Exception from HRESULT: 0x80131522)
1> Finished compiling assembly C:\Program Files (x86)\MyProgram\MyProgram.exe ...
1>Uninstalling assembly C:\Program Files (x86)\MyProgram\MyProgram.exe because of an error during compilation: Could not find or load a type. (Exception from HRESULT: 0x80131522)
Could not find or load a type. (Exception from HRESULT: 0x80131522)
You can use Fuslogvw.exe (Assembly Binding Log Viewer) and take a look at the assemblies ngen is trying to load. That may provide a clue. You may want to capture binding logs for both cases you mentioned (msbuild and VS) and then compare them. I am guessing mbuild is introducing some dependencies not consumable by NGEN.
And when you say runtime behaviour is same, you mean the app is working as it's supposed to ? Then it must be running with IL not the Native Images. Again, you can use Fulogvw to check that.

C# opengl texture

I want to use textures in opengl on my C# application.
I'm using the Tao Framework and I used this code
http://www.gamedev.net/community/for...opic_id=405453 (post #2)
But I got this runtime error:
An unhandled exception of type 'System.DllNotFoundException' occurred in WindowsFormsApplication1.exe
Additional information: Unable to load DLL 'DevIL.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Could someone help me?
Is there any other way to do this?
I had this problem with GLU.FreeGLUT.dll but when I installed Tao Framework solved my problem .
before that i copy dll to win32 and there was in dotnet Directory and add to references in project but I recieved this message : "An unhandled exception of type 'System.DllNotFoundException' "
It looks like the problem is the loading of the dll. You should make sure the dll is properly importer in your project through the references. Also make sure that you haven't moved or deleted the dll after you have added it to your project.
It suggests you are missing DevIL. Try getting it and installing it before proceeding.

Categories

Resources