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

Creating shared memory between applications in C#. *.dll perhaps?

hello. First off, I am very new to dll coding (meaning tonight) and I need to be able to share a List<bool> and a List<double> between my main application and other applications that can interface indirectly with it.

Basically The mian program will initalize the dll and pass in all the values. Then every about 50ms or so, new values will be given to the dll. I made a basic dll that I can send values to a global list in the dll, but my problem comes from I guess windows creates new memory blocks for each instance of the dll or something, so the my main application communicates with the dll, and the test application communicates with the dll, but neither have the same values, so they cannot speak to eachother.

My problem comes from me never using or implementing anything having to do with shared memory. I am not even sure if I am on the correct track. Would the keyword "stackalloc" have anything to do with this?

Justto give some more background, basically I developed some hardware that speaks to my application with a raw byte stream. Then the program interprets that byte stream into doubles and bools. So my application uses them fine. However others would like to interface their program with the hardware, but instead of re-decoding the stream, just grab the values from a dll somewhere.

I can clarify more if neccessary.
May 4 '07 #1
12 5345
anybody have any suggestions?
May 6 '07 #2
kenobewan
4,871 Expert 4TB
To my mind you have confused a number of concepts. I suggest getting back to basics and learning the fundamentals before starting such a project.
May 6 '07 #3
To my mind you have confused a number of concepts. I suggest getting back to basics and learning the fundamentals before starting such a project.
I just dont know what it is called that I am searching for. I can make C# applications no problem by themselves. The problem is now others want to interface with this program through the use of gettings values through a dll.

I have never written a dll, but I just wrote 1 that is basically useless for this application, but just to learn how they were put together. My understanding is that there needs to be shared memory for 1 dll to interface 2 programs. That is all I am asking.

Believe me in saying I am very proficient in C# basics and intermediate understandings. The actual "what goes on behind the scenes" I know some of, but I am learning more of. This would fall into the last category because it is not a standard thing to do.

Through googling, I came accross a few references to stackalloc which I have briefly used when interfacing with a byte stream. I thought it might have some applicability to this scenario.

And the hardware and my software are both already designed/coded. This dll for 3rd party apps, is what I need some help with.

So again, does anybody know what keyword to search for when trying to share a variable between 2 applications?
May 7 '07 #4
Anybody? I just need a couple keywords to search google for or just a small code snippet example please.
May 9 '07 #5
kenobewan
4,871 Expert 4TB
I believe our misunderstanding arose as I use visual studio to publish dlls. Has anyone else written dlls directly?
May 9 '07 #6
if it can be done in visual studio, I am all ears. That would be the new class library for a project correct?

Does visual studio automatically allow applications to share the same data?
May 9 '07 #7
Frinavale
9,735 Expert Mod 8TB
Have you tried storing the information in a database or something where it can be accessed by the various applications?
May 9 '07 #8
Have you tried storing the information in a database or something where it can be accessed by the various applications?
No I havent. Actually I had never thought of doing this. My experience with databases is limited to MySQL, so if you have a link to an example I would appreciate it.

Some quick questions you might be able to answer about databases:

1) WIll they update fast enough? I need about 18-50mS update times probably around 30-50 variables of bool/double...

2) Will it be useable with code programmed in other languages than C# or .NET as well, or will it be limited?

THankyou in advance.
May 10 '07 #9
Frinavale
9,735 Expert Mod 8TB
No I havent. Actually I had never thought of doing this. My experience with databases is limited to MySQL, so if you have a link to an example I would appreciate it.

Some quick questions you might be able to answer about databases:

1) WIll they update fast enough? I need about 18-50mS update times probably around 30-50 variables of bool/double...

2) Will it be useable with code programmed in other languages than C# or .NET as well, or will it be limited?

THankyou in advance.
I also have limited knowledge of using databases but I remember at one time I generated a few hundred threads which added information to the database and after less than a second of running it had added over a thousand entries.

I suggest creating a small test program to make sure that your database can handle the work load your program will be placing on it. My feeling is that it should be able to do what you're looking for, but I'm not 100% on that.

