|
I think you are running into a problem using .Net 1.0 remoting in a .Net 1.1 runtime environment. See http://www.thinktecture.com/Resources/RemotingFAQ/changes2003.html[^].
I must warn you right off the bat: delegates don't work well at all across application domains, especially ones that are "remote". There is a good reason why it will now throwing an exception. You can "revert" to old .Net 1.0 behavior but I wouldn't recommend it. Even if you do revert to old behavior it still isn't a good practice to use delegates across applictaion domains especially remoted ones.
Consider if you have three clients where the server triggers
CloseSockets. The three clients might not even been in a state where they are ready to handle the delgate (ie. delegates are not interupts!). Also consider that in many networks, the machine requesting/answering is not the machine making the request or answering. Another machine is doing the NAT/proxy/other network manipulation. Although it might work for "localhost" you can easily run into problem traversing even intranets. Again three clients are connected to the server but the server only sees one IP for each of the client. How does the server know which machine on the "other side" of the NAT/proxy/firewall to contact?<br />
<br />
In general, a client/server network design shouldn't rely on the client telling the server to close socks. Strong server systems never rely on its client communication protocol for run state instructions. Clients telling servers "tell me the answer to 3 + 4" is okay. Clients telling servers to "cut network connections" is bad. I emplore you to consider another way to do whatever it is you are attempting to do.
|
|
|
|
|
Thank you for your thoughts. I really appreciate opinions about the logic about the program sense I haven’t used remoting before.
I will probably not use delegates but probably interfaces instead. I create an interface with some functions that the server will have, implement the functions on the server and then have an interface-reference on the remote object to server. But when I do this I still get the security exception. Is this is also bad design?
The remote object must in some way communicate with the server object, which I think shouldn’t be a problem sense they a running in the same process. CloseSockets will close all sockets that are running (of course not to the clients that are using remoting). An administrator should only use this if something goes wrong, sockets will normally be closed by the clients.
The remoting object should as I said talk to the server. Mostly of the communications will be about the state of the server (like how many sockets that are currently running, again not the clients that are using remoting), but it will be more complex operations too (like StartCoffeeMachine and TurnOfTheTv).
|
|
|
|
|
Using the TV example, the TV remote turns off the TV when you hit "Power". It does not do "a turn off the IR sensor". If it did that your remote is now a brick. As long as you aren't using .Net Remoting to tell .Net Remoting hosted objects (or a higher abstraction the server/IIS) to close then you are okay. For instance, having a web page in IIS to make IIS to kill itself is a receipe for disaster because of race conditions.
You seem to have a misunderstanding on what .Net Remoting happens to be. The client domain and the server domain certainly are not running in the same process. For instance any reference changed on one domain will not automatically appear in the other domain. The client can simulate synchronization by "blocking" on the response from the server. Things like garbage collection can happen at any moment, independently on either the client or server application domains. You can just as easily do an asynchronous response. The client domain is more than happy to process independent of the server domain and vice versa. Also the assumption that only one client is communicating with the server has to be a strong assumption because .Net Remoting will not enforce that. If your client application exits abnormally will the next client application be able to talk to the server?
One feature of .Net Remoting is that the client domain doesn't have to continually "ping" the server to keep objects alive in the server domain. Once again this is done so the client and server domains can operate independently. The client shouldn't bother finding out what the status of the server domain until it is called upon. There is no need to tell .Net Remoting to clean up itself any more than any other .Net technology (although the facilities are there if you want to twiddle the settings).
I wish you luck on whatever it is you are doing but I would recommend staying away from cross domain delegates and using singleton/single call remoting styles for administration tools.
|
|
|
|
|
I don't agree about the intranet thing. If you are concerned about proxies/firewalls, you shouldn't be using TCP, you must be considering using HTTP. Not using delegates means that you won't be able to subscribe to events from the server, do you consider that too to be bad design?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Http is just built upon TCP. If you have any situation where you map "many to one" how do you traverse the firewall/network translation? The server only sees an IP plus any information carried along in the Http header. Simply put, how does the server initialize a connection to the client back? You can do it as a response because the client initialized the connection. It is much harder when the server needs to initialize.
For a client-server situation, delegates aren't the best thing to use. As stated since they are in entirely different application domains (let alone different processors/machines) and since delegates are not interupts how in the world can you possibly use them correctly? How do you gaurentee the client is ready to respond to the delegate? You simply can not.
If you want delegates with a setup like that, put the delegate on the client side. Call the server , check the response, fire the delegate from the client to the client. Expecting a server to figure out how to handle a delegate to a client just work out well (believe me I've tried).
|
|
|
|
|
as topic, how do i obtain the screen resolution of user?for example 1024*768 or 800*600...thz..
|
|
|
|
|
This is slightly complicated by the fact that a user can have multiple screens.
The class/object you want is System.Windows.Forms.Screen.
If you only care about the main screen,
<br />
Screen mainScreen = Screen.PrimaryScreen;<br />
Size dimensions = mainScreen.Bounds.Size;<br />
If you need to support all screens, you will need to operate on the Screen array returned from Screen.AllScreens.
Regards,
Ray
|
|
|
|
|
Hello Friends,
Our clients requirement is that we have to use their DLL which is created by C,C++ code.
What I am doing in my code is that :
1. using using System.Runtime.InteropServices;
2. [DllImport(@"g:\SampleDLL.dll",EntryPoint="test",
SetLastError=true,
CharSet=CharSet.Unicode,
CallingConvention=CallingConvention.Winapi)]
3. static extern int test(int lpLibName);
4. and in code calling test function with parmeter as 10.
But I am getting error that entry point "test" not found in SampleDll.dll, but this methods defination written in that dll itself.
Please help me out of this.
Or tell me is there any other way to use that dll?
Sachin Gedam
(Software Engg.)
Pune India
|
|
|
|
|
It's COM you're after.
Here's a little appetizer
http://www.codeproject.com/dotnet/cominterop.asp
|
|
|
|
|
sorry but its not a COM object, its simple a compiled dll created by old school level C,C++ language. And we have to use that dll in our .net project.
Sachin Gedam
(Software Engg.)
Pune India
|
|
|
|
|
|
Im try to open another window with some options in it for an app. but when i try to run it i get an error message "It is invalid to start a second message loop on a single thread. Use Application.RunDialog or Form.ShowDialog instead."
But i dont know how to do the sugestions, the main app can close after the options window is open - if thats any help.
|
|
|
|
|
can u show the code where u start the second form?
|
|
|
|
|
The error message means that you tried to call Application.Run from within the UI thread. Can you show us the code that opens the other window?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
So thats the problem, yeah im trying to open it from a button click within the form.
Would i be able to use a 'goto' and put the application.run somewhere else?
public void buttonOptn_Click(object sender, System.EventArgs e)
{
Application.Run (new ChangeText());
}
|
|
|
|
|
You needn't (and shouldn't) do that. If you want the form to be opened to be modal (ie that form takes the focus and you won't be able to go to the main form until you clost it), simply do
MyNewForm f = new MyNewForm();
f.ShowDialog(this);
If you want it to modeless, instead of calling ShowDialog , just call Show()
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
dear all
i need help in how to play flash in C# application
thz all
|
|
|
|
|
The easiest way is to embed a web browser instance inside your app..
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
there's an easier way. If you go to your toolbox add in manager, and search "flash player", there is a ready made component by macromedia you can simply check to add to your toolbox. Drag it to your form, and there is a property that you tell it to navigate to a url or local file to play. I'm not sure exactly what the "flash player" is called, but it is something like that. Hope this helps.
|
|
|
|
|
its helpfull
many many many thx
|
|
|
|
|
hi,
any method to add versioning information automatically in .NET? or, any method to place the build date/time in the source file then i can read it back in the binary?
thanks,
jim
|
|
|
|
|
No, but you can easily read the PE filetimestamp using the following.
DateTime compiletime = new DateTime(1970, 1,1).AddSeconds(BitConverter.ToUInt32(data, 136));
where data is a byte[] representing the PE file (assembly).
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
|
yes, this is great! thanks!!!
|
|
|
|
|
Hi
Does anyone knows if there is any ICQ client on C# under project?
Thanks
|
|
|
|