|
Thank you leppie,I just want to learn how to dialup with C# (with .NET framework).I know how to do it with RAS library in C#,I want to know if .NET has any support for itself,not with old library .
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Mazdak wrote:
I just want to learn how to dialup with C# (with .NET framework).I know how to do it with RAS library in C#,I want to know if .NET has any support for itself,not with old library .
No support, but what you will see in the future perhaps is wrappers like the Office assembles which makes use from .NET easier.
DBHelper - SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET
|
|
|
|
|
i want to start a process.for that purpose i am using
this code?
string strProcName"c:\\yplayerinstall.exe";
Process tmpProcess;
tmpProcess = new Process();
tmpProcess.EnableRaisingEvents=true;
tmpProcess.StartInfo.FileName=strProcName;
try
{
tmpProcess.Start();
while(! tmpProcess.Responding) System.Windows.Forms.Application.DoEvents();
}
catch
{}
the above code run sucessfully but when i want to start that exe on the network it does not run.
for example the path is this
-------------------------------------------
\\Imran1\SOFTWARE\Yahoo Player\yplayerinstall.exe
--------------------------------------------
where imran1 is computer name and rest of them are folder names.
if i type this address on start->run then the process executed.
Prcess.start does not work i dont know why?
although i have full rights and i can start that exe by double clicking it?
r00d0034@yahoo.com
|
|
|
|
|
Is this a Windows Installer package you are trying to run or a standard EXE? I have noticed that when I try to run Install Packages based on Windows Installer, they will not run unless I Map a drive to the Network directory I am installing from. Have no idea why...
|
|
|
|
|
I think this is by design. The .NET Framework implements a code access security model, that limits access not only based on who is running the code, but where the code came from. The idea is to prevent malicious code from doing damage to your system.
Code installed on your local machine is granted full permissions by default, but code downloaded from another machine is limited based on concepts similar to the Internet Explorer security zones, local intranet, internet, trusted sites, restricted sites. Its possible to change the policies that determine what code can do what, but in your case that's probably not the right thing to do.
It sounds like you're trying to write an installer program. Packaging your application as a Windows Installer package (.MSI file) is a better approach. In installing your package, the user makes a decision to trust your code, then it runs from the local machine, with full permissions. If you need to perform special steps during setup you use a "custom action", which are supported in .NET using the System.Configuration.Install.Installer class hierarchy.
It's not a simple change, but learning about it is probably worth while. Try adding a Visual Studio "deployment project" to your solution. Select the deployment project in the solution explorer and be sure to click on the icons that appear at the top of the solution explorer, they aren't obvious at first, once you discover them your on your way.
Burt Harris
|
|
|
|
|
I am writing an application than needs to know if a given date is equal to the start of daylight saving time for the pacific time zone.
Does anybody knows how to do this? Sample code is most appreciated.
|
|
|
|
|
|
Hi,
Presently i have a client server application in C# where server will be listening to port X in an infinite loop.When a client connects to it , it serves the client.Once its doen serving the client,its goes to loop again.
What iam looking for is to have server doing some task and also listening to the port as well.once it gets connection request from the client , it stops its task,serves the client and then continues its task.
I thought of doing this with two threads where in one thread it will listening for the clients and in the other thread it will be doing some task.
In the thread where it comes to know that a client has contacted it, it should signal other thread to stop its task and resume task only when client is served.
Any help on this will be greatly appreciated.Iam doin this in C#.
Srinivas Reddy
|
|
|
|
|
So the hot way of doing this in C# is to use the asynchronous pattern. This uses multiple threads, but not so explicitly.
Think of it this way: You need one thread that uses Socket.Accept to listen for new connections on the port as you describe. However, when a connection comes in, you don't need to spawn another thread, let the runtime will manage threads for you.
You'll probably want to post a read in response to the connect. Do so with an async method, like NetworkStream.BeginWrite(). You pass a delegate to that method, and when the read completes, the runtime will call you back on what's called a "thread pool" thread. That callback will do some work, and post another asynchronous I/O operation instead of blocking. This way, the thread can return back to the thread pool and be used to service more than one client. This scales much better than a thread-per-client approach. Under the covers, the runtime uses a powerful (if obscure) feature Windows NT call "I/O completion ports", but as a C# programmer, it's fairly easy.
It does call for a design shift. You don't want to block thread-pool threads waiting for I/O, especially network I/O. Instead, you have to break your logic into a set of routines that gather the results from a previous I/O operation (like NetworkStream.EndRead()), do some work, and start another asynchronous operation, perhaps respond using NetworkStream.BeginWrite(). You can even do a BeginWrite follwed with a BeginRead and have both active at the same time, since the Begin methods don't wait for completion.
Warning: Having blocking (synchronous) network call nested deep in several subroutines breaks the model!
The ideal is that you have one thread-pool thread per CPU on your server. That way they can all be working, but you don't encounter excessive context (i.e. thread) switching overhead. In the real world, you typically need more than that because of unpredictable blocking I/O operations like page faults. The runtime & OS dynamically adjust the number of threads to match your program's behavior.
You don't even really need a thread to wait on the Socket.Accept function, as it has an async pair BeginAccept and EndAccept as well.
P.S. I/O Completion ports aren't available on Windows 9x & ME, but don't worry about that, the runtime simulates them if necessary.
Burt Harris
|
|
|
|
|
Hi,
Your answer may not suit what iam looking for.Let me explain it.
There is only one client and sever always in my application.Server should be waiting for a connection for this client asynchronously.I mean when client does not connect to server , it should be reading some data base table and doing some calculations e.t.c.
The client now connects to the server and it sends the message which is
basically telling the server that use different database instead of old one since it will be modified.
So at the point where the client connects, the server should stop the processing that it does with the database table.
I thought let one thread handle ..waiting for the client and another thread handle processing database.
When in the first thread ,client contacts the server,iam looking for a way to suspend/stop that thread execution and continue only after client is done talking to server.
basically its like thread1 having capability to suspend thread2 untill its work is done.
is this possible and is there any way to to this.
anyw help will be greatky appreciated.
srinivas
|
|
|
|
|
I have created a Windows service using C#, and as a vanilla project - straight from the wizard it will not start.
Previous dotnet based Windows services used to work but suddenly they seem to be incapable of starting, the service manager times them out. All other services are working fine.
I am running Windows2000 Professional, service pack 3 - has anyone else seen or had a problem like this ?
Thanks,
Nic
|
|
|
|
|
Check your event logs, both Application and System, and peek at the Security log while there. Usually the messages there will give you a hint. I often find help by looking the event source and message ID up on support.microsoft.com.
Hope that helps
Burt Harris
|
|
|
|
|
Thanks for your reply, but unfortunately there are no indications in the log files.
Cheers,
Nic
|
|
|
|
|
Nic Oughton wrote:
has anyone else seen or had a problem like this ?
Sure ... I did have similar problems like this. Some of the services were dependendant services , which were not sarting and the whole thing goofed up !!!
Did ya check for any dependant services...
Ragav
|
|
|
|
|
Hi,
There are no dependant services. When you had similar problems was it purely down to this - or were there other issues ?
Thanks.
Nic
|
|
|
|
|
I am looking to add progress bars to ListViews just like BearShare does. Can anyone tell me how to do this or point me to a web page?
Thanks!
|
|
|
|
|
|
The mnemomic (short-cut keys) are not showing on all the labels on my Windows Forms in C#. The label's UseMnemonic property is set to true. What could be going on?
Gaulles
|
|
|
|
|
If you have XP, you may need to press the Alt key before you can see them.
To turn off this feature, open up the Display control panel, click the Effects button on the Appearance page, and clear the check from the last item.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Thanks. That took care of it.
Gaulles
|
|
|
|
|
I need to find a C#/.NET implementation of a PushBackInputStream or a simple solution as to how I can use an exisiting C# stream to do the same thing.
Thanks...
Coding is a way of life. It's in the air we breath. It pumps through our veines. Without it we soon crumble to dust. - Rodney S. Foley
|
|
|
|
|
Hi,
Splitter control is great feature added to .Net.I want to create explorer like user interface, but in left pan I have tree control, based on node selection here I want to display different form on right pan.(If any of you remember COM Viewer).Any ideas on how can this be done.
Thanks.
|
|
|
|
|
Well my illustrious leader AKA the boss man, has set me the task of creating an C# application that will print mail merged word documents (merged with data from the C# application), so far I have come up with the following (there is a but, see after the code) :
<br />
private void PrintBookMarkedDoc()<br />
{<br />
object oMissing = System.Reflection.Missing.Value;<br />
object fileName = Environment.CurrentDirectory + @"\dev_template.dot";<br />
object newTemplate = false;<br />
object docType = 0;<br />
object isVisible = true;<br />
<br />
Word.Document ActiveDoc = WordApp.Documents.Add(ref fileName, ref newTemplate, ref docType, ref isVisible);<br />
WordApp.Visible = false;<br />
ActiveDoc.Activate();<br />
<br />
object oWhat = Word.WdGoToItem.wdGoToBookmark;<br />
<br />
object oName = "name";<br />
ActiveDoc.GoTo(ref oWhat, ref oMissing, ref oMissing, ref oName).Text = txtName.Text;<br />
<br />
oName = "val1";<br />
ActiveDoc.GoTo(ref oWhat, ref oMissing, ref oMissing, ref oName).Text = txtValue1.Text;<br />
<br />
oName = "val2";<br />
ActiveDoc.GoTo(ref oWhat, ref oMissing, ref oMissing, ref oName).Text = txtValue2.Text;<br />
<br />
object xcopies = 1;<br />
ActiveDoc.PrintOut(ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref<br />
oMissing,ref oMissing,ref oMissing,ref xcopies,ref oMissing,ref oMissing,ref<br />
oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref<br />
oMissing,ref oMissing,ref oMissing);<br />
<br />
object oSaveChanges = 0;<br />
}<br />
Now this works, and diligently takes values and pumps them into the word document template at a specified bookmark - but yes your right, this isnt really mail merging - as it uses bookmarks and not Word FILL-IN mail merge fields, which presents problems when document templates change etc etc, so I really need proper mailmerging - i.e find all FILL fields in XYZ templates and put VALUE123 in there
Has anybody done anything similar using mailmerge fields, and if so, how on earth do you do it?
p.s. I have tried messing around with Word.WdGoToItem.wdGoToField & Word.WdGoToDirection.wdGoToNext to no avail
Thanks muchly in Advance
Mr Eyes
EDIT :
There is a sample on the MS website, but its a no go, as it doesnt even compile
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q301659
|
|
|
|
|
I usually approach this by recording a macro, doing the operation, and then translating it to C#.
|
|
|
|
|
I have used Mail Merging heavily in a prior project at law firm whose only business was to produce documents (or so it seemed). Word provides an object, appropriately named MailMerge, to provide merging automation - I assume you can use that in C# through Interop, couldn't imagine why you couldn't. I would recommend using a table in an Access file as your DataSource instead. As Eric said, record a macro in VBA and then clean it up for your own use.
HTH
Mike
|
|
|
|
|