473,394 Members | 1,746 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,394 software developers and data experts.

DLL Import

Hi,
I have a general DLL "genDLL.dll",this dll open other dlls by calling
generalDll.openDll("dll1.dll").
I mad a form with got dll name in new,and then this for open the new dll by calling the openDll function.
the problem is when I make more than one instance of this Form from MDI the All form work with same dll even if thay are deferent.

The following Is what I do in MDI form :
1- childForm childForm_1 = new childForm("Dll1.dll");
2- childForm childForm_2 = new childForm("Dll2.dll");
3- childForm childForm_3 = new childForm("Dll3.dll");
************
in childForm
***********
private string dllFileName;
public childForm(string FileName)
{
this.dllFileName = FileName;
}

[DllImport("generalDll.dll")]
extern static int OpenDll(string DllName);

private void MemoryShow_Load(object sender, System.EventArgs e)
{
OpenDll(dllFileName);
}

How to creat new DLL instance?

Nov 16 '05 #1
6 4842
Yosi,

From what I can tell, you want to call the same function that is defined
in different DLLs. You can't do this at runtime through the P/Invoke layer,
it has to be known at compile time.

However, in the next version of .NET, you will be able to load a DLL
dynamically, get the address of a function in it, and then map it to a
delegate with the same signature. This should allow you to do what you
want. However, that is still a ways away.

If you need a solution now, you should write an unmanaged piece of code
which will take the dll name, and the function you want to execute, as well
as the parameters, and execute it.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"[Yosi]" <Yo**@discussions.microsoft.com> wrote in message
news:DC**********************************@microsof t.com...
Hi,
I have a general DLL "genDLL.dll",this dll open other dlls by calling
generalDll.openDll("dll1.dll").
I mad a form with got dll name in new,and then this for open the new dll by calling the openDll function. the problem is when I make more than one instance of this Form from MDI the All form work with same dll even if thay are deferent.
The following Is what I do in MDI form :
1- childForm childForm_1 = new childForm("Dll1.dll");
2- childForm childForm_2 = new childForm("Dll2.dll");
3- childForm childForm_3 = new childForm("Dll3.dll");
************
in childForm
***********
private string dllFileName;
public childForm(string FileName)
{
this.dllFileName = FileName;
}

[DllImport("generalDll.dll")]
extern static int OpenDll(string DllName);

private void MemoryShow_Load(object sender, System.EventArgs e)
{
OpenDll(dllFileName);
}

How to creat new DLL instance?

Nov 16 '05 #2
I think you're getting confused between classes, DLLs, and ActiveX (COM) DLLs.
Classes are programmatic objects that you instantiate instances of.
DLLs are blocks of code that are loaded (normally automatically when needed) into the application's memory space, so that it can call the *FUNCTIONS* the DLL exports.
ActiveX (COM) DLLs are a special type of DLL that expose language-independent classes and conform to strict specifications and have things like interfaces etc, their complexity is huge but since they are very standard automating the creation and consumption of them is a relatively easy process.

I think you need to take a step back - you appear to not be able to see the wood for the trees.
Nov 16 '05 #3
BTW the things that tell me you are incredibly confused about how to use DLLs are the fact that you say things like

