|
You're welcome!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Hi,
I want to retrieve a list of all public contacts (email addresses in particular), as listed in exchange server when you click the "To" button while composing an email. The reason I'm doing this is so I can have an auto-complete text field in my C#/wpf application.
Initially I thought this would be simple, but after trying, I'm still stumped.
The main thing I'm trying now is using EWS Managed api to connect to Exchange server, I can provide more details if needed, basically I'm not getting email adrresses.
So my question is: is there any simple, tried-and-true method of doing this? There are so many practical uses of having Exchange contacts in a .NET application -- so surely this has been done before and documented!
Any comments?
|
|
|
|
|
|
My team and I were assigned this year a project at our faculty in which we need to make desktop WPF application like some kind of CV generator with functionality to import information from a Linkedin profile.
So, if you have any knowldege about it, any good books, tutorials or whatever you can think of and that can help us, please share, it would be very appreciated.
|
|
|
|
|
If you want books or tutorials in general, then you (and your team) should learn how to make full use of Google, Bing etc, to search the internet. If you want articles on WPF then start at http://www.codeproject.com/KB/WPF/[^]. If you have specific technical questions then please use the appropriate forum for the subject in question; this forum is for C# questions.
|
|
|
|
|
I have an windows service where I load several assemblies through reflection.
I load the these assemblies into separate AppDomains so I can unload them in runtime and load a newer published version.
The the load/execute asssembly operations are done inside a MarshalByRefObject and everything works on.
The problem is that all the assemblies I'm loading have a Run Method that receives a class, which has a TcpClient object inside.
When I call the method I get a assembly.
System.Runtime.Serialization.SerializationException: Type 'System.Net.Sockets.TcpClient' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
public class ApplicationConnection : MarshalByRefObject
{
public TcpClient Socket { get; set;};
}
public void Run(ApplicationConnection pInApplicationConnection) {
Object applicationInstance = applicationType.InvokeMember(null, BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, null);
applicationType.InvokeMember("Run", BindingFlags.InvokeMethod, null, applicationInstance, new object[] { pInApplicationConnection });
}
Inside the Run method, when I try to use the TCP client I get the serialization error.
How can I pass the TCP client object across AppDomains?
|
|
|
|
|
Good question, but I fear the answer is you can't.
AppDomains are there to isolate things from each other in the scope of a process. MarshalByRefObject is a thing for exchanging messages between domains which is why its trying to serialise the TcpClient. You don't talk to it, you talk to a proxy which looks like it that serializes the data back and forth.
Something like TcpClient, which is just a wrapper around some OS resources can't really be serialized. It's not a piece of data.
I've done quite a bit of this stuff before but not for years and years so I'm trying to think back how I did it. I think life is quite a bit simpler if you only try to pass primitive types between boundaries, and as the error suggests if you can't serialise it then you just can't.
So, what to do? Can you change the code so that it accepts and IpEndpoint rather than a TcpClient? Perhaps you could create some sort of decorator class wrapping up the TcpClient which inherits from MarshalByRefObject, but I have to say that idea makes me feel a little ill.
Tricky, and it'd be good to get some input from others.
Regards,
Rob Philpott.
|
|
|
|
|
Firs of al thanks.
The thing is I have a thread where the tcpListener is working, whenever a new connection is accepted I take the tcpClient object and I pass it to the loaded assembly which is in onother appdomain.
So, I believe that sending the IpEndPoint wouldn't do. Am I not right?
What if.... and stop when I start saying some idiot thing...
Could I let the tcpClient on the appdomain who created it and expose some static methods that would implement the functions I need. Just some basic send/receive wrappers.
Could the assemblies loaded in separate appdomains access the static methods I have on the primary appdomain? And if so, wouldn't I have some problems with the static class being instantiated multiples times?
|
|
|
|
|
OK, so the listener gets given a TcpClient on an incoming connection and you want to pass that to the AppDomain. Yes, you have a connected socket at that point so an end point would be no use. Is it possible to move the listener into the app domain at all?
Static methods AFAIK are global within the AppDomain, and cannot cross boundaries. So if you have a static class, each domain would get its own copy.
The only other approach I can think of is something like WCF port sharing. It is a separate process that listens on one port and then can route messages to different processes.
Or, rather than try to pass the TcpClient over boundaries, can't you keep it in the host domain, and just send packets of data to the AppDomain instead? Are you using the network stream on it? What sort of stream operations are you using?
Regards,
Rob Philpott.
|
|
|
|
|
On a design point of view doesn't make much sense to move the endpoint to the thread. Basically the app starts the listener and depending on the data it receives it executes the correct assembly.
At this point I'm just using the TcpClient.Socket.Send and the TcpClient.Socket.Receive methods.
After all this discussion I was thinking in the main thread (the one with the listener) to implement some communication mechanism that allows the tcp client to live in the main appdomain and just send/receive data to the assemblies appdomains.
What can I use?? NamedPipes or something like that?
|
|
|
|
|
Carlos Sousa wrote: How can I pass the TCP client object across AppDomains?
You can't. The reason is that the app domain barrier despite looking magical ONLY works via serialization. And noted by the other response a TCPClient represents resources (not data) which cannot be serialized.
You can however proxy the TCPClient. You create a proxy and it passes data across the barrier and gets data back. That data of course used by the real TCPClient to send receive messages. Note of course that given that all of the normal restrictions with threads applies it might be easier to create the TCPClient in the AppDomain though.
|
|
|
|
|
I can't create the TcpClient in the final appdomain
the main appdomain as a listener that when accepts a connection and based on the data it receives chooses on of the multiple assemblies loaded.
I then run the correct assembly in a separate appdomain and passing the tcpclient that the assembly should use to comunicate.
Since I can't pass the tcpclient I was planning to keep the tcpclients in the main thread and then implement somekind of mechanism that allows the assembly to send and receive data using a proxy implementation in the main thread.
what do you suggest me using for the implementation? Pipes for example?
|
|
|
|
|
Carlos Sousa wrote: implement somekind of mechanism that allows the assembly to send and receive data using a proxy implementation in the main thread.
A proxy.
Carlos Sousa wrote: what do you suggest me using for the implementation?
It just isn't that complicated if you are already familiar with app domains. You proxy a method call to 'send' data and another to 'get' data. That is what it does in the app domain. Outside the app domain those methods are implemented to send/get using the TCP client.
|
|
|
|
|
When you say "proxy" are talking about using the same "CreateInstanceAndUnwrap" method?
So in the new appdomains I would create a proxy to a class in the default appdomain, is that what you're talking about?
Thanks in advance.
|
|
|
|
|
Ok. It works.
In the secondary appDomain I created a proxy (through AppDomain.CreateInstanceAndUnwrap) to a class with static properties in the process default appdomain.
This class performs all the communication through the socket and just return the messages data.
Thanks for all the help.
|
|
|
|
|
|
That's what I did and it worked.
In the secondary appDomain I created a proxy (through AppDomain.CreateInstanceAndUnwrap) to a class with static properties in the process default appdomain.
This class performs all the communication through the socket and just return the messages data.
Thanks for all the help.
|
|
|
|
|
Hi everyone,
I saved a pdf file into my database in byte[] format. And now, I want to show it in PDF reader program when clicking a button. But I don't want to create the pdf file in my hard drives (because, if create it, I need to delete it).
Do you know how to export my data to pdf ?
Thanks and regards,
Tai
|
|
|
|
|
Apparently, it can be done - in C++ - but it's very complex, since Adobe PDF reader doesn't accept memory directly. See here: http://forums.adobe.com/message/2018299#2018299[^]
I've also seen a suggestion that you should create a ramdisk at runtime, save it to that, and open the file from there - which kinda indicates the level of desperation you need to have to do it.
Basically, I'd go with a "save it as a file in a particular folder and purge the folder regularly" approach, or possibly convert the PDF to HTML and display that.
But there doesn't appear to be a "nice" solution.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Very useful. Thank you very much !
|
|
|
|
|
You're welcome - sorry it's not better news!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
i am having face from which i cropped both the eye and lips and i want to match that pic with another pic and display message as image match can you help me for this its urgent please mail me expected answer.
|
|
|
|
|
No, it's NOT urgent. Everyone here volunteers their time. Questions are answered when we have the chance to, not when you demand it.
What you appear to be talking about is "facial recognition". Start reading these[^]. Good luck!
|
|
|
|
|
|
Hello everybody!
I have two forms: first form have a listbox1 (lists all members) with a button3_click to put a new member in listbox. the second form have four textboxes to type in properties from new member.
So my problem is how can I move the new member with them properties from form2 to form1.
My try is:
here I initialisize form1 with construct without parameters and second with properties-info for a new member
namespace DateiSchreiben
{
public partial class Form1 : Form
{
public Information info = null;
public string path;
public Form1() { InitializeComponent(); }
public Form1(Information info)
{
InitializeComponent();
this.info = info;
}
here I click button to getting start form2 to add a new member
public void button3_Click(object sender, EventArgs e)
{
AddItem item = new AddItem();
item.Show();
}
here is caption of form2 "AddItem" I initialsize form AddItem, when I typed in all info (four textboxes) press button1_click in form AddItem and save all infos in class Information which I want callback in form1. How can I do this?!
namespace DateiSchreiben
{
public partial class AddItem : Form
{
public AddItem()
{
InitializeComponent();
}
public void button1_Click(object sender, EventArgs e)
{
Information info = new Information();
info.FamName = textBoxA1.Text;
info.VorName = textBoxA2.Text;
info.AFid = textBoxA3.Text;
info.Key = textBoxA4.Text;
Close();
}
Finally I want print the new member in the listbox1 in form1
Regards Dick
|
|
|
|