I don't really have an example for you on how to solve your specific problem but I'd recommend storing the information that needs to be shared between the applications into a table which every program can use.

Databases can be used in any programming language that supports them. I'm sure there's even a way to connect to them using C++, and I know that you can in Java...There's even a way to connect to them using Cobol.

-Frinny
May 10 '07 #10
Motoma
3,237 Expert 2GB
You may be able to get away with using a static declaration of your variables in your DLL.

If not, you should probably do a Google on C# IPC.
May 10 '07 #11
TRScheel
638 Expert 512MB
You may be able to get away with using a static declaration of your variables in your DLL.

If not, you should probably do a Google on C# IPC.
No, you cant do that.

DLL's are loaded into the program at launch. The program itself persists the static instance in ITS memory, not in the DLL.

The above ideas of databases would do the job. You might also look into XML, but bear in mind that using multiple programs is akin to having multiple threads, so be prepared to write code that 'waits its turn'.
May 10 '07 #12
When Kenobewan said to learn the fundamentals, he was right, though, he could have added what you (and others here) need to learn.

1 - There are different types of memory, CODE, DATA, STACK, DYNAMIC (HEAP).

2 - DLL's are used for CODE sharing (so the same code being used by several applications, is not loaded multiple times by the O/S). DLL's are not for sharing DATA across applications (though, within an app, one can share data across threads using STATIC variables within a DLL).

3 - Using a database can work, but as someone said, it can grow quickly if you are constantly ADDING data (new rows). If you are just UPDATING a set of rows, this can work nicely - though I suggest simple recovery mode to minimize your log file size.

4 - Your best bet (assuming no need to permanently store the data) is to use "memory mapped files" which despite its name, is using shared memory in the O/S (with the ability to have it stored to disk for retrieval later if/when all apps stop and restart - this is optional).

This ability (memory mapped files in Windows, originally called global shared memory segments in OS/2) has been around for ages. Lots of examples in books and on the web.

NOTE: You will need to worry about things like concurrency! Will two apps ever try to update the data? Are multiple data elements "related" such that they need to be updated "together" (since others may be reading data while another is writing it). These things must be considered when you determine how you're going to control (lock/unlock) access. Again, this is basic fundamentals when using "shared" memory.

Good luck.
Dec 2 '13 #13

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

Similar topics

1
by: Google Mike | last post by:
I'm using PHP 4.2.2 on RH9 Linux (with Progeny.com updates, in case you're wondering). I was using shared memory (shm* API) a great deal in my web applications because I have 1GB of RAM on this...
5
by: Claudio Grondi | last post by:
Background information: --------------------------------- in order to monitor mainboard sensory data as fan speeds, temperatures, applications like SpeedFan http://www.almico.com/speedfan.php or...
1
by: Eric Sasser | last post by:
I'm searching for anyone that has tried working with creating containersin shared memory using the April 2003 article by Grum Ketema in C/C++ UserJournal. I have a project up and running but am...
2
by: Rashad Rivera | last post by:
Hi gang, I have somewhat of a complicated question. I will try my best to explain. I have .NET assemblies that run in IIS's memory space. But I want to be able to interface with those...
15
by: Rob Nicholson | last post by:
A consequence of the ASP.NET architecture on IIS has just hit home with a big thud. It's to do with shared variables. Consider a module like this: Public Module Functions Public GlobalName As...
3
by: Grandpa Pete | last post by:
How can I share resources across all users of a web service for read/write access. *Situation* *one*: I want to have an in memory counter that all users of the webservice could access. Call...
0
by: Morantex | last post by:
Morantex announce the availability of the first beta preview of Persistore for Windows x86 and x64. This technology combines shared memory, data, and object persistence in a .NET component for the...
3
by: Jeff | last post by:
....still new to vb.net and vs 2005 web applications. I remain confused about the "shared" variable/table designation and the difference between "public" etc. I wish to place an entire table from...
5
by: Sune | last post by:
Hi all, I want to make data stored in-memory (not disk) available to several processes. My concern is that poorly written C applications with dangling pointers may(will) damage the data in this...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.