473,406 Members | 2,293 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,406 software developers and data experts.

how can i get a memory address of dll in C# ?

29
how can i get a memory address of dll in C# program?
Jan 6 '10 #1
12 4367
Frinavale
9,735 Expert Mod 8TB
A dll is a Dynamic-link library. It does not have a memory location. When you use the dll in your application, memory will be used for the variables etc that the dll uses.

With this in mind, please explain your problem again because your question does not make sense.

-Frinny
Jan 6 '10 #2
Amera
29
ops , yes i'm sorry about that.

when i call a dll function that will set a value in that dll.

ex : void Set(char x)

how can i get the memory address of that value ?

i want to get that address in a C# program.
Jan 6 '10 #3
If void Set(char x) is C# then it does not have a constant address in the memory. The .NET garbage collector will move it around memory and you cannot assume that it will be at one location. There is a way to lock position of the variable in the memory and get its real address using Interop functions.
Can you describe your task more clear?
Jan 19 '10 #4
Amera
29
the task is to pass a char between C program and C# program in real time

using DLL.C & C# are not the same.so C would store at memory location

different than the C# each time i load the dll.

so in C# rather then loading the dll and calling the function get to get the char.i

get the address of that char that C has stored it.
Jan 20 '10 #5
If you are running two different programs then you cannot access memory of one program from another. This is basic protection mechanism of OS. One program does not have access to the memory of other program, whatever you do. In addition each program has its own address space. It means that some address can point to two different values in the memory in two different programs. Thus, an address of variable in one process points to absolutely different value in other process.
When you start some program Windows creates address space for it and all processing happening in that address space. Then you close program and windows delete everything related to your program from the memory. No way to leave something there. When next program is started it has access to pure clean memory.
As for me simplest way to communicate between processes is TCP/IP. Processes can communicate with each other over TCP/IP network protocol.
Jan 20 '10 #6
Please let us know if you really have two separate programs that have to communicate with each other. Or is it some other case? Do you need to load C library into C# program and work with it from C#?
Jan 20 '10 #7
Amera
29
yes , i have two separated programs that have to communicate with each other.
Jan 20 '10 #8
Amera
29
When you start some program Windows creates address space for it and all processing happening in that address space. Then you close program and windows delete everything related to your program from the memory. No way to leave something there. When next program is started it has access to pure clean memory.

i want the access to be at the same time.

C program sets value and the C# program gets that value at the same time

(real time).That means the memory is not empty right ??
Jan 20 '10 #9
I'm sorry to tell it to you. You cannot read memory from other program. This dead end. This function of CPU and OS to isolate process memory.
If you need to exchange data then you need to utilize some other approach than direct memory access.
Did I answered you question?
Jan 20 '10 #10
Amera
29
ok,it seems like it needs alot of time.so i'll use flat file instead.

but i'll still look for a way by using dll.

Thank you very much.
Jan 20 '10 #11
Amera
29
can i start the CLR in my C code and while calling the C# main method i pass parameter ???
Jan 29 '10 #12
You can. But you said that your C and C# are separate applications. By loading DLL of another application in your C application you will execute a copy of that DLL. It will not affect other already started application with the same DLL.
DLL is just a list of commands for processor. You can load and execute it within any number of application. Each time it will be loaded in particular process memory and all variables will be saved in that memory. Each time it will be separate.
If you a really have two application (two exe files) than you cannot load libraries of one into another to make them communicate.
If you actually have C program and C# dll that performs some operation you need then you can load it into C program. It is cold CLR hosting.
You can find documentation here.
Jan 31 '10 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: lupher cypher | last post by:
Hi, I'm trying to access memory directly at 0xb800 (text screen). I tried this: char far* screen = (char far*)0xb8000000; but apparently c++ compiler doesn't know "far" (says "syntax error...
32
by: John | last post by:
Hi all: When I run my code, I find that the memory that the code uses keeps increasing. I have a PC with 2G RAM running Debian linux. The code consumes 1.5G memory by the time it finishes...
5
by: Jeong-Gun Lee | last post by:
I'm writing a code of writing a value to a specific memory address. ================================================================= #include <stdio.h> int main() { long air; long...
30
by: jimjim | last post by:
Hello, This is a simple question for you all, I guess . int main(){ double *g= new double; *g = 9; delete g; cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<" "<<endl; *g =...
72
by: ravi | last post by:
I have a situation where i want to free the memory pointed by a pointer, only if it is not freed already. Is there a way to know whether the memory is freed or not?
12
by: aling | last post by:
Have following code snip: struct struc { int member1; int member2; } ; printf("&((struc*)0)->member2=%p\n", &((struc*)0)->member2); In VC7.1, the output is 4, the offset of member2 in struc.
62
by: ivan.leben | last post by:
How can I really delete a preloaded image from memory/disk cache? Let's say I preload an image by creating an Image object and setting its src attribute to desired URL: var img = new Image();...
0
by: Hypnotik | last post by:
My program is to simulate cache memory. I read in the info from 2 external files, 1) access 2) data in memory. When I read the information in I display the info...and it is all correct. However...
5
by: erfan | last post by:
vc++6.0,winxp. I use this code to see the memory address and the real value`s address below: #include<stdio.h> int main() { int a=22; int *p; int i; p=&a;
5
by: kumarmdb2 | last post by:
Hi guys, For last few days we are getting out of private memory error. We have a development environment. We tried to figure out the problem but we believe that it might be related to the OS...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.