I made a console application in C#, and I want to execute it from R. I am trying to run the code system(url) where url is the location of the file in the directory ApplicationPath/Bin/Debug.
I get this error when I do it: Warning message: running command ... had status 127.
Do I need to compile my code in Visual Studio in a particular way to get it to run? It's worth noting that another console application that I made the exact same way (at least I thought) does work using this method. The only difference I notice is that in the Debug folder, the one that works has a Visual Studio Solution User Options file, and the other does not. I'm not sure if that makes a difference, but if so how do you create that?
Related
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.
When I build or rebuild my solution I get the error:
Error CS2012 Cannot open 'C:\Users\myUserName\Documents\Visual Studio 2017\Projects\mySolutionFolder\myProjectFolder\obj\Debug\myExecutable.exe' for writing -- 'Access to the path 'C:\Users\myUserName\Documents\Visual Studio 2017\Projects\mySolutionFolder\myProjectFolder\obj\Debug\myExecutable.exe' is denied.'
However, when I build the project, it compiles fine. Once I build the project then a solution build doesn't throw any errors. I am running visual Studio 2017.
What I've tried (without success):
There is a second project in the solution, but I've unloaded it and it still errors.
I deleted the solution file and had visual studio create a new one.
Additional Info:
The error is somewhat random. Usually it errors out, but sometimes not. The odds of an error are reduced the longer I wait between a "Clean" and a rebuild. I have the same problem even when running in Administrator mode. I'm beginning to think it's a hard drive issue.
The application is still running.
\Debug\myExecutable.exe' is denied.' is telling you that you cant replace that because its currently open.
Open task manager and make sure that you end that process, and it should work fine after that.
This is usually what happens to me when I get that error.
Hope this helps
There is a file handle still open for myExecutable.exe. Probably because it is still running (check task manager/process explorer).
If that is not the case, you can try find out which process has has a handle open to said file:
get Process Explorer
Press Ctrl-F to find handle
Enter myExecutable.exe and look for processes that have a handle to the file.
So I've got an OPC-DA server in my program. When the user first runs the program or (even better) installs the program I want just one line of code to be run: myServer.registerServer;. And similarly when they want to uninstall the program it should run the opposite command: myserver.unregisterServer.
Now I'm guessing to do this I'm going to have to do something with a command line argument? maybe check to see if the passed value is equal to something and then if so I can register/unregister accordingly. Then if the passed value matches neither it just continues my program like normal. Issue is I'm not quite sure how to work this into the installer I'm using. Speaking of, I'm using Visual Studio Installer and using their 'Setup Project' project. Can what I'm asking for be done with this or do I need to make a separate installer. I've never had to do anything like this so any information you guys have is really appreciated.
The way you'd do this with a Visual Studio setup is to run the program as an install custom action with the command line that registers it, and an uninstall custom action with the command line that unregisters it.
Ideally you wouldn't run the program at all. Many (if not most) installation programs know what the required registry entries are and they add them to the registry entries that (in Visual Studio's case) are in the Registry view in the IDE. This data is typically always static and can be added to the system without running code.
Someone very helpful over on superuser wrote this script for me, the purpose of it is to wipe specific sectors on a running windows HDD with zeros. Here's the code:
http://pastebin.com/LwYFxhFS
I am not sure how to compile that and run it? Would i need to use like visual studio express and compile it then run it from cmd line? Also i am not sure if it will work as windows 7 basically stops any program (like hex editors) from messing with the HDD while it is the one in use.
You can just run it like:
wipe \.\PhysicalDrive0 0 512
where the first argument is the file name, the second is the offset, and the third is the >number of bytes. The number of bytes probably can't be over ~63 MiB.
Of course i wouldn't input 0 and 512 as that looks to delete the MBR.
Thanks for any help.
Two things.
1) Never compile code that you can't read, that code could easily wipe your entire hard drive with zeros (on purpose, or by accident).
2) Look at Eraser, does the same thing, but has been tested well.
Though to answer you question, yes visual studio C++ express should compile that.
Alright, lets break this down. You can compile the program use visual studio. Visual studio is an IDE (development environment) that allows you to write code easily. There are other compilers if you would like to use them instead. The entire idea is to make this code an executable.
To do this you need to do the following:
Download [Visual C++ 2010 express][1], and install
Start the program, click new project
Click Win32 Console Application
Name it something (like wipe, but it doesn't matter the name
Click finish
Paste this code (a bit modified for the pre compiled headers, to lazy to tell you to uncheck that box). http://pastebin.com/c3gZ3bct
Click the button F6
This should show that the code was compiled successfully (don't worry about the warnings)
There should be a tab on the right that says "Solution Explorer", open that. Right click on the name of the project (in my example it should be wipe), and click "Open Folder in windows explorer"
Go up one folder, then click on Debug.
There will be a file in there with the name of the project, and it is an executable. This is your program.
Open up cmd, navigate to this folder (type 'cd {folder path}' to get there), and then use the example the coder gave you to use his code.
Fell free to ask if part of this doesn't make sense, give me the step you are on, and why it doesn't make sense.
I have a project in c# which uses bindings to use some c++ code. The c++ code consists of multiple DLL's which are compiled using a makefile. Currently I'm trying to run the makefile using a pre build event which calls nmake. However to get it to find nmake I need to have a line in it like the following:
"$(DevEnvDir)..\..\VC\vcvarsall.bat"
Also, even with that line present, nmake doesn't produce any output at all in the output window. Neither does it throw any errors. I tried redirecting the output to a file and it doesn't write anything. I have reproduced all steps in my pre build event in a normal shell and it works fine. I figure I must be missing something. Why doesn't Visual Studio give me a Visual Studio shell for my pre build event? Is there a better way to run this makefile? If not, has anyone got any ideas as to why nmake isn't producing any output?
EDIT: D'oh! nmake wasn't running as I forgot to add 'call' to the start of the line, i.e:
call "$(DevEnvDir)..\..\VC\vcvarsall.bat"
I often build non VS-project (sometimes with nmake, sometimes with other build tools) as a part of a larger solution build.
I tend to make a simple batch file, which sets up the environment and then runs the make.
I call the batch file from a build event (often post-build on my stuff) - usually with a CD on the front:
cd ..\.. && armbuild
Never (that I can remember, anyway) had any problem with the output appearing in the console window.