How easy is this in C#?  
Author Message
Bwilhite





PostPosted: Visual C# General, How easy is this in C#? Top

Sorry for the very general subject line. I've been working on a problem for some time right now that will have two separate applications passing information back and forth and preferably sharing objects. To date, I've been working on this problem using C++ and the WinAPI. However, the WinAPI and Visual Studio c++ 2005 don't really integrate very well.

I've been taking a look at C# lately, and it seems like the language would support this effort pretty well through the use of marshalling (a new concept to me), and multi-threading. I would like to hear from some experienced C# programmers their opinion on how easy this would be to implement in C#. There is an example in "Programming C#" that seems like it would accomplish the type of ends for which I am looking. However, I'm reluctant to spend even more time learning a new language, but I think that it might be worth it in the end. If you have more comments to offer, please do so. A simple yes or no would also be sufficient, as I'm just trying to see whether it would be worth my time.

One more caveat: one of the programs I will be using (the client app) basically uses a morphed version of the C language and so it misses some functionality that would be useful. It can refer to DLLs, though, so my plan is to call a method from a DLL which will then connect to the server app. I don't think this should be a problem in C#...at least that is what it seems.

Brandon W.


Visual C#12  
 
 
Gabriel Lozano-Moran





PostPosted: Visual C# General, How easy is this in C#? Top

The answer you seek is "Yes" and "No"

 
 
Bwilhite





PostPosted: Visual C# General, How easy is this in C#? Top

Let me boil it down:

Is it possible to easily accomplish my overall objective in C#, given the constraints of only being able to use DLLs in the 'client app '

Brandon W.

p.s. read "easily" however you want :)

 
 
CormacRedmond





PostPosted: Visual C# General, How easy is this in C#? Top

What else would you need besides DLLs
 
 
Gabriel Lozano-Moran





PostPosted: Visual C# General, How easy is this in C#? Top

The answer you seek is "it depends"



 
 
Bwilhite





PostPosted: Visual C# General, How easy is this in C#? Top

Thanks for the replies...I hope I get more opinions.

I don't think I need anything other than a DLL and the custom written "server app." The problem I'm having in C++ is in getting the two to talk to each other, the rest I've got figured out. Really, I've found a solution for this problem too, but I'm using VS 2005 Express, and it seems a little buggy in the whole compiling process when it comes to the WinAPI. From the research I've done to date it seems like C# supports inter-process communications more 'natively' than C++ (i.e. no need to include WinAPI and use those functions-C# seems to have this functionality built in). If this is true, then I'll switch to C#. Thanks for any comments :)

Brandon W.

 
 
James Curran





PostPosted: Visual C# General, How easy is this in C#? Top

Is it possible to easily accomplish my overall objective in C#,

Answering that question is rather tough, as you haven't really told us what your overall objective is, beyond "two separate applications passing information back and forth". Give us more detail, and we can give you a more detailed answer.



 
 
Gabriel Lozano-Moran





PostPosted: Visual C# General, How easy is this in C#? Top

What functionality are you talking about Are you talking about things like threading Because actually these are types in the Base Class Library that can be used in COBOL.NET if you want... When you talk about C++, I am guessing that you mean unmanaged C++ Why not use managed C++ Or mix them

 
 
Bwilhite





PostPosted: Visual C# General, How easy is this in C#? Top

The answer you seek is "it depends"



hmmmm....after reading the documentation you pointed me too, it seems like the c++ side is more complicated...at least compared to the example I saw in the book using c#

Brandon W.

 
 
Gabriel Lozano-Moran





PostPosted: Visual C# General, How easy is this in C#? Top

I have absolutely no idea what example you are referring too, perhaps you can enlighten us

 
 
Bwilhite





PostPosted: Visual C# General, How easy is this in C#? Top

Ok, more detail then.

