SwiPICs.dll PlEngine.Initialize FileNotFoundException - c#

For educational purposes, one of our college subjects requires a project that integrates any instance of Prolog with any other GUI supportive language. I went with C# as I have the most experience with it.
I'm trying to learn by example of my fellow college colleagues from higher years. They gave me their repos to download their code and to see how it all comes together. And this is where the problems started.
No matter what I do, what tutorial I follow, what tips from other sources I apply, the error will not change: FileNotFoundException was unhandled: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in SwiPlCs.dll.
I've tried using SWI 32 bit/64 bit, VS 2015/2017 with 32/64 bit builds, redownloading the DLL as a nuget package. None of them seem to work.
InitializeComponent();
igra.popuniSlagalicu += igra_popuniSlagalicu;
igra.vratiOdgovor += igra_vratiOdgovor;
String[] param = { "-q" };
PlEngine.Initialize(param);
PlQuery.PlCall("use_module(sudoku)");
This is the first time I felt helpless and desperate while trying to debug code. Literally stuck on a single line for 5 days without any progress whatsoever.

The error is not very clear, but is caused by the fact that the program needs to know where to find the DLLs that run SWI-Prolog are located. There are a few ways to do this but the simplest is to add the directory (e.g. C:\Program Files\swipl\bin) containing the SWI-Prolog executable (swipl-win.exe) to the Windows system PATH variable.
After changing the system PATH variable you will need to restart Visual Studio if necessary.

Related

Application crashes at certain point when run without debugger attached? c#

I have a small application, it launches properly without debugger and all the features work except one which uses IronOcr (package from NuGet package manager). When I try to use this feature the program just closes.
When I launch this application from within visual studio, everything works fine. No errors and all features work. I get the same result if I run it and attach the debugger to it afterwards. However if I run the exe by launching the exe /bin/release and do not attach the debugger it crashes when I try to use the feature involving IronOcr.
I tested this on a virtual machine, same results with/without debugger. I then tested it on a different computer (fresh install of windows only having VS installed) it gave me this error if debugger is attached:
System.IO.FileNotFoundException: 'Could not load file or assembly 'IronOcr, Version=2021.2.1.0, >Culture=neutral, PublicKeyToken=c2cbcea5ea3f6d8d' or one of its dependencies. The system cannot >find the file specified
I've spent the last few days looking up a reason for this but I have not found one so far that fixes the issue.
What is confusing me the most is:
I assume the error that causes the program to close is the same error that causes it to give this error on the different PC. When I run it through VS it has no issues (it finds the file?) but running it from the exe it cannot find the file. I'm not moving the exe, just running it where it is in the bin/release.
I'm hoping this program will be able to run as a standalone exe.
I am still relatively new to c# and VS, the error may be glaringly obvious, or I may be using the wrong words causing me to not find a solution.
probably a bit too late, but your problem certainly comes from the fact you're using the free licence of IronOCR. It seems that this one only works when the debugger is attached.
If you catch the exception, you get that message:
IronSoftware.Licenses.Exceptions.LicensingException: IronOcr must be
licensed for deployment outside of the Visual Studio development
environment. https://ironpdf.com/licensing
In my opinion this is too restrictive for proper evaluation, so I gave up trying to use it.
Make sure IronOcr.dll is exist at same directory as your executable file.
Try to execute your application from Bin/Debug and see if it runs ok or not.
Check to see if IronOcr.dll exist in Bin/Debug but does not exist in Bin/Release. if so then copy it from Bin/Debug to Bin/Release.

Cannot open SteamTrade.dll for writing. Access to the path is denied

I get the following error:
Severity Code Description Project File Line
Error Cannot open 'D:\Programming\SteamBot\SteamTrade\obj\Debug\SteamTrade.dll' for writing -- 'Access to the path 'D:\Programming\SteamBot\SteamTrade\obj\Debug\SteamTrade.dll' is denied.' SteamTrade D:\Programming\SteamBot\SteamTrade\CSC
I'm unable to compile the source with Visual Studio 2015 Community Edition on Windows 10.
After searching the internet the majority of the answer was to disable malware protection. I'm using Bitdefender Total Security 2016. First I tried to add an exception to the folder, after that even tried to disable the product, but still nothing. I can't get the project to build, failing with the same exact error.
Any idea?
Edit 1:
Still no idea. If I would be on Linux or on Drive C, I could imagine that I have actually no permission to write, but on Windows on drive D, there is no such thing. Today I'll be trying to compile it on a Virtual Machine to be sure that it's not my antivirus program. Still any suggestion is welcomed.
Alright, so after trying out everything I decided to try it on a virtual machine and it work from start. Then I tried it on a new source on my computer then it worked.
I was quite surprised why, so I removed the exception in the anti virus software, then it didn't work anymore. So I added the exception again, but it still didn't worked. So what I did next is downloaded the source in a new folder and added to the exception before I tried to build it then it worked.
Solution:
So the short answer is if you want to make it work, you get the source from git, then add it to the exception in your anti-virus software and only then you try to build it, because if you build it beforehand it won't work no matter what. This is probably related to Bitdefender Total Security 2016, but at least it started working.

Exception in SharpDX.dll

