473,385 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Dll Import problem

** I forgot to ask one more thing, Just see the last few lines.

I have a Dll written in C. And I want to Import that Dll into my C#
program and use a function in the Dll. In a previous newsgroup article
I saw that I may need to wrap the Dll in a C++ .NET class and then use
that in my C# application. But when I run my program I get an error
saying

System.IO.FileNotFoundException: File or assembly name "abc", or one
of its dependencies, was not found.
File name: "abc"

abc is my wrapper project class library.

here is my wrapper class is given below. The lib name is wdll.lib and
the header is dll.h.
#include "dll.h"

#pragma comment(lib, "wdll.lib")

namespace MyWrapper {
public __gc class Class1 {
public:

static void myfunc1(long JobNo)
{
_libmain(JobNo);
}

static char * myfunc2(void *vJobRec, short field, short
subfield)
{
return (GETJF_NAME( vJobRec ));
}

};
}

Here is the actual dll header file.

extern "C" {

void WINAPI _libmain ( long JobNo );
void * WINAPI _getjobfield ( void *vJobRec, short field, short
subfield );

};

......

and here is where I am calling it.
using MyWrapper;

unsafe
{
Class1.myfunc2(null,0,0);
}

It throws the exception here,
System.IO.FileNotFoundException: File or assembly name "abc", or one
of its dependencies, was not found.
File name: "abc"

________________________________________________
So then I tried to acces the Dll in a more traditional way , but would
result in the same error. Here is just a simple console application
that I did,

using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Reflection;
using MyWrapper;

namespace test
{
class Class1
{
[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
static extern IntPtr LoadLibrary(string lpFileName);

[DllImport("wdll.dll")]
public static extern IntPtr
_getjobfield([MarshalAs(UnmanagedType.LPStr)] string s, short i1,
short i2);

[STAThread]
static void Main(string[] args)
{
// Esure current directory is exe directory
Environment.CurrentDirectory = Path.GetDirectoryName(
Assembly.GetExecutingAssembly().Location );

string dllPath = Path.GetFullPath(
@"C:\SoftwareDevelopment\testing\testing\test\test " );
LoadLibrary( dllPath );
Console.WriteLine( _getjobfield(null,0,0) );

}
}
}

*******
************************************************** ****************************
And in the previous mail I for got ask one more thing

since _getjobfield returns a char pointer how can I read that value.

currently what I am trying to do is

unsafe
{
Class1.myfunc2(null,0,0);
}

but when i DO THIS

unsafe
{
char * p = Class1.myfunc2(null,0,0);
}

It say's can not convert sbyte* to char*.

The thing is that I am sending char* so I do not know where sbyte
comes from
But it throws the exception, Can any one help.

Thanks
Nov 15 '05 #1
0 2011

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John Roth | last post by:
I've found a case where it seems that Python is importing two copies of a module without any reason or indication. It took me a while to verify that this is what is occuring: I had to write a...
5
by: Steve Holden | last post by:
This is even stranger: it makes it if I import the module a second time: import dbimp as dbimp import sys if __name__ == "__main__": dbimp.install() #k = sys.modules.keys() #k.sort() #for...
2
by: Jon | last post by:
It appears that (windows) python searches in the current working directory before looking in the local site-packages directory, or that '.' comes first in sys.path? The problem arises when I made...
2
by: Panard | last post by:
Hi, I'm experiencing a strange problem while trying to manage a ftp connection into a separate thread. I'm on linux, python 2.4.3 Here is a test : ------ ftp_thread.py ------ import ftplib...
6
by: robert | last post by:
I get python crashes and (in better cases) strange Python exceptions when (in most cases) importing and using cookielib lazy on demand in a thread. It is mainly with cookielib, but remember the...
1
by: Nick Craig-Wood | last post by:
I've been dumping a database in a python code format (for use with Python on S60 mobile phone actually) and I've noticed that it uses absolutely tons of memory as compared to how much the data...
0
by: Victor Lin | last post by:
Hi, I got some problem with import. I have some python file that should be executed. Something like unit-test or other small tool. The project is not so small. So I want to separate these files...
5
by: Stef Mientki | last post by:
hello, The import statement "import sqlite3" gives the error given below. In simple programs, the import statement (sometimes) succeed, and I can indeed access the database. So I guess there is...
10
by: nisp | last post by:
Hi all ! I'm trying to capture stderr of an external module I use in my python program. I'm doing this by setting up a class in my module overwriting the stderr file object method write. The...
13
by: Rafe | last post by:
Hi, I am in a situation where I feel I am being forced to abandon a clean module structure in favor of a large single module. If anyone can save my sanity here I would be forever grateful. My...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.