"this dll open other dlls" (DLLs don't *open* other DLLs as such... they might reference them, and as such cause them to be loaded aswell, but something that is 'open' is more like a database connection or a file)

"got dll name in new" BAD, BAD idea. (presumably from your crap grammar you mean you are passing the dll name to the constructor of a form?) What a JOKE! DLLs are a compile time thing, not decided dynamically at runtime. They are (or should be) a part of the application's main code, just in a separate file and possibly shared. They are not a magic lamp with which you can just summon up whichever genie you please.
Maybe you should use VB6 - it allows a lot more daft kludges than C# such as those you appear to be accustomed to.

Oh, and by the way. Learn english.

"[Yosi]" wrote:
Hi,
I have a general DLL "genDLL.dll",this dll open other dlls by calling
generalDll.openDll("dll1.dll").
I mad a form with got dll name in new,and then this for open the new dll by calling the openDll function.
the problem is when I make more than one instance of this Form from MDI the All form work with same dll even if thay are deferent.

The following Is what I do in MDI form :
1- childForm childForm_1 = new childForm("Dll1.dll");
2- childForm childForm_2 = new childForm("Dll2.dll");
3- childForm childForm_3 = new childForm("Dll3.dll");
************
in childForm
***********
private string dllFileName;
public childForm(string FileName)
{
this.dllFileName = FileName;
}

[DllImport("generalDll.dll")]
extern static int OpenDll(string DllName);

private void MemoryShow_Load(object sender, System.EventArgs e)
{
OpenDll(dllFileName);
}

How to creat new DLL instance?

Nov 16 '05 #4
No ,I want to call same function in same DLL, the Dll manage the Instance of DLL.
When I call Open the DLL creat new DLLInstance.
What I can't UnderStand is how all the variable in the ChildForm Instants is deferent but the dll instance is same?

What I know Is when I make new Class Instance all variables will reallocated, And Also the DLL variables (new Instance) !!!!! Is it True this work in MFC ? ????????????
"Nicholas Paldino [.NET/C# MVP]" wrote:
Yosi,

From what I can tell, you want to call the same function that is defined
in different DLLs. You can't do this at runtime through the P/Invoke layer,
it has to be known at compile time.

However, in the next version of .NET, you will be able to load a DLL
dynamically, get the address of a function in it, and then map it to a
delegate with the same signature. This should allow you to do what you
want. However, that is still a ways away.

If you need a solution now, you should write an unmanaged piece of code
which will take the dll name, and the function you want to execute, as well
as the parameters, and execute it.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"[Yosi]" <Yo**@discussions.microsoft.com> wrote in message
news:DC**********************************@microsof t.com...
Hi,
I have a general DLL "genDLL.dll",this dll open other dlls by calling
generalDll.openDll("dll1.dll").
I mad a form with got dll name in new,and then this for open the new dll

by calling the openDll function.
the problem is when I make more than one instance of this Form from MDI

the All form work with same dll even if thay are deferent.

The following Is what I do in MDI form :
1- childForm childForm_1 = new childForm("Dll1.dll");
2- childForm childForm_2 = new childForm("Dll2.dll");
3- childForm childForm_3 = new childForm("Dll3.dll");
************
in childForm
***********
private string dllFileName;
public childForm(string FileName)
{
this.dllFileName = FileName;
}

[DllImport("generalDll.dll")]
extern static int OpenDll(string DllName);

private void MemoryShow_Load(object sender, System.EventArgs e)
{
OpenDll(dllFileName);
}

How to creat new DLL instance?


Nov 16 '05 #5
The one how need to back working with VB6 is you, before starting with your Jok.
The application I'm trying to do is already done in MFC.
We have 4 DLLs each one have open/read/write/close but each one have it own protocol for example Read/Write from/to IO/Uart/SMBus,I2C,Memory.....
The C# application Import General DLL witch have get DLL name and creat new instance this new instance is saved in the general DLL variable.
Each Form is same GUI but deferent execution In each one for example have Address = offset = 0x20 for example,
But the display value is deferents because each form shod read the value from deferents places , from IO,MEM,I2C,UART.....

when I open the form several times from command line (.exe) this working will but when this is a child of MDI form this not work,.
Thanks for helpping me , and belive me you need along time to do 50% of what I have already done

"Beeeeeeeeeeeeves" wrote:
BTW the things that tell me you are incredibly confused about how to use DLLs are the fact that you say things like

"this dll open other dlls" (DLLs don't *open* other DLLs as such... they might reference them, and as such cause them to be loaded aswell, but something that is 'open' is more like a database connection or a file)

"got dll name in new" BAD, BAD idea. (presumably from your crap grammar you mean you are passing the dll name to the constructor of a form?) What a JOKE! DLLs are a compile time thing, not decided dynamically at runtime. They are (or should be) a part of the application's main code, just in a separate file and possibly shared. They are not a magic lamp with which you can just summon up whichever genie you please.
Maybe you should use VB6 - it allows a lot more daft kludges than C# such as those you appear to be accustomed to.

Oh, and by the way. Learn english.

"[Yosi]" wrote:
Hi,
I have a general DLL "genDLL.dll",this dll open other dlls by calling
generalDll.openDll("dll1.dll").
I mad a form with got dll name in new,and then this for open the new dll by calling the openDll function.
the problem is when I make more than one instance of this Form from MDI the All form work with same dll even if thay are deferent.

The following Is what I do in MDI form :
1- childForm childForm_1 = new childForm("Dll1.dll");
2- childForm childForm_2 = new childForm("Dll2.dll");
3- childForm childForm_3 = new childForm("Dll3.dll");
************
in childForm
***********
private string dllFileName;
public childForm(string FileName)
{
this.dllFileName = FileName;
}

[DllImport("generalDll.dll")]
extern static int OpenDll(string DllName);

private void MemoryShow_Load(object sender, System.EventArgs e)
{
OpenDll(dllFileName);
}

How to creat new DLL instance?

Nov 16 '05 #6
> The one how need to back working with VB6 is you, before starting with your Jok.

Whatever. You NEED to learn English *a lot* better - simply 'getting by' is obviously doing you a disservice as other programmers aren't understanding your problems, or mistaking them for something much more trivial (as seems to be the situation in this case).

A lot of people take an instant xenophobic reaction to posts that start 'How to do xxxxx...?'
because asking 'How do I...? ' as 'How to...?' is the most common language mistake foreigners make. I just skip straight over them, thinking that I could make a reply, but the person on the other end wouldn't understand it.

The application I'm trying to do is already done in MFC.
I personally think MFC is a load of crap - I can't get over the fact that it's a huge, huge great load of code that actually *DOES* very little.
We have 4 DLLs each one have open/read/write/close

"open", "read", "write" and "close" are VERBS. That means they're a DOING word - they're ACTIONS. They can't be possessed. i.e., a DLL can't "have" open. A DLL might *DO* an "open" operation, but it doesn't *have* open.
but each one have it own protocol for example Read/Write from/to IO/Uart/SMBus,I2C,Memory..... The C# application Import General DLL witch have get
The word "get" should almost never follow the word "have". It sticks out like a sore thumb and confuses the meaning of the whole sentence.
DLL name and creat new instance this new instance is saved in the general DLL variable.
This makes me think you're building your project to rely on a huge technical malpractice. What the HELL is a "general DLL variable"????

Each Form is same GUI but deferent execution In each one for example have Address = offset = 0x20 for example,
But the display value is deferents because each form shod read the value from deferents places , from IO,MEM,I2C,UART.....
and???

Thanks for helpping me , and belive me you need along time to do 50% of what I have already done


Ah but that's where you're wrong. Because I *wouldn't do* what you're doing, at least not in the same way.... certainly not with MFC. There's so many people writing stupid unnecessary network services and packet sniffers and all sorts of stupid crap network components, none of it's really necessary. They just like playing with networks - fine! but why pretend there's a big point to it? Why not just write a network game?
Nov 16 '05 #7

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

Similar topics

0
by: Stian Søiland | last post by:
all examples performed with: Python 2.3+ (#2, Aug 10 2003, 11:09:33) on linux2 (2, 3, 0, 'final', 1) This is a recursive import:
0
by: Vio | last post by:
Hi, I've been trying to embed (statically) wxPy alongside an embedded py interpreter on a linux/gtk box. At one point, for some reason misc.o linking reported "multiple definitions of...
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...
1
by: mark | last post by:
In Access 2000 and 2002, I have created an import specification to import the fixed-width recordset below into an existing table. I am having strange problems with the import of the date and time...
4
by: Bruce W. Roeser | last post by:
All, I'm reading a book by Charles Petzold (Programming VS.Net). Pretty good content but am confused about the difference. From the text: ...
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...
7
by: Ron Adam | last post by:
from __future__ import absolute_import Is there a way to check if this is working? I get the same results with or without it. Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) on win 32 ...
5
by: W. Watson | last post by:
Is there a single source that explains these statements? ------------------------------ from Tkinter import * from Numeric import * import Image import ImageChops import ImageTk import time...
9
by: rsoh.woodhouse | last post by:
Hi, I'm trying to work out some strange (to me) behaviour that I see when running a python script in two different ways (I've inherited some code that needs to be maintained and integrated with...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.