Rlapack.dll is missing from your computer - c# and R - c#

When I run a c# application through Visual Studio 2010, where R is integrated, I get the error: The program can't start because Rlapack.dll is missing from your computer. Try reinstalling the program to fix this problem.
I tried reinstalling the program but it did not work.
I also tried putting it in the folder that has the Matrix in it but it did not work. This solution was suggested in StackOverflow Q.
I am running 64-bit Windows 7! The application is 32-bit.
There are two dll's. One in a folder called i386, and another one in the folder x64.
Here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using RDotNet;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string dlldir = #"D:\Program Files\R-2.15.0\bin\i386";
bool r_located = false;
while (r_located == false)
{
try
{
REngine.SetDllDirectory(dlldir);
REngine.CreateInstance("RDotNet");
r_located = true;
}
catch
{
MessageBox.Show(#"Unable to find R installation's \bin\i386 folder.
Press OK to attempt to locate it.");
}
}
}
}
}

I realize this has been answered, but that was back in 2012. For anyone still having this problem with R version 3.4.3 or later in 2018, especially while trying to follow the simple example from the r.net home page, below is what I did to fix it:
In your code, before the line REngine engine = REngine.GetInstance();, add this line REngine.SetEnvironmentVariables(#"C:\Program Files\R\R-3.4.3\bin\x64", #"C:\Program Files\R\R-3.4.3");.
right click project, go to build and uncheck "Prefer 32-bit".
copy Rlapack.dll from C:\Program Files\R\R-3.4.3\bin\i386
paste in both C:\Program Files\R\R-3.4.3\library\stats\libs\i386 and C:\Program Files\R\R-3.4.3\library\Matrix\libs\i386
copy Rlapack.dll from C:\Program Files\R\R-3.4.3\bin\x64
paste in both C:\Program Files\R\R-3.4.3\library\stats\libs\x64 and C:\Program Files\R\R-3.4.3\library\Matrix\libs\x64.
Such a pain, but that is what finally got it to work for me.

Here is what I just did and it worked: I put the dll in the bin folder of my application.

Try setting path variable before caling the dll:
var envPath = Environment.GetEnvironmentVariable("PATH");
string s = null;
if (Environment.Is64BitProcess)
s = #"C:\Program Files\R\R-2.15.0\bin\x64";
else
s = #"C:\Program Files\R\R-2.15.0\bin\i386";
Environment.SetEnvironmentVariable("PATH", envPath + Path.PathSeparator + s);

Related

The name 'File' does not exist in the current context

I am a beginner in c# programming. I am gettting error The name 'File' does not exist in the current context.
Problem must be in the line var v = File.ReadLines("dictionary.txt");
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
if (args.Length > 0)
{
var v = File.ReadLines("dictionary.txt");
Just add this using statement to the top of you file
using System.IO;
The compiler only recognises classes from namespaces that you have in the current context. You add namespace to the context using using statements. You can also use a fully qualified type name such as System.IO.File to refer to the class.
If you are using Visual Studio you can also place the cursor on the problematic symbol (File) and press Shift + Alt + F10
For anyone using Visual Studio 2015 this error will still occur even if System.IO is referenced. The problem is that by default a Visual Studio 2015 project will target both the dnx451 and dnxcore50 frameworks, and the System.IO assembly doesn't seem to be available for dnxcore50.
If you look in the project.json file you'll see a "frameworks" section. The quick fix is to comment out the "dnxcore50" entry so that you're only targeting dnx451:
"dnxcore50": {
"dependencies": {
"System.Console": "4.0.0-beta-22816",
"System.Collections": "4.0.10-beta-22816",
"System.Linq": "4.0.0-beta-22816",
"System.Threading": "4.0.10-beta-22816",
"Microsoft.CSharp": "4.0.0-beta-22816"
}
}
Add using System.IO; to your usings section.
File class is located in System.IO namespace.
Alternatively (if it is the only place in your code where you're using some type from System.IO) you can use fully qualified name of File like:
var v = System.IO.File.ReadLines("dictionary.txt");
But in the case when you need to access objects from some namespace multiple times in your code, it is better to inculde that namespace in usings.
You need to include System.IO add using System.IO next to other usings.
Add a using statement:
using System.IO
I'm working .Net Core in vs2017 and I have a similar problem.
To solve this problem you should change the target framework and install System.IO.FileSystem.
Using the following methods:
Right click the project and select properties.
in Application Tab and Target Framework section change to .NetStandard1.6
Then, To install System.IO.FileSystem, run the following command in the Package Manager Console
Install-Package System.IO.FileSystem -Version 4.3.0
1.In here first we need to create the object like this.
OpenFileDialog ofd = new OpenFileDialog();
2.Then you need to add this top of your code
using System.IO;
3.Finally you can change your code like this
OpenFileDialog.Title -----> ofd.Title
OpenFileDialog.Filter -----> ofd.Filter

Sikuli Integrator C#

I want to use SikuliIntegrator in C#.
I run VS as administrator, install SikuliIntegrator throught NuGet manager and want to test him on simple task.
Heres my code
using SikuliModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SikuliTrainingNet
{
class Program
{
static void Main(string[] args)
{
string MyPicture = #"c:\111\Sik\MyPicture.png";
SikuliAction.Click(MyPicture);
}
}
}
after running code (and have prepared MyPicture on screen), all i get is exception "###FAILURE" any idea why?
I dont wanna use Sikuli4Net, becose its look like it work on web aps and I need just few simple clicks on desktop aplication.
I try sikuli in Java, and there it works with no problem. But I need to make my program in C#.
I Used This Code For Sikuli4Net in C#,It Was Working For Me First You need add the References please see this link for Reference
http://interviews.ga/angularjs/sikulic/
static void Main(string[] args)
{
APILauncher launch = new APILauncher(true);
Pattern image1 = new Pattern(#"C:\Users\Ramesh\Desktop\Images\userName.png");
Pattern image2 = new Pattern(#"C:\Users\Ramesh\Desktop\Images\password.png");
Pattern image3 = new Pattern(#"C:\Users\Ramesh\Desktop\Images\Login.png");
launch.Start();
IWebDriver driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Url = "http://gmail.com";
Screen scr = new Screen();
scr.Type(image1, "abc#gmail.com", KeyModifier.NONE);
scr.Type(image2, "12345", KeyModifier.NONE);
scr.Click(image3, true);
Console.ReadLine();
}
I used this code and it was working fine. First you should open the webpage on which you want to click and then give a path of the image(it should be a part of the webpage)
here is my code:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SikuliModule;
using OpenQA.Selenium;
namespace WordPressAutomation.DifferentTests
{
[TestClass]
public class Sikuli
{
[TestMethod]
public void TestMethod1()
{
driver.Initialize();
driver.instance.Navigate().GoToUrl("https://www.google.co.in");
SikuliAction.Click("E:/img.png");
}
}
}
To use SikuliInyegrator, you need to check the execution results in these files:
C:\SikuliExceptionLog.txt
C:\SikuliOutputLog.txt
Also you need to:
Have installed JRE7 or superior
Have environment variable PATH with the location of the bin folder
See installed in your “control panel > program and features> visual C++ 2010 Redistributable Package” at x86 and x64 bits according to your java JRE runtime platform. If not, then download and install the Redistributable Package form Microsoft site.

DllNotFoundException for SQLite.Interop.dll (C# & SQLite)

I'm trying to get SQLite running in Visual Studio 2012 for C#.
However after going through a set of tutorials I still get the error DllNotFoundException for the SQLite.Interop.dll.
This is the full error I receive:
Unable to load DLL 'SQLite.Interop.dll': The specified path is
invalid. (Exception from HRESULT: 0x800700A1)
I have created a reference for the System.Data.SQLite.dll. Now I found that I have to add the SQLite.Interop.dll file into my project folder but I still get this error.
Oh and BTW, this is my code, if anyone is interested:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SQLite;
namespace SQLiteWinFormCS
{
public partial class Form1 : Form
{
private SQLiteConnection _sqlCon;
private SQLiteCommand _sqlCmd;
private SQLiteDataAdapter _db;
private DataSet _ds = new DataSet();
private DataTable _dt = new DataTable();
private string _dbPath = String.Empty;
public Form1()
{
InitializeComponent();
}
private void uiOpenDB_Click(object sender, EventArgs e)
{
Console(String.Format("You clicked {0}.", ((Button)sender).Name));
this._dbPath = uiDatabaseFilepath.Text;
Console("Filepath to DB = " + this._dbPath);
Console("Attempting to open DB connection...");
this._sqlCon = new SQLiteConnection(String.Format("Data Source={0};", #"\\Some-PC\ISC\Databases\testdbs\test.db3")); // << ERROR
Console("DB connection succesfull!");
}
private void Console(string text)
{
uiConsoleOutput.AppendText(text);
uiConsoleOutput.ScrollToCaret();
}
}
}
Can anyone help me get this thing working?
Thanks in advance.
Copy the SQLite.Interop.dll file into your debug folder.
For example "Projects\sqlite test18\sqlite test18\bin\Debug" place it here.
And dont add the Interop as a reference.
Add only these references
System.Data.SQLite
System.Data.SQLite.EF6
System.Data.SQLite.EF6
This solved my problem.
And I was using Sqlite x86 under x64 OS.
Dohh...
I was probably using a wrong System.Data.SQLite.dll.
For anyone who is interested you can find the new .dll file I downloaded here:
http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
I needed the .dll for the 4.5 Framework (x86); I clicked the first download link.
Also I am using just the System.Data.SQLite.dll, no other files!
Hope this answer helps someone else. :-)

The name 'ConfigurationManager' does not exist in the current context

Hi every one I am getting the following error: "The name 'ConfigurationManager' does not exist in the current context"
// namespaces
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
namespace Database1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static string GetConnectionString(string strConnection)
{
//variable to hold our connection string for returning it
string strReturn = "";
//check to see if the user provided a connection string name
//this is for if your application has more than one connection string
if (!string.IsNullOrEmpty(strConnection)) //a connection string name was
{
//get the connection string by the name provided
strReturn = ConfigurationManager.ConnectionStrings[strConnection].ConnectionString;
}
else //no connection string name was provided
{
//get the default connection string
strReturn = ConfigurationManager.ConnectionStrings["YourConnectionName"].ConnectionString;
}
//return the connection string to the calling method
return strReturn;
}
}
}
Have you added a reference to System.Configuration.dll?
You have to add reference to System.Configuration.dll
When you right click and click on the Add reference button
Click .Net tab in the open popup
There you should be able to locate the System.Configuration.dll file
This is the path:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Configuration.dll
also you can add reference to the :System:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Configuration.Install.dll
(hope it helps :))
Which version of .NET Framework and Visual Studio are you using?
ConfigurationManager is only available in .NET 2 and above. If you are using .NET Framework 1.x and Visual Studio 2002/2003, you won't be able to use this class at all.
http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx
Click "Other versions" link in the top of this page and you will see all versions it supports.
I ran into same issue using .Net Core, but using .NET Running Install-Package System.Configuration.ConfigurationManager in Package manager solved it for me.

How to use LAME (lame_enc.dll) in my C# web site

I am trying to use the lame_enc.dll in my C# .NET website and I am stuck.
I am working with: .NET Framework 3.5 / Visual Web Developer 2008 Express Edition / (Anything else you'd need to know?)
The first thing I did was get the code from C# MP3 Compressor on The Code Project. One thing I noted is that this project/post is from January 2004 (so, it's old)
I put the folders "yeti.mmedia" and "yeti.mp3" in my "App_Code" directory and deleted the "Bin" and "obj" directories within each. Then I tried to build the project. When I got errors I ended up excluding from the project the following files:
yeti.mmedia/AssemblyInfo.cs
yeti.mmedia/EditWaveWriter.cs
yeti.mmedia/EditWaveWriter.resx
yeti.mmedia/InFormatEdit.cs
yeti.mmedia/InFormatEdit.resx
yeti.mmedia/NumericTextBox.cs
yeti.mmedia/NumericTextBox.resx
yeti.mmedia/Win32Functions.cs
yeti.mp3/AssemblyInfo.cs
yeti.mp3/EditMp3Writer.cs
yeti.mp3/EditMp3Writer.resx
These seem to me to be the code files related to the Windows UI (which I don't need sonce I'm doing this on the web).
I also put the file "lame_enc.dll" in the Bin directory.
I created a test page based on the example on the page linked above:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using WaveLib;
using Yeti.MMedia;
using Yeti.MMedia.Mp3;
public partial class Documents : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
WaveStream InStr = new WaveStream(Server.MapPath(#"Temp/SomeFile.wav"));
try {
Mp3Writer writer = new Mp3Writer(new FileStream(Server.MapPath(#"Temp/SomeFile.mp3"), FileMode.Create), InStr.Format);
try {
byte[] buff = new byte[writer.OptimalBufferSize];
int read = 0;
while ((read = InStr.Read(buff, 0, buff.Length)) > 0) {
writer.Write(buff, 0, read);
}
}
finally {
writer.Close();
}
}
finally {
InStr.Close();
}
}
}
So, then I load this page and the error I get is:
Unable to load DLL 'Lame_enc.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
(I can't add the DLL as a reference in my project because it says "...This is not a COM component.") I have also tried getting the latest and greatest (lame3.98.4) dll and had the same problems. So, I assume there is something different about using this code in a website rather than another type of project. What it is I don't know though.
My guess, having not used LAME, is you have to install in on the box in question. After that, you should be able to use the code project code successfully. If that does not work, it appears Lame_Enc.dll is a native component and you will have to PInvoke methods.

Categories