|
Well, you could use the offset as you did, but then you would have to declare a buffer that is as large as the entire file.
The second parameter is the offset in the buffer, not the offset in the files. The stream objects will keep track of where in the files you are reading and writing.
---
b { font-weight: normal; }
|
|
|
|
|
great thank u about this More than Enough and perfect Answer , now I konw how it work fine
welcome for any comments , Questions
|
|
|
|
|
Hi All,
I have a problem in C# Remoting. I am doing as given below code. I am also giving different Computername and Portname. Every time m_DisplayComputerName and m_lDisplayPort read from the Database. But Still I am getting error.
"Only one usage of each socket address (protocol/network address/port) is normally permitted"
//This is client and connection() funtion in Constructor
private void Connection()
{
try
{
// First check if a Channel with the computername already exists.
IChannel oChannel = ChannelServices.GetChannel(m_DisplayComputerName);
if (oChannel == null)
{
// then we need to create.
IDictionary props = new Hashtable();
props["name"] = m_DisplayComputerName;
props["port"] = m_lDisplayPort;
BinaryClientFormatterSinkProvider clientSink = new BinaryClientFormatterSinkProvider();
BinaryServerFormatterSinkProvider serverSink = new BinaryServerFormatterSinkProvider();
oChannel = new TcpChannel(props,clientSink,serverSink);
//oChannel = new TcpChannel(props,null,null);
ChannelServices.RegisterChannel(oChannel);
}
/*else
{
// do nothing
}*/
}
catch(System.Net.Sockets.SocketException ex)
{
MessageBox.Show(ex.Message);
}
m_remoting = (RFDisplayStation_Remoting_Interface.IRFDisplaystation_Remoting_Interface)Activator.GetObject(
typeof(RFDisplayStation_Remoting_Interface.IRFDisplaystation_Remoting_Interface),
GetURL());
}
private string GetURL()
{
return "Tcp://" + m_DisplayComputerName + ":" + m_lDisplayPort + "/RemotingKeyWord";
}
///////Server side And also in Constructor
try
{
ChannelServices.RegisterChannel(new TcpChannel((int)(m_ResourceDetailsArray[0].DisplayPort)));
}
catch(System.Net.Sockets.SocketException ex)
{
MessageBox.Show(ex.Message);
}
Thanks
-- modified at 21:14 Saturday 7th January, 2006
|
|
|
|
|
Is that code being run after you're running a server locally that uses the same port? Usually that error occurs when you've got 2 apps using the same port simultaneously.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Little House on the Flickr
Judah Himango
|
|
|
|
|
It is a bug in .Net 1.1 which has been removed in .Net 2.0. It only happens in case of abnomal shutdown of ur server. There are some tools available on .Net that will release the specifed port for u.
Hope it will help u
Akif
|
|
|
|
|
we had same problems. our solution was to wrap all channel and communication jobs in to a disposable class. That means after the container is shut untidily, with container disposition all goes disposing. you should contact this class with yor process as acontainer so if it goes also your class goes disposing...
Mikail Çetinkaya . The C# DEveloper
|
|
|
|
|
Thanks for all. Yes I fixed it. Now it is running.
Thanks a lot.
-- modified at 13:29 Sunday 8th January, 2006
|
|
|
|
|
ei guys... juz wanna thank you for the reply. it really help. hehehe... i'm sori if anyone get offended, its juz so new to me. i tried to read some books but our library is a limited resources about C#. i tried to look at the internet but its not enough. can you suggest a web site that can help me with my prob. thanks!!!
pls and thank you...
|
|
|
|
|
What problem are you having?
If you need samples, check this[^] out. If it's learning materials in general, go buy some books, and if possible, take some .NET training courses.
|
|
|
|
|
How to add a control of type TextBox or ComboBox to a ToolBar in Runtime
Is It Possible too !!
Ahmad Shaban
|
|
|
|
|
Candseeme wrote: How to add a control of type TextBox or ComboBox to a ToolBar in Runtime
You already are adding controls to the form at run time - Take a look at the designer written code to see how it is done.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
use forms' topmost property to true or bring forward type methods
Mikail Çetinkaya . The C# DEveloper
|
|
|
|
|
What do I use instead of addressof.I am trying to p/invoke Win32 API CreateThread in a C# application.One of the API's parameter is the address of the function which the thread will execute.
|
|
|
|
|
|
|
And problably one based on some incorrect assumptions.
By using the unmanaged Win32 thread functions, you introduce garbage collection issues with your managed code being executed from an unmanaged thread.
There is no reason I can think of that would be good enough to justify this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
So was I. Bummer....
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You want entertainment…… well you got it! :
I have a C# application that invokes COM objects. I need to stop a COM instance from executing when it executes more than a predefined amount of time. Each COM instance is assigned a thread.
System.Thread.Abort() does not achieve that result because when calling Abort() on a thread, if the thread is currently executing native code (or COM in my case), nothing will happen until the thread returns to managed code. To solve the problem I thought with the help of the forum of these solutions:
1. Creating an exe (Process) that invokes the COM and assign a thread to a function that launches that exe. When a thread aborts, I will kill the exe and stop the COM execution. This approach has worked.
2. Create a MTA COM component that spawns a native thread and the COM object with methods added to the abort the Native threads.
3. Instead of using Managed Threads, I can P/Invoke Native threads by using the CreateThread/ExitThread/TerminateThread API. Aborting threads occurs in a rare occasion.
I appreciate any useful comment.
|
|
|
|
|
If anyone is interested ,delegates are used instead of addressof.
|
|
|
|
|
Well, it took me looking into your message histroy to see what's you're really trying to do here. Launching multiple instances of VB6-created .DLL, COM based. Hmmmm....interesting since VB6 runtime doesn't support threading, directly anyway.
Creating a seperate .EXE will work, since each launch of the .EXE will, of course, spawn on it's own thread. This will also make any communication with the instance of the .DLL a huge PITA, since now your crossing a Process boundry. I hope this .DLL doesn't do anything useful to the form.
In my opinion, option number 2 is your best bet. Keep manangement of the unmanaged threads in a COM-based component that exposes any interface your .NET app can use to control the launching and shutdown of the VB6 component instances. This COM component can also handle communication to and from the VB6 stuff for your Managed code to.
Why do I say this? Because in your original post, that you didn't tell us anything about, it sounds like this VB6 component could be replaced sometime in the future. By creating a wrapper for the VB6 threads, you can easily replace this interface component with a different interface when the VB6 component is finally replaced by managed code.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I needed a quick answer to a quick question!
I am working on Options 2 and 3(Option1 is done) in parallel since they hold the same complexity which is mainly working with unmanaged threads.In both cases i am creating a wrapper to the COM either with creating COM-based component or a .net assembly or class( never figured it out yet).The problem i am facing is how to stop a thread execution.TerminateThread is not the answer(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/terminatethread.asp[^]), how to gently terminate a thread keeping in mind that the COM source code cannot be changed.Any code can only be added to the Wrapper.
|
|
|
|
|
You don't have a choice here. Either your VB6 code was written to terminate itself property on some flag, or you'll have to forcefully kill it, which will lead to memory and handle leaks.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks man i appreciate it..
|
|
|
|
|
Thanks Dave i appreciate it..
|
|
|
|