Here's what I have in mind...at least it's the model I'm working with right now. The client-side app will pass data to the DLL, probably via an object found in the DLL. The data will mostly be double and int and it will be updated frequently, as much as a 5-6 times/second, possibly double that. When first called, this object will connect with my server-side application (note...I'm not actually sending across a network, for now, this is all on the same machine). The object will pass a pointer to itself to the server app, which will also pass another pointer to a "communication" object located on the server app. So I'll have a data object instantiated in the DLL and a communication object on the server app. Every time the data from the client is updated, the server will need to analyze the data and possibly send a communication to the client app. I will actually have several, probably 4-5, client apps running at once...all feeding data into the server app. [An alternative scheme would be to have the data object instantiated on the server app and have the client app writing to this instance. I don't think I really have a preference for exactly where the data resides.]

That's the basic program flow. Because of the calculation and multiple processes involved, I would like to make the sharing of data as fast as possible...my reasoning for utilizing pointers. I think that would be fastest (I think). Really I just want to be able to move the data quickly and easily. Other than that, I frankly don't care about the exact implementation. So if it sounds generic...well that's why.

The implementation that I have been working on is to use the Win API SendMessage() call to pass the appropriate pointers. Naturally, other actions need to be taken besides just calling SendMessage :) I'm new to Windows programming, so that is probably the main reason that I'm having so much difficulty with C++, but at least part of my difficulty is coming from Visual Studio. It seems that C# *might* be better integrated with Windows than C++ and so hopefully the process will be easier to program. Alternatively, maybe there is another simple way to accomplish my means in C# that I don't know about. That's also part of what I'm trying to determine, because really I don't know everything C# is capable of and how simple it would be to implement other solutions.

My original intent with this thread was *just* to get a feel for whether C# was really much better at inter-process communications than C++. But, if I get more help by sharing more...then great :) If anyone can point me to a good tutorial on an implementation that would be good too :) Thank you for the responses so far.

Brandon W.

 
 
Bwilhite





PostPosted: Visual C# General, How easy is this in C#? Top

 
I have absolutely no idea what example you are referring too, perhaps you can enlighten us

Sorry for my obtuseness.

Please see my post below giving the basic algorithm I'm following.

The example I'm referring to was in "Programming C#" by Jesse Liberty. It was an example used to illustrate marshalling across apps via http. In this example he instantiated an object (a simple calculator) on the server which was used by the client (these were both on running on the same machine). I believe this could work for my purposes, and his implementation could provide a basic framework from which to expand my own code and functionality. Given what I'm trying to accomplish, does this sound reasonable

BW

 
 
boban.s





PostPosted: Visual C# General, How easy is this in C#? Top

Check here, especially post from Rizwan Sharp where it gives some good links to find out how to solve this:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1050004&SiteID=1

 
 
ne_plus_ultra





PostPosted: Visual C# General, How easy is this in C#? Top

In my views, if you are already not a seasoned programmer in C++ including Win32 then I would suggest to use C#. C# is comparatively much easier to pickup and also has a steep learning curve...

Besides all those things you are mentioning can be done in C#, like the earlier post mentioned, take a look at .Net Remoting technology, this technology is a powerfull alternative for IPC and even across Devices and Networks compared to classical Win32 cryptic calls..

I hope this helps

Cheers

Nataraj Chakraborty



 
 
Bwilhite





PostPosted: Visual C# General, How easy is this in C#? Top

Thank you all for the input on this. It seems like some of the remoting technology, at least, is also available for C++, but the documentation seems clearer for C#. This is what I had suspected. Frankly, I did not run across the remoting solution until after I had decided to look at C#...and believe me, I was looking everywhere for a solution.

My conclusion is that I don't believe my learning curve to implement in C# will be greater than that for the Win32 API, and I believe that C# is better integrated into the environment I'll be working in. Also, the documentation explaining how to implement the kinds of solutions I need seems to be more prevalent and clearer too...so I'll be picking up C# it looks like :)

Again, thanks to all.

Brandon W.