我是C#的新手,可能做错了什么!
我有它的连接和工作与EmotivXavier控制面板。我编写了一个代码从EEG Emotiv中获取csv的原始数据。
我从Emotiv GitHub下载了Community。在那里,我可以找到DotNetEmotivSDK.dll。与许多其他人一起:
我将所有这些文件添加到项目"/bin“文件夹中,并试图在Visual中引用所有这些文件。只有一个在工作
尽管如此,我仍然可以在C#中使用Emotiv类,只有在这个单一的dll中。
但是,当我运行我的代码时,会出现以下错误:
错误说:
未处理的异常: System.DllNotFoundException:无法加载DLL 'edk.dll':找不到指定的模块。(除HRESULT: 0x8007007E外)在Emotiv.EdkDll.Unmanged_IEE_EmoEngineEventCreate() at Emotiv.EdkDll.IEE_EmoEngineEventCreate() at Emotiv.EdkDll.IEE_EmoEngineEventCreate 756 at Emotiv.EmoEngine..ctor()在C:\Users\Becchi-PC\Documents\EEG\community-sdk-master\examples\C#\DotNetEmotivSDK\EmoEngine.cs:line 393 at Emotiv.EmoEngine.getC:\Users\Becchi-PC\Documents\EEG\community-sdk-master\examples\C#\DotNetEmotivSDK\EmoEngine.cs:line 418 at C:\Users\Becchi-PC\Documents\EEG\EEG_v2\Program.cs:line 21 at EEG.EEG_Logger.Main(String[] args)中的_Instance()
缺失的dll (Edk.dll)是我不能引用的其中之一。
这是我的完整代码:
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Reflection;
using Emotiv;
namespace EEG
{
class EEG_Logger
{
EmoEngine engine; //Criando a variavel com a Engine
int userID = -1; //ID do usuario
string filename = "outfile.csv"; //Arquivo de saida
EEG_Logger()
{
//Instanciando a Engine
engine = EmoEngine.Instance;
engine.UserAdded += new EmoEngine.UserAddedEventHandler(engine_UserAdded_Event);
//Conectando ao EEG
engine.Connect();
//Criando o Header do CSV
WriteHeader();
}
void engine_UserAdded_Event(object sender, EmoEngineEventArgs e)
{
Console.WriteLine("User Added Event has occured");
//Gravando o usuario
userID = (int)e.userId;
//Permitindo a aquisicao de dados
engine.DataAcquisitionEnable((uint)userID, true);
//Determinando o tempo do buffer
engine.DataSetBufferSizeInSec(1);
}
public void WriteHeader()
{
TextWriter file = new StreamWriter(filename, false);
string header = "COUNTER,INTERPOLATED,RAW_CQ,AF3,F7,F3, FC5, T7, P7, O1, O2,P8" +
", T8, FC6, F4,F8, AF4,GYROX, GYROY, TIMESTAMP, ES_TIMESTAMP" +
"FUNC_ID, FUNC_VALUE, MARKER, SYNC_SIGNAL,";
file.WriteLine(header);
file.Close();
}
void Run()
{
// Handle any waiting events
engine.ProcessEvents();
// If the user has not yet connected, do not proceed
if ((int)userID == -1)
return;
Dictionary<EdkDll.IEE_DataChannel_t, double[]> data = engine.GetData((uint)userID);
if (data == null)
{
return;
}
int _bufferSize = data[EdkDll.IEE_DataChannel_t.IED_TIMESTAMP].Length;
Console.WriteLine("Writing " + _bufferSize.ToString() + " lines of data ");
// Write the data to a file
TextWriter file = new StreamWriter(filename, true);
for (int i = 0; i < _bufferSize; i++)
{
//Escrevendo no arquivo
foreach (EdkDll.IEE_DataChannel_t channel in data.Keys)
file.Write(data[channel][i] + ",");
file.WriteLine("");
}
file.Close();
}
static void Main(string[] args)
{
EEG_Logger p = new EEG_Logger();
for (int i = 0; i < 10; i++)
{
p.Run();
Thread.Sleep(100);
}
}
}
}
请帮帮我!
发布于 2017-01-12 16:31:18
首先,您不应该将all放在项目的bin文件夹中,因为这是在构建之后将引用的all复制到的位置,而不是您应该引用它们的位置。因此,一种选择是将所请求的dll复制到项目中的某个位置,并从那里引用它们(例如: Lib文件夹)。
其次,您可以在github上找到Emotiv,还有一个示例解决方案,包含几个项目:https://github.com/Emotiv/community-sdk/tree/master/examples/C%23。您将注意到,这些项目引用了DotNetEmotivSDK项目,因此这将是解决问题的另一种选择。
https://stackoverflow.com/questions/41613340
复制相似问题