|
Hello,
This is the situation I have an assembly A (plugin) loaded into separate app domain, that assembly fires a couple of events.
And i have a class B created using the default App domain.
Now Class A raises and event and event handler in class B catches that event, but since it is called from another App domain (A) it cannot see variables of app domain B (all variables are null) in this case a public static object that is 100% not null on app domain B.
I think i understand why the variable is null, but how do i execute event handler code in app domain B so that code executed in app domain B will see the variables initialized?
I have tried CrossAppDomainDelegate but it can only call mehods that don't have any parameters, and since this is an event handler it has parameters and not standard event signature but with a custom EventArgs.
How can i solve this problem.
Thank you!
|
|
|
|
|
Make sure the objects passed in the delegate arguments, and the result type, are either simple objects or inherit from MarshalByRefObject. You will probably need to create proxy classes for complex types in your plugin to achieve that. For example from my lobby server:
public class LobbyProxy: MarshalByRefObject {
public BaseLobby lobby;
public LobbyProxy(BaseLobby l){ this.lobby = l; }
public void Log(object sender, String msg){ lobby.Log(sender, msg); }
public MemberInfo Member(int id){ return lobby.Member(id); }
public MemberInfo GetMember(string name){ return lobby.GetMember(name); }
public bool MemberInGame(int member, int game){ return lobby.MemberInGame(member, game); }
public int MemberIndexInGame(int member, int game){ return lobby.MemberIndexInGame(member, game); }
}
public class ServerLobbyProxy: LobbyProxy {
public ServerLobby serverLobby;
public ServerLobbyProxy(ServerLobby l) : base(l) { this.serverLobby = l; }
public void SendMessage(int id, uint command, byte[] msg){ serverLobby.Server[id].SendMessage(command, msg); }
public void SendMessage(int id, uint command, byte[] msg, byte pt){ serverLobby.Server[id].SendMessage(command, msg, pt); }
}
public class ClientLobbyProxy : LobbyProxy {
public ClientLobby clientLobby;
public ClientLobbyProxy(ClientLobby l) : base(l) { this.clientLobby = l; }
public void SendMessage( uint command, byte[] msg){ clientLobby.Connection.SendMessage(command, msg); }
public void SendMessage( uint command, byte[] msg, byte pt){ clientLobby.Connection.SendMessage(command, msg, pt); }
public int MyID { get { return clientLobby.MyID; } }
public MemberInfo Me { get { return clientLobby.Me; } }
public void DoChat(int DefaultScope, String msg, int GameID){ clientLobby.DoChat(DefaultScope, msg, GameID); }
}
This is actually the other way around (so plugins can call methods in the main app domain) as I find that design cleaner. (Plugins are responsible for making sure that they respond to events and call whatever they need to in the main app domain, via these well defined interfaces.) But the same thing should work from the other side too.
|
|
|
|
|
Hi guys,
i have a project in which I'm supposed to retrieve data from the database and put d data into an XML file (with a defined schema), and send that file encrypted and all.
My problem, however, is getting the data into XML.
Please anyone knows how to achieve this?
He who goes for revenge must first dig two graves.
|
|
|
|
|
You're getting answers in Q/A for this question. Why did you post it here as well?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
I've had no answers. I wouldn't be posting here if I had an answer to this. Pls can u help me out?
He who goes for revenge must first dig two graves.
|
|
|
|
|
That's not the way the site works. This is a volunteer site where people help out as and when they can. If you post a question in multiple locations, then answers to the question become fragmented making it harder for us to identify what's been said to you already, and making it next to impossible for somebody following a link in from a search engine to follow answers to a problem that they may be having just because you're impatient.
|
|
|
|
|
But i have posted this nowhere else. Of course i know how the site works!
He who goes for revenge must first dig two graves.
|
|
|
|
|
You've posted it in two places. Q and A, and here. The two aren't linked together.
|
|
|
|
|
Pete,
i went over to Q&A, and that wasn't me. Besides, the questions are quite different. He's trying to export to an XML file, while i'm trying to export data to a Typed XML Schema file. I can do the former, but have problems with the latter. I've seen the responses to that, and they aren't helpful to mine.
I humbly ask, pls is there any1 with a solution to my problem?
He who goes for revenge must first dig two graves.
|
|
|
|
|
|
No problem, Pete, just a misconception.
He who goes for revenge must first dig two graves.
|
|
|
|
|
Do you wish to create the schema as part of the xml production or is that defined already?
Without going near code, SQL Server has got various things in it to retrieve data in XML, using the FOR XML AUTO thing for instance. That is of course, presuming you're using SQL Server.
Regards,
Rob Philpott.
|
|
|
|
|
Rob,
Yes, i'm using SQL Server. The problem is that i'm supposed to pull several data from various tables, and the schema has been defined by my clients in one cumbersome XML schema file. The data includes names, addresses, sales agents (which could be multiple), contacts (phones and emails, which could also be multiple), and so on. So i'm supposed to bring all data relating to one person into an XML file.
That's my problem.
He who goes for revenge must first dig two graves.
|
|
|
|
|
Well, that could be a tricky thing to do depending on how the schema has been laid out. Probably the best approach is to see if you can use the FOR XML AUTO thing with appropriate joins to get your query response to validate against the schema, but then apart from that you might want to look at the XSD tool which could generate business objects from the schema which you'll have to populate manually through code.
Regards,
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote: but then apart from that you might want to look at the XSD tool which could generate business objects from the schema which you'll have to populate manually through code.
I'm sorry i don't know about this.
He who goes for revenge must first dig two graves.
|
|
|
|
|
Ouch. Your choices are either to serialize your different objects out to a temporary location and then use Xslt to convert them, or you create a super class that contains the values and serialize that. If I were you, I'd go with the Xslt approach.
|
|
|
|
|
Ouch. Harder than i thought.
Pete O'Hanlon wrote: Your choices are either to serialize your different objects out to a temporary location and then use Xslt to convert them
i'm sorry, how do i do this? U mean i should write the data into an xml file, then manually use the xsl tool to conform it?
He who goes for revenge must first dig two graves.
|
|
|
|
|
Write to several XML files and then use XSL to form it into one.
|
|
|
|
|
Cumbersome. We've got little time for pilot mode so i guess i'll try it.
Thanx a lot.
He who goes for revenge must first dig two graves.
|
|
|
|
|
|
Thanx a lot. I think LINQ will help us achieve it.
He who goes for revenge must first dig two graves.
|
|
|
|
|
I have done similar things before using an sql data adapter. This produces a seperate file for xml schema though. I'm not sure if this is what your looking for.
SqlCommand cmd = new SqlCommand();
cmd.Connection = new SqlConnection(@"cnnstring");
cmd.Connection.Open();
cmd.CommandText = "SELECT * FROM Table1; SELECT * FROM Table2";
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
ds.WriteXmlSchema(@"C:\dat.xsd");
ds.WriteXml(@"C:\dat.xml");
cmd.Connection.Close();
|
|
|
|
|
how Access to the default page other Webhost
Example http://codeproject.com
Results defalut.aspx
Example http://byethost.com
Results index.php
Please Help
|
|
|
|
|
Do you want to know what it will be called? Because you can't tell in advance. It could be "default.aspx", "index.html", "index.php" or something else, depending on the language it is written in.
Only going there will tell you - you can't determine the language in advance.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
That's a setting of the web server. There, you can define a list of "default" pages which is searched up to the first match, which is then sent to the browser. Typically, you will not see in the browser which page was sent to you. But in case of server redirect, you will see it.
|
|
|
|