I'm working on a school project with four others.
We're writing a game in C# and Monogame.
They pass around the source code without any problems, but I cannot run the program. I get this error on 1 out of 5 computers.
I've been researching, but can't seem to find an answer of how to fix this.
Visual studio gives the following error:
An unhandled exception of type 'SharpDX.SharpDXException' occurred in SharpDX.dll
Additional information: HRESULT: [0x887A0005], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_DEVICE_REMOVED/DeviceRemoved], Message: GPU-enhedsforekomsten er blevet suspenderet. Brug GetDeviceRemovedReason til at bestemme den relevante handling.
I have Nvidia SLI GT cards, and I'm afraid that's what's causing the problem.
I have no problem with other projects.
Edit:
Okay, after having solved this forever ago, and totally forgetting to write it here, here's what I recall I did:
The error was thrown because I was trying to use something outside of the bounds of the sprite sheet. Fixing that, fixed the issue. Weird how some cards react.
I guess you are right. The problem is caused by your graphic card:
here is a link which explains your error.
"DXGI_ERROR_DEVICE_REMOVED
0x887A0005
The video card has been physically removed from the system, or a driver upgrade for the video card has occurred. The application should destroy and recreate the device. For help debugging the problem, call ID3D10Device::GetDeviceRemovedReason."
I had the same issue. Figured this crap out after 2 hours. You have to go to your projects bin folder and delete all the .dll files with the word "Sharp" in it. Once thats done DO NOT build your code again, just run it. It should work.
If you build the code again, C# will generate the .dlls for you.
Let me know if you found any other better solution. Thanks
EDIT: You also have to copy all the files from the Bin of another working Monogame into the bin of your game. Sample game is found at https://farseerphysics.codeplex.com/downloads/get/722128.

Unable to load DLL XXX.dll, Can not find specified module.(Exception from HRESULT: 0x8007007E)

Recently I wrote a small winForm program using C# language. In the app I use C# to invoke a "*.dll" file written in C++. It works all right in my Visual Studio 2012 and on my computer, but when I move it to other computer, it always pops an error about “ Unable to load DLL ' *.dll',can not find specified module.(Exception from HRESULT: 0x8007007E). ”.
I've searched the internet for solution. There are also some similar questions regarding problems that others met and it seems that they also have not found the right solution yet. I also tried some methods like moving my '*.dll' file to windows\system32 or write the app current directory to System Enviroment Variable, but this also didn't work.
Now I really don't know how to deal with it. So I'll be very appreciative if someone could give some help.
I'm new here and thanks very much.
Pretty old post but shows up first in Google so I am gonna post my solution to the issue: I was writing a minimal DLL in C++ which I integrated in a minimal C# console application and got the same error that you stated above. The final fix is simple: Your target PC might not have the appropriate VS redistributable package installed. In my case (VS 2013) it was this one here: http://www.microsoft.com/en-us/download/details.aspx?id=40784 for some reason it does not work to copy the required DLLs from the system32 folder manually... what a freak bug taking me half a day to find out. I did not find this anywhere online, will do some cross-posting now...

C# app doesn't work in other computers

Why does my app compiled with C# not work on other computers?
I have the .Net Framework 4.0 already installed.
When I open my .exe on another computer, I get the error:
ERROR SIGNATURE:
Event Type: clr20r3
P1: myapp.exe
P2: 1.0.0.0
P3: 502051f
P4: myapp
P5: 1.0.0.0
P6: 502051f
P7: 2
P8: 6
P9: System.IO.FileNotFoundException
A system.io.filenotfoundexception usually means your program tried to open a file that wasn't there. It is likely that your program is trying to access some file using a path or filename that doesn't exist or is in a different location on other computers. Without knowing what myapp.exe is supposed to do, I can't answer any further.
Your solution is probably to re-write your app so that it handles that exception better in some way, such as by checking for the file's existence before trying to open it.
It sounds to me like a case of missing references. Check your references from the solution explorer or go into bin/debug or bin/release (depending on your configuration) and make sure to copy all the dlls or exes that your project depends on
Most likely the app is trying to load an assembly and is failing to find it
A little off topic but ideally with any application you want to add some 'unhandled' exception handling to write to a log file or the event log so that you can capture more of the exception stack.
Often you only get the last exception message and you also don't see the call stack
You can roll up exceptions quite easily using something like this:
string RollupException(Exception ex)
{
StringBuilder sb = new StringBuilder();
sb.Append(ex.Message);
while(ex.InnerException != null)
{
sb.Append(Environment.Newline);
sb.Append(ex.Message);
ex = ex.InnerException;
}
return sb.ToString();
}
You can also use the EventLog class to write to the event log.
Info here:
http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx
Check out the examples - remember to register an event source first!
It looks like your program's missing a DLL (or the DLL's been misplaced):
http://social.msdn.microsoft.com/Forums/pl-PL/clr/thread/782217a8-46bd-4371-9915-28655d9b2c2f
Deciphering the .NET clr20r3 exception parameters P1..P10
A simple way around this would be to create a setup project - this will then bundle your project's dependencies into an install file. I don't think that option's available if you're on Visual Studio Express edition though. . .
http://www.dreamincode.net/forums/topic/58021-deploying-a-c%23-application-visual-studio-setup-project/
If you're pretty sure it's a .net framework that's missing, the following tool will show you what's on your machine / your client's, so you can figure out what's missing:
http://www.asoft.be/prod_netver.html
Hope that helps.
I had exactly the same problem and like Joao eventually found it was caused by the Windows Forms LineShape. This adds the Microsoft.VisualBasic.PowerPacks reference to your project. When you then run it on a system that doesn't have the PowerPacks installed you just get that unhelpful System.IO.FileNotFoundException error with no clue as to which file is missing.
Yes I know this should get fixed up if you go the trouble of making a proper distribution setup which will prompt the user to install ..., etc, etc. But I just want to be able simply to copy my EXE to another system.
To solve: remove any LineShapes from your form and then remove the refences to VisualBasic and VisualBasic.PowerPacks in your references.
David
[Using VS2008 SP]

Categories

Resources